Example #1
0
 /**
  * Connects to the MSSQL database.
  *
  * \param $settings
  *   An associative array with connection settings: the 'hostname',
  *   'username' and 'password' indices will be used.
  */
 function connect(array $settings)
 {
     is_array($settings) && isset($settings['hostname'], $settings['username'], $settings['password']) or trigger_error('Invalid parameters to connect()', E_USER_ERROR);
     $this->id =& mssql_pconnect($settings['hostname'], $settings['username'], $settings['password']) or trigger_error(sprintf('Could not connect to databaseserver (%s)', $settings['hostname']), E_USER_ERROR);
     // suppress warnings
     if (function_exists('mssql_min_client_severity')) {
         mssql_min_client_severity(100);
     }
     if (function_exists('mssql_min_server_severity')) {
         mssql_min_server_severity(100);
     }
     if (function_exists('mssql_min_message_severity')) {
         mssql_min_message_severity(100);
     }
     if (function_exists('mssql_min_error_severity')) {
         mssql_min_error_severity(100);
     }
 }
Example #2
0
 function db_connect($query = "SELECT")
 {
     global $db_list, $global_db_list;
     if (!is_array($db_list)) {
         return true;
     }
     if ($this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i", $query)) {
         $action = 'global';
         $details = $global_db_list[mt_rand(0, count($global_db_list) - 1)];
         $this->db_global = $details;
     } elseif (preg_match("/^\\s*(alter table|create|insert|delete|update|replace) /i", $query)) {
         $action = 'write';
         $details = $db_list['write'][mt_rand(0, count($db_list['write']) - 1)];
         $this->db_write = $details;
     } else {
         $action = '';
         $details = $db_list['read'][mt_rand(0, count($db_list['read']) - 1)];
         $this->db_read = $details;
     }
     $dbhname = "dbh" . $action;
     $this->{$dbhname} = @mssql_connect($details['db_host'], $details['db_user'], $details['db_password']);
     $this->is_mysql = false;
     if (!$this->{$dbhname}) {
         $this->bail(sprintf("\n<h1>Error establishing a database connection</h1>\n<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>\n<ul>\n        <li>Are you sure you have the correct username and password?</li>\n        <li>Are you sure that you have typed the correct hostname?</li>\n        <li>Are you sure that the database server is running?</li>\n</ul>\n<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>\n", $details['db_host']), 'db_connect_fail');
     }
     mssql_min_error_severity(0);
     mssql_min_message_severity(17);
     @mssql_query('SET TEXTSIZE 2147483647');
     $this->select($details['db_name'], $this->{$dbhname});
 }
Example #3
0
 /**
  * MS SQL DBO driver constructor; sets SQL Server error reporting defaults
  *
  * @param array $config Configuration data from app/config/databases.php
  * @return boolean True if connected successfully, false on error
  */
 function __construct($config, $autoConnect = true)
 {
     if ($autoConnect) {
         if (!function_exists('mssql_min_message_severity')) {
             trigger_error("PHP SQL Server interface is not installed, cannot continue.  For troubleshooting information, see http://php.net/mssql/", E_USER_WARNING);
         }
         mssql_min_message_severity(15);
         mssql_min_error_severity(2);
     }
     return parent::__construct($config, $autoConnect);
 }
