Example #1
0
 public static function __callStatic($method, $args)
 {
     if (is_null(static::$schema)) {
         static::$schema = DB::schema();
     }
     return call_user_func_array([static::$schema, $method], $args);
 }
Example #2
0
 /**
  * Drop all the table/column that aren't defined
  */
 public static function dropMissing()
 {
     foreach (self::$tables as $n => $k) {
         if (!isset(SchemaBuilder::$tables[$n])) {
             DB::schema($n)->drop();
         } else {
             $table = SchemaBuilder::$tables[$n];
             foreach ($k->getColumns() as $name_column => $column) {
                 if ($table->getColumn($name_column) == null) {
                     DB::schema($n)->dropColumn($name_column);
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * Returns the array describing the database schema.
  *
  * If the $table parameter is passed, the method will return the schema for the given table,
  * otherwise - for the whole database.
  *
  * @static
  *
  * @throws APIException if the given table does not exist
  *
  * @param string $table
  *
  * @return array
  */
 public static function getSchema($table = null)
 {
     if (is_null(self::$schema)) {
         self::$schema = (include dirname(__FILE__) . '/../../' . self::SCHEMA_FILE);
     }
     if (is_null($table)) {
         return self::$schema;
     } elseif (isset(self::$schema[$table])) {
         return self::$schema[$table];
     } else {
         self::exception(self::SCHEMA_ERROR, _s('Table "%1$s" does not exist.', $table));
     }
 }
Example #4
0
 public static function getSchema($table = null)
 {
     if (is_null(self::$schema)) {
         self::$schema = (include self::SCHEMA_FILE);
     }
     if (is_null($table)) {
         return self::$schema;
     } else {
         if (isset(self::$schema[$table])) {
             return self::$schema[$table];
         } else {
             return false;
         }
     }
 }