Example #1
0
 public function putDumpDB(DbSimple_Database $db, array $query)
 {
     // Выполняем запросы из дампа БД
     foreach ($query as $v) {
         if (!empty($v)) {
             $db->query($v);
         }
     }
 }
 /**
  * constructor(string $dsn)
  * Connect to PostgresSQL.
  */
 function DbSimple_Postgresql($dsn)
 {
     $dsn = DbSimple_Database::parseDSN($dsn);
     if (!is_callable('pg_connect')) {
         return $this->_setLastError("-1", "PostgreSQL extension is not loaded", "pg_connect");
     }
     // Prepare+execute works only in PHP 5.1+.
     $this->DbSimple_Postgresql_USE_NATIVE_PHOLDERS = function_exists('pg_prepare');
     $this->dsn = $dsn;
     $this->_connect($dsn);
 }
Example #3
0
 /**
  * constructor(string $dsn)
  * Connect to PostgresSQL.
  */
 function DbSimple_Postgresql($dsn)
 {
     $p = DbSimple_Database::parseDSN($dsn);
     if (!is_callable('pg_connect')) {
         return $this->_setLastError("-1", "PostgreSQL extension is not loaded", "pg_connect");
     }
     // Prepare+execute works only in PHP 5.1+.
     $this->DbSimple_Postgresql_USE_NATIVE_PHOLDERS = function_exists('pg_prepare');
     $ok = $this->link = @pg_connect($t = (!empty($p['host']) ? 'host=' . $p['host'] . ' ' : '') . (!empty($p['port']) ? 'port=' . $p['port'] . ' ' : '') . 'dbname=' . preg_replace('{^/}s', '', $p['path']) . ' ' . (!empty($p['user']) ? 'user='******'user'] . ' ' : '') . (!empty($p['pass']) ? 'password='******'pass'] . ' ' : ''));
     $this->_resetLastError();
     if (!$ok) {
         return $this->_setDbError('pg_connect()');
     }
 }
Example #4
0
 /**
  * constructor(string $dsn)
  * Connect to Interbase/Firebird.
  */
 function __construct($dsn)
 {
     $p = DbSimple_Database::parseDSN($dsn);
     if (!is_callable('ibase_connect')) {
         return $this->_setLastError("-1", "Interbase/Firebird extension is not loaded", "ibase_connect");
     }
     $ok = $this->link = ibase_connect($p['host'] . (empty($p['port']) ? "" : ":" . $p['port']) . ':' . preg_replace('{^/}s', '', $p['path']), $p['user'], $p['pass'], isset($p['CHARSET']) ? $p['CHARSET'] : 'win1251', isset($p['BUFFERS']) ? $p['BUFFERS'] : 0, isset($p['DIALECT']) ? $p['DIALECT'] : 3, isset($p['ROLE']) ? $p['ROLE'] : '');
     if (isset($p['TRANSACTION'])) {
         $this->DbSimple_Ibase_BEST_TRANSACTION = eval($p['TRANSACTION'] . ";");
     }
     $this->_resetLastError();
     if (!$ok) {
         return $this->_setDbError('ibase_connect()');
     }
 }
Example #5
0
 /**
  * constructor(string $dsn)
  * Connect to PostgresSQL.
  */
 function DbSimple_Postgresql($dsn)
 {
     $p = DbSimple_Database::parseDSN($dsn);
     if (!is_callable('pg_connect')) {
         return $this->_setLastError("-1", "PostgreSQL extension is not loaded", "pg_connect");
     }
     // Prepare+execute works only in PHP 5.1+.
     $this->DbSimple_Postgresql_USE_NATIVE_PHOLDERS = function_exists('pg_prepare');
     $dsnWithoutPass = (!empty($p['host']) ? 'host=' . $p['host'] . ' ' : '') . (!empty($p['port']) ? 'port=' . $p['port'] . ' ' : '') . 'dbname=' . preg_replace('{^/}s', '', $p['path']) . ' ' . (!empty($p['user']) ? 'user='******'user'] : '');
     $ok = $this->link = @pg_connect($dsnWithoutPass . " " . (!empty($p['pass']) ? 'password='******'pass'] . ' ' : ''), PGSQL_CONNECT_FORCE_NEW);
     // We use PGSQL_CONNECT_FORCE_NEW, because in PHP 5.3 & PHPUnit
     // $this->prepareCache may be cleaned, but $this->link is still
     // not closed. So the next creation of DbSimple_Postgresql()
     // would use exactly the same connection as the previous, but with
     // empty $this->prepareCache, and it will generate "prepared statement
     // xxx already exists" error each time we execute the same statement
     // as in the previous calls.
     $this->_resetLastError();
     if (!$ok) {
         return $this->_setDbError('pg_connect("' . $dsnWithoutPass . '") error');
     }
 }
Example #6
0
 public function selectCol()
 {
     $rows = $this->query();
     if (!is_array($rows)) {
         return $rows;
     }
     DbSimple_Database::firstColumnArray($rows);
     return $rows;
 }
Example #7
0
 public static function category_id(DbSimple_Database $db)
 {
     $res = $db->select("SELECT  id , parent_id ,  category  FROM categorys WHERE parent_id IS NOT NULL");
     $data = array();
     foreach ($res as $v) {
         $data[$v['parent_id']][$v['id']] = $v['category'];
     }
     return $data;
 }