Пример #1
0
 /**
  * 开启一个查询,并根据提供的参数设置查询对象
  *
  * @param array $args
  *
  * @return QDB_Select
  */
 function findByArgs(array $args = array())
 {
     $select = new QDB_Select(QDB::getConn($this->_dsn));
     $select->setSQL($this->_find_sql)->asColl()->asObject($this->class_name);
     $c = count($args);
     if ($c > 0) {
         if ($c == 1 && is_int($args[0]) && $this->idname_count == 1) {
             $select->where(array(reset($this->idname) => $args[0]));
         } else {
             call_user_func_array(array($select, 'where'), $args);
         }
     }
     return $select;
 }
Пример #2
0
 /**
  * 开启一个查询,并根据提供的参数设置查询对象
  *
  * @param array $args
  *
  * @return QDB_Select
  */
 function findByArgs(array $args = array())
 {
     $select = new QDB_Select($this->table->getConn());
     $select->asColl()->from($this->table)->asObject($this->class_name);
     $c = count($args);
     if ($c > 0) {
         if ($c == 1 && is_int($args[0]) && $this->idname_count == 1) {
             $select->where(array(reset($this->idname) => $args[0]));
         } else {
             call_user_func_array(array($select, 'where'), $args);
         }
     }
     if ($this->inherit_base_class && $this->inherit_type_field) {
         // 如果是来自某个继承类的查询,则限定只能查询该类型的对象
         $select->where(array($this->inherit_type_field => $this->class_name));
     }
     return $select;
 }
Пример #3
0
 /**
  * 发起一个查询,获得一个 QDB_Select 查询对象
  *
  * @return QDB_Select
  */
 function select()
 {
     if (!$this->_inited) {
         $this->init();
     }
     $select = new QDB_Select($this->_conn);
     $select->from($this);
     $args = func_get_args();
     if (!empty($args)) {
         call_user_func_array(array($select, 'where'), $args);
     }
     return $select;
 }
Пример #4
0
 /**
  * 开启一个查询,并根据提供的参数设置查询对象
  *
  * @param array $args
  *
  * @return QDB_Select
  */
 function findByArgs(array $args)
 {
     $select = new QDB_Select($this->table->getConn());
     $select->asObject($this->class_name)->from($this->table);
     $c = count($args);
     if ($c > 0) {
         if ($c == 1 && intval($args[0]) == $args[0] && is_numeric($args[0]) && $this->idname_count == 1) {
             $select->where(array(reset($this->idname) => $args[0]));
         } else {
             call_user_func_array(array($select, 'where'), $args);
         }
     }
     return $select;
 }
Пример #5
0
 /**
  * 开启一个查询,并根据提供的参数设置查询对象
  *
  * @param array $args
  *
  * @return QDB_Select
  */
 function findByArgs(array $args)
 {
     $select = new QDB_Select($this->table->getConn());
     $select->asObject($this->class_name)->from($this->table);
     if (count($args)) {
         call_user_func_array(array($select, 'where'), $args);
     }
     return $select;
 }