Пример #1
0
 /**
  * Parse the query string and convert any strings of the form `\([a-zA-Z0-9_]*?)\]
  * table prefix . $1
  */
 public function query($sql)
 {
     if (!empty($sql)) {
         $sql = $this->add_table_prefixes($sql);
     }
     return parent::query($sql);
 }
Пример #2
0
 /**
  * Multiway profile of Database configures
  */
 public function __construct()
 {
     $config = array();
     // custom environment key to databse config.
     $environment = Kohana::config('database.environment');
     // available: development, test, pro
     if (!is_array($environment) && !empty($environment)) {
         $config = Kohana::config('database.' . $environment);
     }
     parent::__construct($config);
 }
Пример #3
0
 /**
  * Catch query exceptions
  *
  * @return bool
  */
 public function run_query($sql)
 {
     try {
         $test = $this->db->query($this->group, $sql, false);
     } catch (Kohana_Database_Exception $e) {
         // Kohana::log('error', 'Migration Failed: ' . $e);
         echo $e->getMessage();
         exit;
         return FALSE;
     }
     return TRUE;
 }
Пример #4
0
 /**
  * Combine a SQL statement with the bind values. Used for safe queries.
  * 
  * If $binds is an indexed array use KO3 style named binding
  * otherwise fallback to Kohana core
  *
  * @param   string  query to bind to the values
  * @param   array   array of values to bind to the query
  * @return  string
  */
 public function compile_binds($sql, $binds)
 {
     $isIndexed = array_values($binds) === $binds;
     // if we have an associative array, use named bindings ala KO3
     if (!$isIndexed) {
         // Escape all of the values
         $values = array_map(array($this->driver, 'escape'), $binds);
         // Replace the values in the SQL
         $sql = strtr($sql, $values);
         return $sql;
     } else {
         return parent::compile_binds($sql, $binds);
     }
 }
Пример #5
0
 /**
  * @ return mysqli
  */
 public static function connectDB()
 {
     //connect no banco
     self::$_dbLink = mysqli_connect('localhost', 'root', '', 'acoisa');
     return self::$_dbLink;
 }
 /**
  * Catch query exceptions
  *
  * @return bool
  */
 public function run_query($sql)
 {
     $test = $this->db->query($this->group, $sql, false);
 }
Пример #7
0
 public function __construct($config = array())
 {
     parent::__construct($config);
 }
Пример #8
0
 /**
  * End Transaction
  * 
  */
 public function commit()
 {
     $this->db->commit();
 }