当前位置: 首页>>代码示例>>PHP>>正文


PHP DibiConnection::alias方法代码示例

本文整理汇总了PHP中DibiConnection::alias方法的典型用法代码示例。如果您正苦于以下问题:PHP DibiConnection::alias方法的具体用法?PHP DibiConnection::alias怎么用?PHP DibiConnection::alias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DibiConnection的用法示例。


在下文中一共展示了DibiConnection::alias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'file');
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     if (isset($config['resource']) && $config['resource'] instanceof SQLite3) {
         $this->connection = $config['resource'];
     } else {
         try {
             $this->connection = new SQLite3($config['database']);
         } catch (Exception $e) {
             throw new DibiDriverException($e->getMessage(), $e->getCode());
         }
     }
     $this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
     $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
     if (strcasecmp($this->dbcharset, $this->charset) === 0) {
         $this->dbcharset = $this->charset = NULL;
     }
     // enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
     $version = SQLite3::version();
     if ($version['versionNumber'] >= '3006019') {
         $this->query("PRAGMA foreign_keys = ON");
     }
 }
开发者ID:romcok,项目名称:treeview,代码行数:30,代码来源:sqlite3.php

示例2: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'file');
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     $errorMsg = '';
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } elseif (empty($config['persistent'])) {
         $this->connection = @sqlite_open($config['database'], 0666, $errorMsg);
         // intentionally @
     } else {
         $this->connection = @sqlite_popen($config['database'], 0666, $errorMsg);
         // intentionally @
     }
     if (!$this->connection) {
         throw new DibiDriverException($errorMsg);
     }
     $this->buffered = empty($config['unbuffered']);
     $this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
     $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
     if (strcasecmp($this->dbcharset, $this->charset) === 0) {
         $this->dbcharset = $this->charset = NULL;
     }
 }
开发者ID:Scrik,项目名称:Need-For-Speed-World-Statistics-Website,代码行数:30,代码来源:sqlite.php

示例3: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'options');
     DibiConnection::alias($config, 'database');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('mysqli.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('mysqli.default_pw');
         }
         if (!isset($config['socket'])) {
             $config['socket'] = ini_get('mysqli.default_socket');
         }
         if (!isset($config['port'])) {
             $config['port'] = NULL;
         }
         if (!isset($config['host'])) {
             $host = ini_get('mysqli.default_host');
             if ($host) {
                 $config['host'] = $host;
                 $config['port'] = ini_get('mysqli.default_port');
             } else {
                 $config['host'] = NULL;
                 $config['port'] = NULL;
             }
         }
         $this->connection = mysqli_init();
         @mysqli_real_connect($this->connection, $config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket'], $config['options']);
         // intentionally @
         if ($errno = mysqli_connect_errno()) {
             throw new DibiDriverException(mysqli_connect_error(), $errno);
         }
     }
     if (isset($config['charset'])) {
         $ok = FALSE;
         if (version_compare(PHP_VERSION, '5.1.5', '>=')) {
             // affects the character set used by mysql_real_escape_string() (was added in MySQL 5.0.7 and PHP 5.0.5, fixed in PHP 5.1.5)
             $ok = @mysqli_set_charset($this->connection, $config['charset']);
             // intentionally @
         }
         if (!$ok) {
             $ok = @mysqli_query($this->connection, "SET NAMES '{$config['charset']}'");
             // intentionally @
             if (!$ok) {
                 throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection));
             }
         }
     }
     if (isset($config['sqlmode'])) {
         if (!@mysqli_query($this->connection, "SET sql_mode='{$config['sqlmode']}'")) {
             // intentionally @
             throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection));
         }
     }
     $this->buffered = empty($config['unbuffered']);
 }
开发者ID:vlki,项目名称:dibi,代码行数:65,代码来源:mysqli.php

示例4: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('odbc.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('odbc.default_pw');
         }
         if (!isset($config['dsn'])) {
             $config['dsn'] = ini_get('odbc.default_db');
         }
         if (empty($config['persistent'])) {
             $this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         } else {
             $this->connection = @odbc_pconnect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         }
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException(odbc_errormsg() . ' ' . odbc_error());
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:34,代码来源:odbc.php

