示例#1
0
文件: dal.php 项目: reith2004/domain
 protected function get_columns($table)
 {
     $table = explode(' AS ', $table);
     $table = $table[0];
     $table_info = DBManager::table($table)->info();
     return array_map(function ($column) {
         return $column['name'];
     }, $table_info);
 }
示例#2
0
// --------------------------------------------------------------
Route::filter('authority', function ($resource) {
    $action = Request::$route->parameters['0'];
    if (Authority::cannot($action, $resource)) {
        return Response::make('', 401);
    }
});
Route::filter('auth', function () {
    if (Auth::guest()) {
        return Redirect::make('', 401);
    }
});
// --------------------------------------------------------------
// Setting system tables
// --------------------------------------------------------------
DBManager::$hidden = Config::get('domain::dbmanager.hidden');
$api_version = Config::get('layla.domain.api.version');
// --------------------------------------------------------------
// Map the Base Controller
// --------------------------------------------------------------
Autoloader::map(array('Domain_Base_Controller' => __DIR__ . DS . 'controllers' . DS . 'base' . EXT));
Route::filter('api_auth', function () {
    if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
        //return Response::json(array(), 401);
    }
    //Auth::attempt();
});
Bundle::start('thirdparty_bob');
// --------------------------------------------------------------
// Load the routes
// --------------------------------------------------------------
示例#3
0
 /**
  * Create a new table
  * 
  * <code>
  * // input example
  * $input = array(
  *   'posts' => array(
  *     'title' => array(
  *       'type' => 'string',
  *       'length' => 100,
  *     ),
  *   ),
  *   // Can add multiple tables at once
  *   'post_lang' => array(
  *     'name' => array(
  *       'type' => 'string',
  *     ),
  *     'locale' => array(
  *       'type' => 'string',
  *       'length' => 5,
  *     ),
  *   ),
  * );
  * 
  * DBManager::new_table($input);
  * 
  * </code>
  *
  * @param array $input
  * @return array
  */
 public static function new_table($input)
 {
     foreach ($input as $table => $columns) {
         Schema::create($table, function ($table) use($columns) {
             if (!isset($columns['id'])) {
                 $table->increments('id');
             }
             foreach ($columns as $name => $data) {
                 if (isset($data['length']) and !is_null($data['length'])) {
                     ${$name} = $table->{$data['type']}($name, $data['length']);
                 } else {
                     ${$name} = $table->{$data['type']}($name);
                 }
                 if (isset($data['nullable']) and $data['nullable'] == true) {
                     ${$name}->nullable();
                 }
             }
             $table->timestamps();
         });
     }
     return DBManager::tables();
 }