示例#1
0
 public static function handleError($query = null, $queryLog = null, $parameters = null)
 {
     $Connection = DB::getConnection();
     if ($Connection->errorCode() == '42S02' && static::$autoCreateTables) {
         $CreateTable = SQL::getCreateTable(static::$rootClass);
         // history versions table
         if (static::isVersioned()) {
             $CreateTable .= SQL::getCreateTable(static::$rootClass, true);
         }
         $Statement = $Connection->query($CreateTable);
         // check for errors
         $ErrorInfo = $Statement->errorInfo();
         // handle query error
         if ($ErrorInfo[0] != '00000') {
             self::handleError($query, $queryLog, $errorHandler);
         }
         // clear buffer (required for the next query to work without running fetchAll first
         $Statement->closeCursor();
         return $Connection->query($query);
         // now the query should finish with no error
     } else {
         return DB::handleError($query, $queryLog, $parameters);
     }
 }