Example #4
0
 /**
  * Connect to the database
  * 
  * @param string $host				The hostname the database is located at
  * @param integer $port				The port the database is at
  * @param string $user				Username for connecting
  * @param string $pass				Password for connecting
  * @param string $db				The database name
  * @param boolean $new_link			TRUE for establishing a new link to the database, FALSE to re-use an existing one
  * @param integer $client_flags		Database connection flags (see the PHP/MySQL documentation)
  * @return boolean
  */
 protected function _connect($host, $port, $user, $pass, $db, $new_link, $client_flags)
 {
     mssql_min_message_severity(QUICKBOOKS_DRIVER_SQL_MSSQL_MESSAGE_LEVEL);
     mssql_min_error_severity(QUICKBOOKS_DRIVER_SQL_MSSQL_ERROR_LEVEL);
     if ($port) {
         $this->_conn = mssql_connect($host, $user, $pass, $new_link) or die('host: ' . $host . ', user: '******', pass: '******' mysql_error(): ' . mssql_get_last_message());
     } else {
         $this->_conn = mssql_connect($host . ':' . $port, $user, $pass, $new_link) or die('host: ' . $host . ', user: '******', pass: '******' mysql_error(): ' . mssql_get_last_message());
     }
     return mssql_select_db($db, $this->_conn);
 }
date_default_timezone_set('Europe/Oslo');
ini_set('log_errors', 1);
ini_set('error_log', '/var/log/php-errors.log');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
//http://stackoverflow.com/questions/6511913/php-sql-error-message-changed-database-context
/*sqlsrv_configure ( "WarningsReturnAsErrors" , 0 ); //OFF
	sqlsrv_configure ( "LogSeverity" , 1 ); //SQLSRV_LOG_SEVERITY_ERROR*/
//http://forum.symfony-project.org/viewtopic.php?t=9958&p=40272
/**
 * MSSQL-queries may sometimes fail and mssql_last_error() returns "Changed database context to Relay441"
 * It may seem like this message is misinterpeted by PHP and it ends up as an error.
 * mssql_min_error_severity should remove those messages (and possibly others?)
 *
 * Source http://forum.symfony-project.org/viewtopic.php?t=9958&p=40272
 */
mssql_min_error_severity(16);
// TODO: Experimental!
ini_set('memory_limit', '1536M');
ini_set('mssql.timeout', 60 * 10);
$projectRoot = dirname(__DIR__);
/**
 * Autoload third party modules
 */
require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/config.php';
/*
 * Load .env file
 */
Dotenv::load($projectRoot);
 /**
  * Connect to and select database
  *
  * @since 3.0.0
  */
 function db_connect()
 {
     // Make sure the version is the same for your ntwdblib.dll.
     // The TDS library and the ntwdblib.dll can't be speaking two different protocols.
     // note we don't OVERWRITE an existing TDSVER environment
     // a properly set up environment might have this at 8.0 or higher
     if (false === getenv('TDSVER')) {
         putenv('TDSVER=70');
     }
     // Set text limit sizes to max BEFORE connection is made
     ini_set('mssql.textlimit', 2147483647);
     ini_set('mssql.textsize', 2147483647);
     if (get_magic_quotes_gpc()) {
         $this->dbhost = trim(str_replace("\\\\", "\\", $dbhost));
     }
     if (WP_DEBUG) {
         $this->dbh = mssql_connect($this->dbhost, $this->dbuser, $this->dbpassword);
     } else {
         $this->dbh = @mssql_connect($this->dbhost, $this->dbuser, $this->dbpassword);
     }
     if (!$this->dbh) {
         $this->bail(sprintf("\n<h1>Error establishing a database connection</h1>\n<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>\n<ul>\n    <li>Are you sure you have the correct username and password?</li>\n    <li>Are you sure that you have typed the correct hostname?</li>\n    <li>Are you sure that the database server is running?</li>\n</ul>\n<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>\n", $this->dbhost), 'db_connect_fail');
         return;
     }
     mssql_min_error_severity(0);
     mssql_min_message_severity(17);
     @mssql_query('SET TEXTSIZE 2147483647');
     $this->ready = true;
     $this->select($this->dbname, $this->dbh);
 }
Example #7
0
function vty_errno(){
        switch($this->vtAdi){
        case 'mysql': return mysql_errno(); break;
        case 'odbc': return odbc_error($sqlQuery); break;
        case 'mssql': return mssql_min_error_severity(); break;
        case 'postgresql': return 0; break;}
}