コード例 #1
0
ファイル: CRUD.php プロジェクト: neoartdoo/CMS
 public function dbQS($id, $table, $field = "id", $limit = 'LIMIT 1')
 {
     $noCacheTables = array('_users', '_users_groupes', '_dg_firewall', '_users_info');
     $fieldToCache = array('id', 'uri');
     if (!in_array($field, $fieldToCache) || $limit !== 'LIMIT 1' || in_array($table, $noCacheTables) || !ACTIVE_CACHE) {
         $array_selection = array();
         $query = "SELECT * FROM " . $table . " WHERE " . $field . " = '" . $id . "' " . $limit;
         //echo $query.'<br />';
         $verif_req = $this->dbpdo->query($query);
         $imax = $verif_req->columnCount();
         while ($verif_reqs = $verif_req->fetch(PDO::FETCH_ASSOC)) {
             for ($i = 0; $i < $imax; $i++) {
                 $meta = $verif_req->getColumnMeta($i);
                 $name = $meta['name'];
                 $array_selection[$name] = $verif_reqs[$name];
             }
         }
         return $array_selection;
     }
     $fileName = $table . '-' . $field . '-' . $id . '.php';
     $cache = new DBCache($table, $fileName);
     if (!$cache->statut) {
         $array_selection = array();
         $query2 = "SELECT * FROM " . $table . " WHERE " . $field . " = '" . $id . "' " . $limit;
         $verif_req = $this->dbpdo->query($query2);
         $imax = $verif_req->columnCount();
         while ($verif_reqs = $verif_req->fetch(PDO::FETCH_ASSOC)) {
             for ($i = 0; $i < $imax; $i++) {
                 $meta = $verif_req->getColumnMeta($i);
                 $name = $meta['name'];
                 $array_selection[$name] = $verif_reqs[$name];
             }
         }
         $cache->ecrire($array_selection);
     } else {
         $array_selection = $cache->get;
     }
     return $array_selection;
 }