Example #1
0
 /**
  * Execute the query as a DELETE statement.
  *
  * Optionally, an ID may be passed to the method do delete a specific row.
  *
  * @param  int   $id
  * @return int
  */
 public function delete($id = null)
 {
     if (!is_null($id)) {
         $this->where('id', '=', $id);
     }
     return $this->connection->query($this->grammar->delete($this), $this->bindings);
 }
Example #2
0
 /**
  * Validate the uniqueness of an attribute value on a given database table.
  *
  * If a database column is not specified, the attribute name will be used.
  *
  * @param  string  $attribute
  * @param  mixed   $value
  * @param  array   $parameters
  * @return bool
  */
 protected function validate_unique($attribute, $value, $parameters)
 {
     if (!isset($parameters[1])) {
         $parameters[1] = $attribute;
     }
     if (is_null($this->db)) {
         $this->db = DB::connection();
     }
     return $this->db->table($parameters[0])->where($parameters[1], '=', $value)->count() == 0;
 }
Example #3
0
 /**
  * Execute the query as a DELETE statement.
  *
  * Optionally, an ID may be passed to the method do delete a specific row.
  *
  * @param  int   $id
  * @return int
  */
 public function delete($id = null)
 {
     // If an ID is given to the method, we'll set the where clause to
     // match on the value of the ID. This allows the developer to
     // quickly delete a row by its primary key value.
     if (!is_null($id)) {
         $this->where('id', '=', $id);
     }
     $sql = $this->grammar->delete($this);
     return $this->connection->query($sql, $this->bindings);
 }
 /**
  * Get a session database query.
  *
  * @return Query
  */
 private function table()
 {
     return $this->connection->table(Config::get('session.table'));
 }
Example #5
0
 /**
  * Create the appropriate schema grammar for the driver.
  *
  * @param  Connection  $connection
  * @return Grammar
  */
 public static function grammar(Connection $connection)
 {
     $driver = $connection->driver();
     switch ($driver) {
         case 'mysql':
             return new Schema\Grammars\MySQL($connection);
         case 'pgsql':
             return new Schema\Grammars\Postgres($connection);
         case 'sqlsrv':
             return new Schema\Grammars\SQLServer($connection);
         case 'sqlite':
             return new Schema\Grammars\SQLite($connection);
     }
     throw new \Exception("Schema operations not supported for [{$driver}].");
 }
Example #6
0
 /**
  * Create the appropriate schema grammar for the driver.
  *
  * @param  Connection  $connection
  * @return Grammar
  */
 public static function grammar(Connection $connection)
 {
     $driver = $connection->driver();
     if (isset(\Laravel\Database::$registrar[$driver])) {
         return \Laravel\Database::$registrar[$driver]['schema']();
     }
     switch ($driver) {
         case 'mysql':
             return new Schema\Grammars\MySQL($connection);
         case 'pgsql':
             return new Schema\Grammars\Postgres($connection);
         case 'sqlsrv':
             return new Schema\Grammars\SQLServer($connection);
         case 'sqlite':
             return new Schema\Grammars\SQLite($connection);
     }
     throw new \Exception("Schema operations not supported for [{$driver}].");
 }
Example #7
0
 /**
  * Get a session database query.
  *
  * @return Query
  */
 private function table()
 {
     return $this->connection->table(Config::$items['session']['table']);
 }