コード例 #1
0
 /**
  * Returns true if this storage mechanism is ready to be used.  false otherwise.
  */
 public function isAvailable()
 {
     $qry = 'SHOW TABLES LIKE "config_alt"';
     $result = $this->db->query($qry);
     if (I2CE::pearError($result, "Cannot access database")) {
         return false;
     }
     if ($result->numRows() == 0) {
         I2CE::raiseError("No config_alt");
         return false;
     }
     if (count($this->db_statements) != 5) {
         I2CE::raiseError("No prep stmts:" . count($this->db_statements));
         return false;
     }
     return true;
 }
コード例 #2
0
 /**
  * Return list of articles
  * 
  * @param integer $start
  * @param integer $max
  * @param string $order_field
  * @param string $order_dir
  * @param string $filter
  */
 private function dataArticles($start = 0, $max = 10, $order_field = "date", $order_dir = "desc", $filter = '')
 {
     $order_by = " ORDER BY";
     if ($filter != '') {
         $filter = ' WHERE ' . $filter;
     }
     switch ($order_field) {
         case 'id':
             $order_by = $order_by . " Article_ID";
             break;
         case 'url':
             $order_by = $order_by . " Article_URL_Name";
             break;
         case 'date':
         default:
             $order_by = $order_by . " Article_Date";
             break;
     }
     switch ($order_dir) {
         case 'asc':
             $order_by = $order_by . " ASC";
             break;
         case 'desc':
         default:
             $order_by = $order_by . " DESC";
             break;
     }
     if ($max != 0) {
         $limit = "LIMIT {$start}, {$max}";
     } else {
         $limit = "";
     }
     $querySearch = "SELECT `article_id` FROM articles {$filter} {$order_by} {$limit}";
     $querySearchResults = $this->_db->query($querySearch);
     $data = $querySearchResults->fetchAll(MDB2_FETCHMODE_ASSOC);
     $querySearchResults->free();
     return $data;
 }
コード例 #3
0
ファイル: DataBase.class.php プロジェクト: cmooony/d4d-studio
 public function query($sql)
 {
     $startTime = microtime(true);
     $ret = parent::query($sql);
     $costTime = sprintf('%01.4f', microtime(true) - $startTime);
     if ($costTime > 1) {
         $this->_log("SLOW QUERY:\t{$sql}");
     }
     return $ret;
 }
コード例 #4
0
 /**
  * Return array of list of images ids 
  * 
  * @param integer $start
  * @param integer $max
  * @param array $filters
  * @param string $order
  * @param boolean $all
  * 
  * @return array
  */
 private function qImageId($start, $max, $filters, $order, $all = false)
 {
     $data = array();
     $where = $this->filterSQL($filters);
     if ($all) {
         $querySearch = "SELECT im.`Image_ID` FROM `photo_images` im " . $where . " ORDER BY im.`Image_ID` {$order}";
     } else {
         $querySearch = "SELECT im.`Image_ID` FROM `photo_images` im " . $where . " ORDER BY im.`Image_ID` {$order} LIMIT {$start}, {$max}";
     }
     $querySearchResults = $this->_db->query($querySearch);
     $data = $querySearchResults->fetchAll();
     $querySearchResults->free();
     return $data;
 }