__construct() public method

Instantiate class
public __construct ( SQL $db, $table, $fields = NULL, $ttl = 60 )
$db DB\SQL object
$table string
$fields array|string
$ttl int|array
示例#1
0
 public function __construct($id = null)
 {
     parent::__construct(\Base::instance()->get('DB'), 'connections');
     if ($id) {
         $this->load('id = ' . $id);
     }
 }
示例#2
0
 function __construct()
 {
     $f3 = \Base::instance();
     $db = $f3->get('DB');
     // This is where the mapper and DB structure synchronization occurs
     parent::__construct($db, 'tb_users');
 }
示例#3
0
 function __construct($uid = NULL)
 {
     parent::__construct(\kksd\Sesi::$DB, "users");
     if ($uid != NULL) {
         $this->load(array("id=?", $uid));
     }
 }
示例#4
0
文件: SQL.php 项目: eghojansu/shap
 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();
 }
示例#5
0
 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);
 }
示例#7
0
 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;
 }
示例#8
0
 public function __construct()
 {
     parent::__construct(\Base::instance()->get('DB'), \Config::instance()->prefix . "log");
 }
示例#9
0
 /** 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;
 }
示例#10
0
 public function __construct()
 {
     $this->db = static::getDibi();
     parent::__construct($this->db, static::TABLE_NAME);
 }
示例#11
0
 public function __construct(\DB\SQL $db)
 {
     parent::__construct($db, 'cards');
 }
示例#12
0
 public function __construct(\DB\SQL $db)
 {
     parent::__construct($db, 'affiliates');
 }
示例#13
0
文件: model.php 项目: svlt/back
 /**
  * Initialize model instance
  */
 function __construct()
 {
     parent::__construct(App::db(), $this->getTableName());
 }
示例#14
0
 public function __construct(\DB\SQL $db)
 {
     parent::__construct($db, 'upcoming');
 }
示例#15
0
文件: LoanType.php 项目: srccn/f3
 public function __construct(DB\SQL $db)
 {
     parent::__construct($db, 'loan_type');
 }
示例#16
0
 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();
 }
示例#17
0
 /**
  *
  * @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);
     }
 }
示例#18
0
 function __construct()
 {
     $f3 = \Base::instance();
     $db = $f3->get('DB');
     parent::__construct($db, 'tb_rating');
 }
示例#19
0
 /**
  *
  * @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);
     }
 }
示例#20
0
 public function __construct()
 {
     parent::__construct(\Base::instance()->get('DB'), 'serietype');
 }
示例#21
0
 public function __construct(\DB\SQL $db)
 {
     parent::__construct($db, 'members');
 }