Answer the question
In order to leave comments, you need to log in
Change property of parent class?
Greetings colleagues! I am writing my bike, type MVC. There is a model
<?php
namespace App\Models;
use PDO;
class Model{
protected $dbname="shop";
protected $dbuser="root";
protected $dbpass="";
protected $table='items';
public $db;
function __construct(){
try {
$this->db=new PDO("mysql:dbname=$this->dbname;dbhost=localhost;charset=utf8",$this->dbuser,$this->dbpass);
}
catch(PDOException $e) {
echo $e->getMessage();
die();
}
}
function all(){
$db=$this->db;
$model=$db->query("select * from $this->table");
return $model;
}
}
....
static function all(){
$model=new Model;
$item=$model->all();
return View::render('show',['items'=>$item]);
}
....
class items extends Model {
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question