コード例 #1
0
ファイル: model.ModelPost.php プロジェクト: arno06/Achilles
 public function all($pCond = null, $pFields = "*")
 {
     $all = parent::all($pCond, $pFields);
     foreach ($all as &$post) {
         $post['categories'] = Query::select('b.*', 'post_category a')->join('main_category b', Query::JOIN_INNER, 'a.id_category=b.id_category')->andWhere('a.id_post', Query::EQUAL, $post['id_post'])->execute();
     }
     return $all;
 }
コード例 #2
0
ファイル: class.Query.php プロジェクト: arno06/Savely
 /**
  * @static
  * @param $pTable
  * @param null|QueryCondition $pCondition
  * @param String $pHandler
  * @return int
  */
 public static function count($pTable, QueryCondition $pCondition = null, $pHandler = "default")
 {
     $q = Query::select("count(1) as nb", $pTable)->setCondition($pCondition)->execute($pHandler);
     return $q[0]["nb"];
 }
コード例 #3
0
ファイル: class.BaseModel.php プロジェクト: arno06/Savely
 /**
  * @param null|QueryCondition $pCond
  * @param string $pFields
  * @return array|resource
  */
 public function all($pCond = null, $pFields = "*")
 {
     return $this->prepareJoin(Query::select($pFields, $this->table))->setCondition($pCond)->execute($this->handler);
 }
コード例 #4
0
ファイル: class.TasteIt.php プロジェクト: arno06/Achilles
 public static function debugger()
 {
     trace("premiere action trace");
     trigger_error("Une notice trigger par le code", E_USER_NOTICE);
     for ($i = 0; $i < 20; $i++) {
         trigger_error("Un warning trigger &agrave; chaque itération", E_USER_WARNING);
         if ($i % 3 == 0) {
             trace("i : " . $i);
         }
     }
     trace("before sleep 10 secondes");
     sleep(10);
     trace("after sleep 10 secondes");
     trace("derni&egrave;re action trace");
     Query::select("*", "ma_table")->join("mon_autre_table")->andWhere("un_champ", Query::EQUAL, "une valeur")->limit(0, 1)->groupBy("some_id")->execute();
 }
コード例 #5
0
ファイル: model.ModelLink.php プロジェクト: arno06/Savely
 private function decorateLink(&$pData)
 {
     $s = Query::select('*', 'sil_states')->andWhere('id_link', Query::EQUAL, $pData['id_link'])->andWhere('price_state', Query::UPPER, '0')->order('date_state', 'DESC')->limit('0', '1')->execute($this->handler);
     $pData['last_state'] = $s[0];
     $s = Query::execute("SELECT MIN(ROUND(price_state, 2)) as previous_price FROM sil_states WHERE id_link = '" . $pData['id_link'] . "' AND ROUND(price_state, 2) > '" . $pData['last_state']['price_state'] . "' AND price_state > 0 AND date_state BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW() ORDER BY date_state;", $this->handler);
     $pData['previous_price'] = null;
     if (!empty($s)) {
         $pData['previous_price'] = round($s[0]['previous_price'], 2);
         if ($pData['previous_price'] == $pData['last_state']['price_state']) {
             $pData['previous_price'] = null;
         }
     }
 }