예제 #1
0
파일: session.php 프로젝트: mymizan/phreeze
 /**
  * Create a new session driver instance.
  *
  * @param  string  $driver
  * @return Session\Drivers\Driver
  */
 public static function factory($driver)
 {
     if (isset(static::$registrar[$driver])) {
         $resolver = static::$registrar[$driver];
         return $resolver();
     }
     switch ($driver) {
         case 'apc':
             return new Session\Drivers\APC(Cache::driver('apc'));
         case 'cookie':
             return new Session\Drivers\Cookie();
         case 'database':
             return new Session\Drivers\Database(Database::connection());
         case 'file':
             return new Session\Drivers\File(path('storage') . 'sessions' . DS);
         case 'memcached':
             return new Session\Drivers\Memcached(Cache::driver('memcached'));
         case 'memory':
             return new Session\Drivers\Memory();
         case 'redis':
             return new Session\Drivers\Redis(Cache::driver('redis'));
         default:
             throw new \Exception("Session driver [{$driver}] is not supported.");
     }
 }
예제 #2
0
 /**
  * Add a performed SQL query to the Profiler.
  *
  * @param 	string 	$sql
  * @param 	array 	$bindings
  * @param 	float 	$time
  * @return 	void
  */
 public static function query($sql, $bindings, $time)
 {
     foreach ($bindings as $binding) {
         $binding = Database::connection()->pdo->quote($binding);
         $sql = preg_replace('/\\?/', $binding, $sql, 1);
     }
     static::$data['queries'][] = array($sql, $time);
 }
예제 #3
0
 /**
  * Execute the given schema operation against the database.
  *
  * @param  Schema\Table  $table
  * @return void
  */
 public static function execute($table)
 {
     // The implications method is responsible for finding any fluently
     // defined indexes on the schema table and adding the explicit
     // commands that are needed to tbe schema instance.
     static::implications($table);
     foreach ($table->commands as $command) {
         $connection = DB::connection($table->connection);
         $grammar = static::grammar($connection);
         // Each grammar has a function that corresponds to the command type and
         // is for building that command's SQL. This lets the SQL syntax builds
         // stay granular across various database systems.
         if (method_exists($grammar, $method = $command->type)) {
             $statements = $grammar->{$method}($table, $command);
             // Once we have the statements, we will cast them to an array even
             // though not all of the commands return an array just in case it
             // needs multiple queries to complete.
             foreach ((array) $statements as $statement) {
                 $connection->query($statement);
             }
         }
     }
 }
예제 #4
0
 /**
  * Get the database connection for the Validator.
  *
  * @return Database\Connection
  */
 protected function db()
 {
     if (!is_null($this->db)) {
         return $this->db;
     }
     return $this->db = Database::connection();
 }
예제 #5
0
파일: Model.php 프로젝트: noikiy/inovi
 /**
  * Delete a model from the database.
  *
  * @param  int  $id
  * @return int
  */
 public function delete($id = null)
 {
     // If the delete method is being called on an existing model, we only want to delete
     // that model. If it is being called from an Eloquent query model, it is probably
     // the developer's intention to delete more than one model, so we will pass the
     // delete statement to the query instance.
     if (!$this->exists) {
         return $this->query->delete();
     }
     $table = static::table(get_class($this));
     return DB::connection(static::$connection)->table($table)->delete($this->{static::$primary_key});
 }
예제 #6
0
 /**
  * Get the database connection for the model.
  *
  * @return Connection
  */
 public function connection()
 {
     return Database::connection($this->model->connection());
 }
예제 #7
0
 /**
  * Get a query builder for the database table.
  *
  * @return Laravel\Database\Query
  */
 protected function table()
 {
     $connection = DB::connection(Config::get('cache.database.connection'));
     return $connection->table(Config::get('cache.database.table'));
 }
예제 #8
0
 /**
  * Get a database query instance for the migration table.
  *
  * @return Laravel\Database\Query
  */
 protected function table()
 {
     return DB::connection(Request::server('cli.db'))->table('laravel_migrations');
 }
예제 #9
0
 /**
  * __construct
  *
  * @return void
  */
 public function __construct()
 {
     $this->pdo = DB::connection()->pdo;
     $this->config = Config::get('database.connections.' . Config::get('database.default'));
 }