部分代码:
\app\model\cModel.php下:
class cModel extends model
{
public $table;
public function __construct($table1)
{
$this->table = $table1;
}
public function lists()
{
$ret = $this->select($this->table,'*');
return $ret;
}
\app\ctrl\indexCtrl.php下:
<?php
namespace app\ctrl;
use core\lib\model;
class indexCtrl extends \core\future
{
public function index(){
$table1 = 'users';
$model = new \app\model\cModel($table1);
$ret = $model->delOne(1);
dump($ret);
$ret1 = $model->lists();
dump($ret1);
}
}
值可以传过去,但是报medoo的错误,Undefined property: app\model\cModel::$pdo
解决了,,因为子类的构造函数 会覆盖父类的构造函数,,于是在子类中声明构造函数的时候,需要在子类中继承父类的构造函数,以使父类的构造函数依然生效。代码:
public function __construct($table1)
{
$this->table = $table1;
parent::__construct(); //祸根就出在这里!!!
}