/**
  * Returns the connection.
  *
  * @access  protected
  * @return  \mako\database\Connection
  */
 protected function getConnection()
 {
     if (empty($this->connectionName)) {
         return $this->connectionManager->connection();
     }
     return $this->connectionManager->connection($this->connectionName);
 }
 /**
  * Checks that the value doesn't exist in the database table.
  *
  * @access  public
  * @param   string   $input   Input
  * @param   string   $table   Table name
  * @param   string   $column  Column name
  * @param   string   $value   Allowed value
  * @return  boolean
  */
 public function validate($input, $table, $column, $value = null)
 {
     $query = $this->connectionManager->builder()->table($table)->where($column, '=', $input);
     if (!empty($value)) {
         $query->where($column, '!=', $value);
     }
     return $query->count() == 0;
 }
 /**
  * Validator.
  *
  * @access  public
  * @param   string   $input        Input
  * @param   string   $table        Table name
  * @param   string   $column       Column name
  * @param   array    $conditional  (optional) Query conditionals
  * @return  boolean
  */
 public function validate($input, $table, $column, $conditionals = [])
 {
     $query = $this->connectionManager->builder()->table($table)->where($column, '=', $input);
     // Additional clauses
     foreach ($conditionals as $conditional) {
         // Explode clauses
         list($field, $conditional, $value) = explode(' ', $conditional);
         // Perform query
         $query->where($field, $conditional, $value);
     }
     return $query->count() != 0;
 }
Exemple #4
0
 /**
  * Returns the connection of the model.
  *
  * @access  public
  * @return  \mako\database\connections\Connection
  */
 public function getConnection()
 {
     if (empty(static::$connectionManager)) {
         static::$connectionManager = Application::instance()->getContainer()->get('database');
     }
     return static::$connectionManager->connection($this->connectionName);
 }
 /**
  * Checks that the value exists in the database table.
  *
  * @access  public
  * @param   string   $input   Input
  * @param   string   $table   Table name
  * @param   string   $column  Column name
  * @return  boolean
  */
 public function validate($input, $table, $column)
 {
     return $this->connectionManager->builder()->table($table)->where($column, '=', $input)->count() != 0;
 }
Exemple #6
0
 /**
  * Returns the database connection.
  *
  * @access  protected
  * @return  \mako\database\Connection
  */
 protected function connection()
 {
     return $this->database->connection();
 }