Exemple #1
0
 public static function query($sql, $type = "exec")
 {
     self::getinstance("read");
     if (c("debug")) {
         adduptime("queryStartTime");
     }
     switch ($type) {
         case "query":
             $result = self::$link->query($sql);
             break;
         case "exec":
             $result = self::$link->exec($sql);
     }
     if (c("debug")) {
         self::debug($sql);
     }
     ++self::$query_num;
     if ($result === FALSE) {
         $error = "Db Error: PDO query error code is " . self::$link->errorCode();
         throw_exception($error);
     }
     return $result;
 }
Exemple #2
0
 public static function debug($sql)
 {
     adduptime("queryEndTime");
     Log::record($sql . " [ RunTime:" . adduptime("queryStartTime", "queryEndTime", 6) . "s ]", Log::SQL);
 }