示例5: connect

 /**
  * Connects to a database.
  *
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     DibiConnection::alias($config, 'database', 'db');
     DibiConnection::alias($config, 'charset');
     $this->connection = @oci_new_connect($config['username'], $config['password'], $config['database'], $config['charset']);
     // intentionally @
     if (!$this->connection) {
         $err = oci_error();
         throw new DibiDriverException($err['message'], $err['code']);
     }
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:19,代码来源:oracle.php

示例6: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'options|UID', 'username');
     DibiConnection::alias($config, 'options|PWD', 'password');
     DibiConnection::alias($config, 'options|Database', 'database');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         $this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
     }
     if (!is_resource($this->connection)) {
         $info = sqlsrv_errors();
         throw new DibiDriverException($info[0]['message'], $info[0]['code']);
     }
 }
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:20,代码来源:mssql2005.php

示例7: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'charset');
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         $this->connection = @oci_new_connect($config['username'], $config['password'], $config['database'], $config['charset']);
         // intentionally @
     }
     if (!$this->connection) {
         $err = oci_error();
         throw new DibiDriverException($err['message'], $err['code']);
     }
 }
开发者ID:vrana,项目名称:dibi,代码行数:21,代码来源:oracle.php

示例8: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'host', 'hostname');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } elseif (isset($config['options'])) {
         $this->connection = sqlsrv_connect($config['host'], $config['options']);
     } else {
         $this->connection = sqlsrv_connect($config['host']);
     }
     if (!is_resource($this->connection)) {
         $info = sqlsrv_errors();
         throw new DibiDriverException($info[0]['message'], $info[0]['code']);
     }
     $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:21,代码来源:mssql2005.php

示例9: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         if (!isset($config['charset'])) {
             $config['charset'] = 'utf8';
         }
         if (isset($config['string'])) {
             $string = $config['string'];
         } else {
             $string = '';
             DibiConnection::alias($config, 'user', 'username');
             DibiConnection::alias($config, 'dbname', 'database');
             foreach (array('host', 'hostaddr', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service') as $key) {
                 if (isset($config[$key])) {
                     $string .= $key . '=' . $config[$key] . ' ';
                 }
             }
         }
         DibiDriverException::tryError();
         if (empty($config['persistent'])) {
             $this->connection = pg_connect($string, PGSQL_CONNECT_FORCE_NEW);
         } else {
             $this->connection = pg_pconnect($string, PGSQL_CONNECT_FORCE_NEW);
         }
         if (DibiDriverException::catchError($msg)) {
             throw new DibiDriverException($msg, 0);
         }
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException('Connecting error.');
     }
     if (isset($config['charset'])) {
         DibiDriverException::tryError();
         pg_set_client_encoding($this->connection, $config['charset']);
         if (DibiDriverException::catchError($msg)) {
             throw new DibiDriverException($msg, 0);
         }
     }
     if (isset($config['schema'])) {
         $this->query('SET search_path TO "' . $config['schema'] . '"');
     }
     $this->escMethod = version_compare(PHP_VERSION, '5.2.0', '>=');
 }
开发者ID:kravco,项目名称:dibi,代码行数:50,代码来源:postgre.php

示例10: connect

 /**
  * Connects to a database.
  *
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'file');
     $this->fmtDate = isset($config['format:date']) ? $config['format:date'] : 'U';
     $this->fmtDateTime = isset($config['format:datetime']) ? $config['format:datetime'] : 'U';
     $errorMsg = '';
     if (empty($config['persistent'])) {
         $this->connection = @sqlite_open($config['database'], 0666, $errorMsg);
         // intentionally @
     } else {
         $this->connection = @sqlite_popen($config['database'], 0666, $errorMsg);
         // intentionally @
     }
     if (!$this->connection) {
         throw new DibiDriverException($errorMsg);
     }
     $this->buffered = empty($config['unbuffered']);
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:24,代码来源:sqlite.php

示例11: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'dsn');
     DibiConnection::alias($config, 'resource', 'pdo');
     DibiConnection::alias($config, 'options');
     if ($config['resource'] instanceof PDO) {
         $this->connection = $config['resource'];
     } else {
         try {
             $this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
         } catch (PDOException $e) {
             throw new DibiDriverException($e->getMessage(), $e->getCode());
         }
     }
     if (!$this->connection) {
         throw new DibiDriverException('Connecting error.');
     }
 }
开发者ID:vrana,项目名称:dibi,代码行数:23,代码来源:pdo.php

示例12: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     $foo =& $config['dsn'];
     $foo =& $config['options'];
     DibiConnection::alias($config, 'resource', 'pdo');
     if ($config['resource'] instanceof PDO) {
         $this->connection = $config['resource'];
     } else {
         try {
             $this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
         } catch (PDOException $e) {
             if ($e->getMessage() === 'could not find driver') {
                 throw new DibiNotSupportedException("PHP extension for PDO is not loaded.");
             }
             throw new DibiDriverException($e->getMessage(), $e->getCode());
         }
     }
     $this->driverName = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME);
 }
开发者ID:rbrdevs,项目名称:pydio-core,代码行数:24,代码来源:DibiPdoDriver.php

示例13: connect

 /**
  * Connects to a database.
  *
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     DibiConnection::alias($config, 'host', 'hostname');
     if (empty($config['persistent'])) {
         $this->connection = @mssql_connect($config['host'], $config['username'], $config['password'], TRUE);
         // intentionally @
     } else {
         $this->connection = @mssql_pconnect($config['host'], $config['username'], $config['password']);
         // intentionally @
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException("Can't connect to DB.");
     }
     if (isset($config['database']) && !@mssql_select_db($config['database'], $this->connection)) {
         // intentionally @
         throw new DibiDriverException("Can't select DB '{$config['database']}'.");
     }
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:26,代码来源:mssql.php

示例14: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'db');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('ibase.default_password');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('ibase.default_user');
         }
         if (!isset($config['database'])) {
             $config['database'] = ini_get('ibase.default_db');
         }
         if (!isset($config['charset'])) {
             $config['charset'] = ini_get('ibase.default_charset');
         }
         if (!isset($config['buffers'])) {
             $config['buffers'] = 0;
         }
         DibiDriverException::tryError();
         if (empty($config['persistent'])) {
             $this->connection = ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']);
             // intentionally @
         } else {
             $this->connection = ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']);
             // intentionally @
         }
         if (DibiDriverException::catchError($msg)) {
             throw new DibiDriverException($msg, ibase_errcode());
         }
         if (!is_resource($this->connection)) {
             throw new DibiDriverException(ibase_errmsg(), ibase_errcode());
         }
     }
 }
开发者ID:vrana,项目名称:dibi,代码行数:43,代码来源:firebird.php

示例15: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         DibiConnection::alias($config, 'flags', 'options');
         if (!isset($config['charset'])) {
             $config['charset'] = 'utf8';
         }
         if (!isset($config['username'])) {
             $config['username'] = ini_get('mysql.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('mysql.default_password');
         }
         if (!isset($config['host'])) {
             $host = ini_get('mysql.default_host');
             if ($host) {
                 $config['host'] = $host;
                 $config['port'] = ini_get('mysql.default_port');
             } else {
                 if (!isset($config['socket'])) {
                     $config['socket'] = ini_get('mysql.default_socket');
                 }
                 $config['host'] = NULL;
             }
         }
         if (empty($config['socket'])) {
             $host = $config['host'] . (empty($config['port']) ? '' : ':' . $config['port']);
         } else {
             $host = ':' . $config['socket'];
         }
         if (empty($config['persistent'])) {
             $this->connection = @mysql_connect($host, $config['username'], $config['password'], TRUE, $config['flags']);
             // intentionally @
         } else {
             $this->connection = @mysql_pconnect($host, $config['username'], $config['password'], $config['flags']);
             // intentionally @
         }
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException(mysql_error(), mysql_errno());
     }
     if (isset($config['charset'])) {
         $ok = FALSE;
         if (function_exists('mysql_set_charset')) {
             // affects the character set used by mysql_real_escape_string() (was added in MySQL 5.0.7 and PHP 5.2.3)
             $ok = @mysql_set_charset($config['charset'], $this->connection);
             // intentionally @
         }
         if (!$ok) {
             $this->query("SET NAMES '{$config['charset']}'");
         }
     }
     if (isset($config['database'])) {
         if (!@mysql_select_db($config['database'], $this->connection)) {
             // intentionally @
             throw new DibiDriverException(mysql_error($this->connection), mysql_errno($this->connection));
         }
     }
     if (isset($config['sqlmode'])) {
         $this->query("SET sql_mode='{$config['sqlmode']}'");
     }
     $this->query("SET time_zone='" . date('P') . "'");
     $this->buffered = empty($config['unbuffered']);
 }
开发者ID:kravco,项目名称:dibi,代码行数:72,代码来源:mysql.php


注:本文中的DibiConnection::alias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。