예제 #1
0
 /**
  * To check a particular key exists in the dictionary.
  *
  * @param <object> $key
  */
 public function ContainsKey($key)
 {
     $objectID = $key->getObjectID();
     if (array_key_exists($objectID, $this->_entries)) {
         return TRUE;
     }
     return FALSE;
 }
예제 #2
0
 /**
  *
  * @param type $from
  */
 public function search()
 {
     //whitelisting to prevent sql injection
     if ($this->order != 'Asc' && $this->order != 'Desc') {
         $this->order = 'Desc';
     }
     if (!in_array($this->sort, array_keys($this->sort_keys))) {
         $this->sort = "post_created";
     }
     //$t1 = microtime(true);
     $base_qry = $this->build_query();
     $qry = $this->setSelectors($base_qry, $this->getSelectors());
     $obj = $this->db->prepare($qry);
     if (!empty($this->cats)) {
         $this->values = array_merge($this->values, array($this->cats));
     }
     $values = $this->values;
     $obj->execute($this->values);
     $res = $obj->fetchAll();
     if ($this->count_rows) {
         if ($this->isMySQL) {
             $cnt_qry = 'SELECT  FOUND_ROWS();';
             $cnt_obj = $this->db->prepare($cnt_qry);
             $cnt_obj->execute();
         } else {
             $cnt_qry = $this->setSelectors($base_qry, 'COUNT(p.post_id)');
             $cnt_obj = $this->db->prepare($cnt_qry);
             $cnt_obj->execute($values);
         }
         $rows = $cnt_obj->fetch();
         $this->count = $rows[0];
     }
     return $res;
     //echo microtime(true) - $t1;
 }
예제 #3
0
파일: DB.php 프로젝트: kaka987/YoungYaf
 /**
  * *取结果$result中第一行记录
  *
  * @param  <object> $result :查询结果数据集
  * @param  <bool> $assoc :true 返回数组; false 返回stdClass对象;默认 false
  * @return 没有结果返回 false
  */
 public static function fetchRow($result = null, $assoc = false)
 {
     if (empty($result)) {
         return false;
     }
     if ($assoc) {
         return $result->fetch_assoc();
     } else {
         return $result->fetch_object();
     }
 }