本文整理汇总了PHP中MDB2::areEquals方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2::areEquals方法的具体用法?PHP MDB2::areEquals怎么用?PHP MDB2::areEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2
的用法示例。
在下文中一共展示了MDB2::areEquals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
*/
function connect()
{
if (is_resource($this->connection)) {
if (MDB2::areEquals($this->connected_dsn, $this->dsn)) {
return MDB2_OK;
}
$this->disconnect(false);
}
$connection = $this->_doConnect($this->dsn['username'], $this->dsn['password'], $this->database_name, $this->options['persistent']);
if (MDB2::isError($connection)) {
return $connection;
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $this->database_name;
$this->opened_persistent = $this->options['persistent'];
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
return MDB2_OK;
}
示例2: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
**/
function connect()
{
if ($this->connection instanceof SQLite3) {
return MDB2_OK;
}
$datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
$database_file = $this->_getDatabaseFile($this->database_name);
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
if (MDB2::areEquals($this->connected_dsn, $this->dsn) && $this->connected_database_name == $database_file && $this->opened_persistent == $this->options['persistent']) {
return MDB2_OK;
}
$this->disconnect(false);
}
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'extension ' . $this->phptype . ' is not compiled into PHP', __FUNCTION__);
}
if (empty($this->database_name)) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
if ($database_file !== ':memory:') {
if (!strpos($database_file, '.db')) {
$database_file = "{$datadir}/{$database_file}.db";
}
if (!file_exists($database_file)) {
if (!touch($database_file)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not create database file', __FUNCTION__);
}
if (!isset($this->dsn['mode']) || !is_numeric($this->dsn['mode'])) {
$mode = 0644;
} else {
$mode = octdec($this->dsn['mode']);
}
if (!chmod($database_file, $mode)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not be chmodded database file', __FUNCTION__);
}
if (!file_exists($database_file)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not be found database file', __FUNCTION__);
}
}
if (!is_file($database_file)) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null, 'Database is a directory name', __FUNCTION__);
}
if (!is_readable($database_file)) {
return $this->raiseError(MDB2_ERROR_ACCESS_VIOLATION, null, null, 'Could not read database file', __FUNCTION__);
}
}
$php_errormsg = '';
$this->connection = new SQLite3($database_file);
if (is_callable(array($this->connection, 'busyTimeout'))) {
//busy timout is only available in php>=5.3
$this->connection->busyTimeout(100);
}
$this->_lasterror = $this->connection->lastErrorMsg();
if (!$this->connection) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
if ($this->fix_assoc_fields_names || $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) {
$this->connection->exec("PRAGMA short_column_names = 1");
$this->fix_assoc_fields_names = true;
}
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $database_file;
$this->opened_persistent = $this->getoption('persistent');
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
return MDB2_OK;
}
示例3: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
**/
function connect()
{
$database_file = $this->_getDatabaseFile($this->database_name);
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
if (MDB2::areEquals($this->connected_dsn, $this->dsn) && $this->connected_database_name == $database_file && $this->opened_persistent == $this->options['persistent']) {
return MDB2_OK;
}
$this->disconnect(false);
}
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'extension ' . $this->phptype . ' is not compiled into PHP', __FUNCTION__);
}
if (empty($this->database_name)) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
if ($database_file !== ':memory:') {
if (!file_exists($database_file)) {
if (!touch($database_file)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not create database file', __FUNCTION__);
}
if (!isset($this->dsn['mode']) || !is_numeric($this->dsn['mode'])) {
$mode = 0644;
} else {
$mode = octdec($this->dsn['mode']);
}
if (!chmod($database_file, $mode)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not be chmodded database file', __FUNCTION__);
}
if (!file_exists($database_file)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not be found database file', __FUNCTION__);
}
}
if (!is_file($database_file)) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null, 'Database is a directory name', __FUNCTION__);
}
if (!is_readable($database_file)) {
return $this->raiseError(MDB2_ERROR_ACCESS_VIOLATION, null, null, 'Could not read database file', __FUNCTION__);
}
}
$connect_function = $this->options['persistent'] ? 'sqlite_popen' : 'sqlite_open';
$php_errormsg = '';
if (version_compare('5.1.0', PHP_VERSION, '>')) {
@ini_set('track_errors', true);
$connection = @$connect_function($database_file);
@ini_restore('track_errors');
} else {
$connection = @$connect_function($database_file, 0666, $php_errormsg);
}
$this->_lasterror = $php_errormsg;
if (!$connection) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
if ($this->fix_assoc_fields_names || $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) {
@sqlite_query("PRAGMA short_column_names = 1", $connection);
$this->fix_assoc_fields_names = true;
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $database_file;
$this->opened_persistent = $this->getoption('persistent');
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
return MDB2_OK;
}
示例4: connect
/**
* Connect to the database
*
* @return MDB2_OK on success, MDB2 Error Object on failure
* @access public
*/
function connect()
{
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
if (MDB2::areEquals($this->connected_dsn, $this->dsn) && $this->opened_persistent == $this->options['persistent']) {
return MDB2_OK;
}
$this->disconnect(false);
}
$connection = $this->_doConnect($this->dsn['username'], $this->dsn['password'], $this->options['persistent']);
if (MDB2::isError($connection)) {
return $connection;
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = '';
$this->opened_persistent = $this->options['persistent'];
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
if ($this->database_name) {
if ($this->database_name != $this->connected_database_name) {
if (!@mysql_select_db($this->database_name, $connection)) {
$err = $this->raiseError(null, null, null, 'Could not select the database: ' . $this->database_name, __FUNCTION__);
return $err;
}
$this->connected_database_name = $this->database_name;
}
}
$this->_getServerCapabilities();
return MDB2_OK;
}
示例5: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
*/
function connect()
{
if (is_object($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0) {
if (MDB2::areEquals($this->connected_dsn, $this->dsn)) {
return MDB2_OK;
}
$this->connection = 0;
}
$connection = $this->_doConnect($this->dsn['username'], $this->dsn['password']);
if (PEAR::isError($connection)) {
return $connection;
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $this->database_name;
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
$this->_getServerCapabilities();
return MDB2_OK;
}
示例6: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
*/
function connect()
{
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
if (MDB2::areEquals($this->connected_dsn, $this->dsn) && $this->opened_persistent == $this->options['persistent'] && $this->connected_database_name == $this->database_name) {
return MDB2_OK;
}
$this->disconnect(false);
}
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'extension ' . $this->phptype . ' is not compiled into PHP', __FUNCTION__);
}
$params = array();
if ($this->dsn['protocol'] && $this->dsn['protocol'] == 'unix') {
$params[0] = ':' . $this->dsn['socket'];
} else {
$params[0] = $this->dsn['hostspec'] ? $this->dsn['hostspec'] : 'localhost';
if ($this->dsn['port']) {
$params[0] .= ':' . $this->dsn['port'];
}
}
$params[] = $this->dsn['username'] ? $this->dsn['username'] : null;
$params[] = $this->dsn['password'] ? $this->dsn['password'] : null;
if (!$this->options['persistent']) {
if (isset($this->dsn['new_link']) && ($this->dsn['new_link'] == 'true' || $this->dsn['new_link'] === true)) {
$params[] = true;
} else {
$params[] = false;
}
}
if (version_compare(phpversion(), '4.3.0', '>=')) {
$params[] = isset($this->dsn['client_flags']) ? $this->dsn['client_flags'] : null;
}
$connect_function = $this->options['persistent'] ? 'mysql_pconnect' : 'mysql_connect';
$connection = @call_user_func_array($connect_function, $params);
if (!$connection) {
if (($err = @mysql_error()) != '') {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, $err, __FUNCTION__);
} else {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
}
if (!empty($this->dsn['charset'])) {
$result = $this->setCharset($this->dsn['charset'], $connection);
if (PEAR::isError($result)) {
return $result;
}
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = '';
$this->opened_persistent = $this->options['persistent'];
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
if ($this->database_name) {
if ($this->database_name != $this->connected_database_name) {
if (!@mysql_select_db($this->database_name, $connection)) {
$err = $this->raiseError(null, null, null, 'Could not select the database: ' . $this->database_name, __FUNCTION__);
return $err;
}
$this->connected_database_name = $this->database_name;
}
}
$this->supported['transactions'] = $this->options['use_transactions'];
if ($this->options['default_table_type']) {
switch (strtoupper($this->options['default_table_type'])) {
case 'BLACKHOLE':
case 'MEMORY':
case 'ARCHIVE':
case 'CSV':
case 'HEAP':
case 'ISAM':
case 'MERGE':
case 'MRG_ISAM':
case 'ISAM':
case 'MRG_MYISAM':
case 'MYISAM':
$this->supported['transactions'] = false;
$this->warnings[] = $this->options['default_table_type'] . ' is not a supported default table type';
break;
}
}
$this->_getServerCapabilities();
return MDB2_OK;
}
示例7: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
* @access public
*/
function connect()
{
$database_file = $this->_getDatabaseFile($this->database_name);
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
if (MDB2::areEquals($this->connected_dsn, $this->dsn) && $this->connected_database_name == $database_file && $this->opened_persistent == $this->options['persistent']) {
return MDB2_OK;
}
$this->disconnect(false);
}
if (empty($this->database_name)) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
$connection = $this->_doConnect($this->dsn['username'], $this->dsn['password'], $this->database_name, $this->options['persistent']);
if (MDB2::isError($connection)) {
return $connection;
}
$this->connection =& $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $database_file;
$this->opened_persistent = $this->options['persistent'];
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
$this->supported['limit_queries'] = $this->dbsyntax == 'firebird' ? true : 'emulated';
return MDB2_OK;
}
示例8: connect
/**
* Connect to the database
*
* @return MDB2_OK on success, MDB2 Error Object on failure
* @access public
*/
function connect()
{
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
if (MDB2::areEquals($this->connected_dsn, $this->dsn) && $this->opened_persistent == $this->options['persistent']) {
return MDB2_OK;
}
$this->disconnect(false);
}
if ($this->database_name && $this->options['emulate_database']) {
$this->dsn['username'] = $this->options['database_name_prefix'] . $this->database_name;
}
$connection = $this->_doConnect($this->dsn['username'], $this->dsn['password'], $this->options['persistent']);
if (PEAR::isError($connection)) {
return $connection;
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = '';
$this->opened_persistent = $this->options['persistent'];
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
if ($this->database_name) {
if ($this->database_name != $this->connected_database_name) {
$query = 'ALTER SESSION SET CURRENT_SCHEMA = "' . strtoupper($this->database_name) . '"';
$result = $this->_doQuery($query);
if (PEAR::isError($result)) {
$err = $this->raiseError($result, null, null, 'Could not select the database: ' . $this->database_name, __FUNCTION__);
return $err;
}
$this->connected_database_name = $this->database_name;
}
}
$this->as_keyword = ' ';
$server_info = $this->getServerVersion();
if (is_array($server_info)) {
if ($server_info['major'] >= '10') {
$this->as_keyword = ' AS ';
}
}
return MDB2_OK;
}