Instantiate class
public __construct ( |
||
$db | object | |
$table | string | |
$fields | array|string | |
$ttl | int|array |
public function __construct($id = null) { parent::__construct(\Base::instance()->get('DB'), 'connections'); if ($id) { $this->load('id = ' . $id); } }
function __construct() { $f3 = \Base::instance(); $db = $f3->get('DB'); // This is where the mapper and DB structure synchronization occurs parent::__construct($db, 'tb_users'); }
function __construct($uid = NULL) { parent::__construct(\kksd\Sesi::$DB, "users"); if ($uid != NULL) { $this->load(array("id=?", $uid)); } }
public function __construct() { $this->tableName || ($this->tableName = Shap::className(get_called_class())); $connID = 'CONNECTION.' . $this->connection; if (!Registry::exists($connID)) { $fw = Base::instance(); $config = ($fw[$connID] ?: []) + ['type' => null, 'file' => null, 'name' => null, 'host' => null, 'user' => null, 'pass' => null, 'port' => 3306]; $dsn = $config['type'] . ':'; switch ($config['type']) { case 'sqlite': $dsn .= $config['file']; break; case 'mysql': $dsn .= 'host=' . $config['host'] . ';port=' . $config['port'] . ';dbname=' . $config['name']; break; default: $dsn = null; break; } if (empty($dsn)) { throw new InvalidArgumentException(sprintf(self::E_Connection, $connID)); } Registry::set($connID, new \DB\SQL($dsn, $config['user'], $config['pass'])); } parent::__construct(Registry::get($connID), $this->tableName); if (empty($this->pkeys)) { foreach ($this->fields as $field => $schema) { false === $schema['pkey'] || ($this->pkeys[] = $field); } } $this->init(); }
function __construct() { parent::__construct(\kksd\Sesi::$DB, "tblpost"); if (!empty($pid)) { $this->load(array("pid = ?", $pid)); if ($this->loaded() == 0) { throw new \Exception("Error: IDnya nggak ada di database."); } $this->casted = parent::cast(); $this->user = new \Model\User($this->casted['uid']); } }
public function __construct($table = null, $fields = NULL, $ttl = 60) { $class = get_called_class(); $isMySQL = preg_match('/mysql/i', $class); if ($table === null) { $temp = explode('\\', $class); $table = strtolower(end($temp)); } $fw = $this->fw(); $db = $isMySQL ? $fw->get('MySQLDB') : $fw->get('SQLiteDB'); parent::__construct($db, $table, $fields, $ttl); }
function __construct($table_name = null) { $f3 = \Base::instance(); if (empty($this->_table_name)) { if (empty($table_name)) { $f3->error(500, "Model instance does not have a table name specified."); } else { $this->table_name = $table_name; } } parent::__construct($f3->get("db.instance"), $this->_table_name, null); return $this; }
public function __construct() { parent::__construct(\Base::instance()->get('DB'), \Config::instance()->prefix . "log"); }
/** Set up a new SQL mapped object */ public function __construct($name, $db) { parent::__construct($db->connection, strtolower($name)); $this->name = strtolower($name); $this->database = $db; }
public function __construct() { $this->db = static::getDibi(); parent::__construct($this->db, static::TABLE_NAME); }
public function __construct(\DB\SQL $db) { parent::__construct($db, 'cards'); }
public function __construct(\DB\SQL $db) { parent::__construct($db, 'affiliates'); }
/** * Initialize model instance */ function __construct() { parent::__construct(App::db(), $this->getTableName()); }
public function __construct(\DB\SQL $db) { parent::__construct($db, 'upcoming'); }
public function __construct(DB\SQL $db) { parent::__construct($db, 'loan_type'); }
public function __construct($table = null, $fields = null, $ttl = 60) { $db = Base::instance()->get($this->connection); parent::__construct($db, $table ?: $this->source, $fields, $ttl); $this->init(); }
/** * * @param mixed $table 数据表的名字,如果是单个表,可以是 'user',多个表可以是 array('user', 'user_info' => 'ui') * @param int $ttl 缓存多少秒 * * */ function __construct($table, $ttl = 600) { $dbEngine = static::getDbEngine(); // 检查数据库连接 if (null == $dbEngine) { throw new \InvalidArgumentException('can not find dbEngine'); } if (null == $table) { return parent::__construct($dbEngine, null, null, $ttl); } // 多表联合查询 if (is_array($table)) { $tableArray = array(); foreach ($table as $key => $value) { if (is_string($key)) { $tableArray[] = static::tableName($key); continue; } $tableArray[] = static::tableName($value); } // By Syncxplus: 这里表名传入数组会出错, 修改为传入第一张表名; // 实际进行多表查询的时候, 没有用到parent(f3: \DB\SQL\Mapper)的实例或函数, 因此只要传入一个表名能够成功调用构造函数即可 // return parent::__construct($dbEngine, $tableArray, null, $ttl); return parent::__construct($dbEngine, $tableArray[0], null, $ttl); } // 单表查询 if (is_string($table)) { parent::__construct($dbEngine, static::tableName($table), null, $ttl); } }
function __construct() { $f3 = \Base::instance(); $db = $f3->get('DB'); parent::__construct($db, 'tb_rating'); }
/** * * @param mixed $table 数据表的名字,如果是单个表,可以是 'user',多个表可以是 array('user', 'user_info' => 'ui') * @param int $ttl 缓存多少秒 * * */ function __construct($table, $ttl = 600) { $dbEngine = static::getDbEngine(); // 检查数据库连接 if (Utils::isEmpty($dbEngine)) { throw new \InvalidArgumentException('can not find dbEngine'); } if (null == $table) { return parent::__construct($dbEngine, null, null, $ttl); } // 多表联合查询 if (is_array($table)) { $tableArray = array(); foreach ($table as $key => $value) { if (is_string($key)) { $tableArray[] = static::tableName($key); continue; } $tableArray[] = static::tableName($value); } return parent::__construct($dbEngine, $tableArray, null, $ttl); } // 单表查询 if (is_string($table)) { parent::__construct($dbEngine, static::tableName($table), null, $ttl); } }
public function __construct() { parent::__construct(\Base::instance()->get('DB'), 'serietype'); }
public function __construct(\DB\SQL $db) { parent::__construct($db, 'members'); }