/** * 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()); } }
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; $this->dbname = $database; $this->server = $sqlserver; if ($this->persistency) { $this->db_connect_id = odbc_pconnect($this->server, "", ""); } else { $this->db_connect_id = odbc_connect($this->server, "", ""); } if ($this->db_connect_id) { @odbc_autocommit($this->db_connect_id, off); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $this->sql_time += $endtime - $starttime; return $this->db_connect_id; } else { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $this->sql_time += $endtime - $starttime; return false; } }
/** * Connect to server */ function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) { $this->persistency = $persistency; $this->user = $sqluser; $this->dbname = $database; $port_delimiter = defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN' ? ',' : ':'; $this->server = $sqlserver . ($port ? $port_delimiter . $port : ''); $max_size = @ini_get('odbc.defaultlrl'); if (!empty($max_size)) { $unit = strtolower(substr($max_size, -1, 1)); $max_size = (int) $max_size; if ($unit == 'k') { $max_size = floor($max_size / 1024); } else { if ($unit == 'g') { $max_size *= 1024; } else { if (is_numeric($unit)) { $max_size = floor((int) ($max_size . $unit) / 1048576); } } } $max_size = max(8, $max_size) . 'M'; @ini_set('odbc.defaultlrl', $max_size); } $this->db_connect_id = $this->persistency ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword); return $this->db_connect_id ? $this->db_connect_id : $this->sql_error(''); }
public function connect() { $this->link = $this->_config['pconnect'] == 0 ? @odbc_connect($this->_config['dsn'], $this->_config['username'], $this->_config['password'], SQL_CUR_USE_ODBC) : odbc_pconnect($this->_config['dsn'], $this->_config['username'], $this->_config['password'], SQL_CUR_USE_ODBC); if (!$this->link) { $this->halt("Connect to odbc failed"); } }
function Fconectar() { $dsn = "Drypers"; $usuario = "reporte"; $clave = ""; //realizamos la conexion mediante odbc $conn = odbc_pconnect($dsn, $usuario, $clave); return $conn; }
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { global $php_errormsg; $php_errormsg = ''; $this->_connectionID = odbc_pconnect($argDSN, $argUsername, $argPassword, $this->curmode); $this->_errorMsg = $php_errormsg; //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); return $this->_connectionID != false; }
public function connect($config = array()) { $this->config = $config; $dsn = !empty($this->config['dsn']) ? $this->config['dsn'] : 'DRIVER=' . $this->config['host'] . ';SERVER=' . $this->config['server'] . ';DATABASE=' . $this->config['database']; $this->connect = $this->config['pconnect'] === true ? @odbc_pconnect($dsn, $this->config['user'], $this->config['password']) : @odbc_connect($dsn, $this->config['user'], $this->config['password']); if (empty($this->connect)) { die(getErrorMessage('Database', 'mysqlConnectError')); } }
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false) { $this->persistency = $persistency; $this->user = $sqluser; $this->server = $sqlserver . ($port ? ':' . $port : ''); $this->dbname = $database; $this->db_connect_id = $this->persistency ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword); return $this->db_connect_id ? $this->db_connect_id : $this->sql_error(''); }
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { global $php_errormsg; $php_errormsg = ''; $this->_connectionID = odbc_pconnect($argDSN, $argUsername, $argPassword, SQL_CUR_USE_ODBC); $this->_errorMsg = $php_errormsg; $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); return $this->_connectionID != false; }
function Fconectar() { $dsn = "protisa"; $usuario = "reporte"; $clave = ""; // $server="procoldb02"; //realizamos la conexion mediante odbc $conn = odbc_pconnect($dsn, $usuario, $clave); return $conn; }
function connect() { if (0 == $this->Link_ID) { $this->Link_ID = odbc_pconnect($this->Database, $this->User, $this->Password, $this->UseODBCCursor); if (!$this->Link_ID) { $this->halt("Link-ID == false, odbc_pconnect failed"); } } return $this->Link_ID; }
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) { $this->persistency = $persistency; $this->server = $sqlserver; $this->user = $sqluser; $this->password = $sqlpassword; $this->dbname = $database; $this->db_connect_id = $this->persistency ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password); return $this->db_connect_id ? $this->db_connect_id : false; }
/** * Opens a MS Access database. */ protected function selectDatabase() { if ($this->usePConnect) { $this->linkID = @odbc_pconnect("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" . $this->database, '', ''); } else { $this->linkID = @odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" . $this->database, '', ''); } if ($this->linkID === false) { throw new DatabaseException("Cannot use database " . $this->database, $this); } }
/** * * @todo should perhaps handle this method differently if $options are not passed * * @param $database * @param $user * @param $password * @param null $options * @return bool|resource */ public function connect($database, $user, $password, $options = null) { if ($options) { if (isset($options['persistent']) && $options['persistent']) { $conn = odbc_pconnect($database, $user, $password); } else { $conn = odbc_connect($database, $user, $password); } if (is_resource($conn)) { return $conn; } } $this->setError(); return false; }
function connect($dsn, $db = '', $user, $password, $persistent = false) { parent::connect($dsn, $db, $user, $password, $persistent); $this->dsn = $dsn; $this->host = ''; $this->db = ''; if ($persistent) { $this->db = odbc_pconnect($dsn, $user, $password); } else { $this->db = odbc_connect($dsn, $user, $password); } if ($this->db) { return true; } else { $this->_addError('Error connecting to db!', 'connect()'); return false; } }
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) { $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; $this->dbname = $database; $this->server = $sqlserver; if ($this->persistency) { $this->db_connect_id = odbc_pconnect($this->server, "", ""); } else { $this->db_connect_id = odbc_connect($this->server, "", ""); } if ($this->db_connect_id) { @odbc_autocommit($this->db_connect_id, off); return $this->db_connect_id; } else { return false; } }
function connect() { if (!$this->Connected) { $this->Query_ID = 0; if ($this->Persistent) { $this->Link_ID = odbc_pconnect($this->DBDatabase, $this->DBUser, $this->DBPassword, $this->UseODBCCursor); } else { $this->Link_ID = odbc_connect($this->DBDatabase, $this->DBUser, $this->DBPassword, $this->UseODBCCursor); } if (!$this->Link_ID) { $this->Halt("Cannot connect ot Database: " . odbc_errormsg()); return false; } foreach ($this->Options as $option) { @odbc_setoption($this->Link_ID, $option[0], $option[1], $option[2]); } $this->Connected = true; } }
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; $this->persistency = $persistency; $this->server = $sqlserver; $this->user = $sqluser; $this->password = $sqlpassword; $this->dbname = $database; $this->db_connect_id = $this->persistency ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $this->sql_time += $endtime - $starttime; return $this->db_connect_id ? $this->db_connect_id : false; }
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { global $php_errormsg; if (!function_exists('odbc_connect')) return null; if (isset($php_errormsg)) $php_errormsg = ''; $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; if ($this->debug && $argDatabasename) { ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter."); } // print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush(); if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID); if (isset($this->connectStmt)) $this->Execute($this->connectStmt); return $this->_connectionID != false; }
function DoConnect() { if ($this->bConnected) { return; } $this->bConnected = true; if (!defined("DBPersistent")) { define("DBPersistent", true); } //$DSN = "DRIVER={SQL Server}; SERVER={".$DBHost."};UID={".$DBLogin."};PWD={".$DBPassword."}; DATABASE={".$DBName."}"; $DSN = $this->DBHost; if (DBPersistent) { $this->db_Conn = odbc_pconnect($DSN, $this->DBLogin, $this->DBPassword); } else { $this->db_Conn = odbc_connect($DSN, $this->DBLogin, $this->DBPassword); } if (!$this->db_Conn) { $s = DBPersistent ? "odbc_pconnect" : "odbc_connect"; if ($this->debug || @session_start() && $_SESSION["SESS_AUTH"]["ADMIN"]) { echo "<br><font color=#ff0000>Error! " . $s . "('-', '-', '-')</font><br>#" . odbc_error() . " " . odbc_errormsg() . "<br>"; } else { SendError("Error! " . $s . "('-', '-', '-')\n#" . odbc_error() . " " . odbc_errormsg() . "\n"); } return false; } odbc_autocommit($this->db_Conn, true); if ($this->DBName != "") { $this->Query("USE " . $this->DBName); } $this->cntQuery = 0; $this->timeQuery = 0; $this->arQueryDebug = array(); global $DB, $USER, $APPLICATION; if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/after_connect.php")) { include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/after_connect.php"; } return true; }
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { global $php_errormsg; $php_errormsg = ''; if ($this->debug && $argDatabasename) { ADOConnection::outp("For odbc PConnect(), {$argDatabasename} is not used. Place dsn in 1st parameter."); } // print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush(); if ($this->curmode === false) { $this->_connectionID = odbc_connect($argDSN, $argUsername, $argPassword); } else { $this->_connectionID = odbc_pconnect($argDSN, $argUsername, $argPassword, $this->curmode); } $this->_errorMsg = $php_errormsg; if ($this->_connectionID && $this->autoRollback) { @odbc_rollback($this->_connectionID); } return $this->_connectionID != false; }
/** * Opens up a database connection. * * Use a pooled connection if the db supports it and * the <var>db_persistent</var> setting is enabled. * * <b>Notes:</b> * - The database type is determined by the global variable * <var>db_type</var> * - For ODBC, <var>$host</var> is ignored, <var>$database</var> = DSN * - For Oracle, <var>$database</var> = tnsnames name * - Use the {@link dbi_error()} function to get error information if the connection * fails * * @param string $host Hostname of database server * @param string $login Database login * @param string $password Database login password * @param string $database Name of database * * @return resource The connection */ function dbi_connect($host, $login, $password, $database) { if (strcmp($GLOBALS["db_type"], "mysql") == 0) { if ($GLOBALS["db_persistent"]) { $c = mysql_pconnect($host, $login, $password); } else { $c = mysql_connect($host, $login, $password); } if ($c) { if (!mysql_select_db($database)) { return false; } return $c; } else { return false; } } else { if (strcmp($GLOBALS["db_type"], "mysqli") == 0) { if ($GLOBALS["db_persistent"]) { $c = @mysqli_connect($host, $login, $password, $database); } else { $c = @mysqli_connect($host, $login, $password, $database); } if ($c) { /* if ( ! mysqli_select_db ( $c, $database ) ) return false; */ $GLOBALS["db_connection"] = $c; return $c; } else { return false; } } else { if (strcmp($GLOBALS["db_type"], "mssql") == 0) { if ($GLOBALS["db_persistent"]) { $c = mssql_pconnect($host, $login, $password); } else { $c = mssql_connect($host, $login, $password); } if ($c) { if (!mssql_select_db($database)) { return false; } return $c; } else { return false; } } else { if (strcmp($GLOBALS["db_type"], "oracle") == 0) { if (strlen($host) && strcmp($host, "localhost")) { $c = OCIPLogon("{$login}@{$host}", $password, $database); } else { $c = OCIPLogon($login, $password, $database); } $GLOBALS["oracle_connection"] = $c; return $c; } else { if (strcmp($GLOBALS["db_type"], "postgresql") == 0) { if (strlen($password)) { if (strlen($host)) { $dbargs = "host={$host} dbname={$database} user={$login} password={$password}"; } else { $dbargs = "dbname={$database} user={$login} password={$password}"; } } else { if (strlen($host)) { $dbargs = "host={$host} dbname={$database} user={$login}"; } else { $dbargs = "dbname={$database} user={$login}"; } } if ($GLOBALS["db_persistent"]) { $c = pg_pconnect($dbargs); } else { $c = pg_connect($dbargs); } $GLOBALS["postgresql_connection"] = $c; if (!$c) { echo "Error connecting to database\n"; exit; } return $c; } else { if (strcmp($GLOBALS["db_type"], "odbc") == 0) { if ($GLOBALS["db_persistent"]) { $c = odbc_pconnect($database, $login, $password); } else { $c = odbc_connect($database, $login, $password); } $GLOBALS["odbc_connection"] = $c; return $c; } else { if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) { if ($GLOBALS["db_persistent"]) { $c = db2_pconnect($database, $login, $password); } else { $c = db2_connect($database, $login, $password); } $GLOBALS["ibm_db2_connection"] = $c; return $c; } else { if (strcmp($GLOBALS["db_type"], "ibase") == 0) { $host = $host . ":" . $database; if ($GLOBALS["db_persistent"]) { $c = ibase_pconnect($host, $login, $password); } else { $c = ibase_connect($host, $login, $password); } return $c; } else { if (empty($GLOBALS["db_type"])) { dbi_fatal_error("dbi_connect(): db_type not defined."); } else { dbi_fatal_error("dbi_connect(): invalid db_type '" . $GLOBALS["db_type"] . "'"); } } } } } } } } } }
/** * Non-persistent database connection * * @param bool $persistent * @return resource */ public function db_connect($persistent = FALSE) { return $persistent === TRUE ? odbc_pconnect($this->dsn, $this->username, $this->password) : odbc_connect($this->dsn, $this->username, $this->password); }
<?php include 'config.php'; global $DB; $DB = str_replace("\"", "", $DB); $connection_string = odbc_pconnect($DB, "", ""); $sqlquery = "Exec usp_USI_getVIPERReferringProviderCount " . $_GET['pReferringProviderID']; $process = odbc_exec($connection_string, $sqlquery); odbc_fetch_row($process); // echo odbc_result($process,"numOfPrev"); if (odbc_result($process, "numOfPrev") > 0) { echo "1"; } else { echo "0"; }
NotSupportedException("PHP extension 'odbc' is not loaded.");}}function connect(array&$config){if(isset($config['resource'])){$this->connection=$config['resource'];}else{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']);}else{$this->connection=@odbc_pconnect($config['dsn'],$config['username'],$config['password']);}}if(!is_resource($this->connection)){throw new DibiDriverException(odbc_errormsg().' '.odbc_error());}}function
/** * Persistent database connection * * @access private called by the base class * @return resource */ function db_pconnect() { return @odbc_pconnect($this->hostname, $this->username, $this->password); }
<?php if (isset($_POST['dsn'])) { if (isset($_POST['user'])) { if (isset($_POST['password'])) { $dsn = $_POST['dsn']; $user = $_POST['user']; $password = $_POST['password']; if (isset($_POST['grammar'])) { if (file_exists('grammar_' . $_POST['grammar'] . '.php')) { require 'grammar_' . $_POST['grammar'] . '.php'; $connection = odbc_pconnect($dsn, $user, $password); } else { $status = "Invalid grammar"; } } else { require 'grammar_default.php'; $connection = odbc_pconnect($dsn, $user, $password); } } else { $status = "password required"; } } else { $status = "user required"; } } else { $status = "dsn required"; }
/** * Persistent database connection * * @access private called by the base class * @return resource */ function db_pconnect() { return odbc_pconnect($this->database, $this->username, $this->password); }
/** * Get a database connection. This function shouldn't be used by you, as a connection to the database is established automatically. * * @param boolean Whether to create a persistant connection * @param string The database name * @param string The database host (the server) * @param string The database connection username * @param string The database connection password * @param boolean Whether to on error echo an error and return with a NULL, rather than giving a critical error * @return ?array A database connection (NULL: failed) */ function db_get_connection($persistent, $db_name, $db_host, $db_user, $db_password, $fail_ok = false) { if ($db_host != 'localhost') { fatal_exit(do_lang_tempcode('ONLY_LOCAL_HOST_FOR_TYPE')); } // Potential cacheing global $CACHE_DB; if (isset($CACHE_DB[$db_name][$db_host])) { return $CACHE_DB[$db_name][$db_host]; } if (!function_exists('odbc_connect')) { $error = 'The ODBC PHP extension not installed (anymore?). You need to contact the system administrator of this server.'; if ($fail_ok) { echo $error; return NULL; } critical_error('PASSON', $error); } $db = $persistent ? @odbc_pconnect($db_name, $db_user, $db_password) : @odbc_connect($db_name, $db_user, $db_password); if ($db === false) { $error = 'Could not connect to database-server (' . odbc_errormsg() . ')'; if ($fail_ok) { echo $error; return NULL; } critical_error('PASSON', $error); //warn_exit(do_lang_tempcode('CONNECT_DB_ERROR')); } if (!$db) { fatal_exit(do_lang('CONNECT_DB_ERROR')); } $CACHE_DB[$db_name][$db_host] = $db; return $db; }
/** * Connect to server */ function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) { $this->persistency = $persistency; $this->user = $sqluser; $this->server = $sqlserver . (($port) ? ':' . $port : ''); $this->dbname = $database; $max_size = @ini_get('odbc.defaultlrl'); if (!empty($max_size)) { $unit = strtolower(substr($max_size, -1, 1)); $max_size = (int) $max_size; if ($unit == 'k') { $max_size = floor($max_size / 1024); } else if ($unit == 'g') { $max_size *= 1024; } else if (is_numeric($unit)) { $max_size = floor((int) ($max_size . $unit) / 1048576); } $max_size = max(8, $max_size) . 'M'; @ini_set('odbc.defaultlrl', $max_size); } $this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword); return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); }