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


PHP JDatabase::__construct方法代码示例

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


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

示例1:

 /**
  * Database object constructor
  *
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		JDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Perform a number of fatality checks, then return gracefully
     if (!function_exists('mysql_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQL');
         return;
     }
     // Connect to the server
     if (!($this->_connection = @mysql_connect($host, $user, $password, true))) {
         $this->_errorNum = 2;
         $this->_errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL');
         return;
     }
     // Finalize initialisation
     parent::__construct($options);
     // Set sql_mode to non_strict mode
     mysql_query("SET @@SESSION.sql_mode = '';", $this->_connection);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:akksi,项目名称:jcg,代码行数:36,代码来源:mysql.php

示例2:

 /**
  * Database object constructor
  *
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		JDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Perform a number of fatality checks, then return gracefully
     if (!function_exists('mysql_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = 'The MySQL adapter "mysql" is not available.';
         return;
     }
     // Connect to the server
     if (!($this->_connection = @mysql_connect($host, $user, $password, true))) {
         $this->_errorNum = 2;
         $this->_errorMsg = 'Could not connect to MySQL';
         return;
     }
     // Finalize initialisation
     parent::__construct($options);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:joebushi,项目名称:joomla,代码行数:34,代码来源:mysql.php

示例3: __construct

 /**
  * This special constructor reuses the existing resource from the existing db connecton
  *
  * @param unknown_type $options
  */
 function __construct($options)
 {
     $db =& JFactory::getDBO();
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     // perform a number of fatality checks, then return gracefully
     if (!function_exists('mysql_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = 'The MySQL adapter "mysql" is not available.';
         return;
     }
     // connect to the server
     $this->_resource =& $db->_resource;
     // finalize initialization
     JDatabase::__construct($options);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:25,代码来源:intercept.jdatabasemysql.php

示例4: __construct

 /**
  * Constructor.
  *
  * @param   array  $options  List of options used to configure the connection
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function __construct($options)
 {
     // Get some basic values from the options.
     $options['host'] = isset($options['host']) ? $options['host'] : 'localhost';
     $options['user'] = isset($options['user']) ? $options['user'] : 'root';
     $options['password'] = isset($options['password']) ? $options['password'] : '';
     $options['database'] = isset($options['database']) ? $options['database'] : '';
     $options['select'] = isset($options['select']) ? (bool) $options['select'] : true;
     // Make sure the MySQL extension for PHP is installed and enabled.
     if (!function_exists('mysql_connect')) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  11.3
         if (JError::$legacy) {
             $this->errorNum = 1;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQL');
             return;
         } else {
             throw new DatabaseException(JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQL'));
         }
     }
     // Attempt to connect to the server.
     if (!($this->connection = @mysql_connect($options['host'], $options['user'], $options['password'], true))) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  11.3
         if (JError::$legacy) {
             $this->errorNum = 2;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL');
             return;
         } else {
             throw new DatabaseException(JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL'));
         }
     }
     // Finalize initialisation
     parent::__construct($options);
     // Set sql_mode to non_strict mode
     mysql_query("SET @@SESSION.sql_mode = '';", $this->connection);
     // If auto-select is enabled select the given database.
     if ($options['select'] && !empty($options['database'])) {
         $this->select($options['database']);
     }
 }
开发者ID:ramdesh,项目名称:joomla-platform,代码行数:50,代码来源:mysql.php

示例5: __construct

 /**
  * This special constructor reuses the existing resource from the existing db connecton
  *
  * @param unknown_type $options
  */
 function __construct($options)
 {
     $db = JFactory::getDBO();
     // support for recovery of existing connections (Martin N. Brampton)
     if (isset($this->_options)) {
         $this->_options = $options;
     }
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     // perform a number of fatality checks, then return gracefully
     if (!function_exists('mysqli_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = 'The MySQL adapter "mysqli" is not available.';
         return;
     }
     // connect to the server
     $this->_resource = $db->_resource;
     // finalize initialization
     JDatabase::__construct($options);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:RangerWalt,项目名称:ecci,代码行数:29,代码来源:intercept.jdatabasemysqli.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param   array  $options  List of options used to configure the connection
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function __construct($options)
 {
     // Get some basic values from the options.
     $options['host'] = isset($options['host']) ? $options['host'] : 'localhost';
     $options['user'] = isset($options['user']) ? $options['user'] : 'root';
     $options['password'] = isset($options['password']) ? $options['password'] : '';
     $options['database'] = isset($options['database']) ? $options['database'] : '';
     $options['select'] = isset($options['select']) ? (bool) $options['select'] : true;
     $options['port'] = null;
     $options['socket'] = null;
     /*
      * Unlike mysql_connect(), mysqli_connect() takes the port and socket as separate arguments. Therefore, we
      * have to extract them from the host string.
      */
     $tmp = substr(strstr($options['host'], ':'), 1);
     if (!empty($tmp)) {
         // Get the port number or socket name
         if (is_numeric($tmp)) {
             $options['port'] = $tmp;
         } else {
             $options['socket'] = $tmp;
         }
         // Extract the host name only
         $options['host'] = substr($options['host'], 0, strlen($options['host']) - (strlen($tmp) + 1));
         // This will take care of the following notation: ":3306"
         if ($options['host'] == '') {
             $options['host'] = 'localhost';
         }
     }
     // Make sure the MySQLi extension for PHP is installed and enabled.
     if (!function_exists('mysqli_connect')) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  12.1
         if (JError::$legacy) {
             $this->errorNum = 1;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQLI');
             return;
         } else {
             throw new JDatabaseException(JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQLI'));
         }
     }
     // Attempt to connect to the server.
     if (!($this->connection = @mysqli_connect($options['host'], $options['user'], $options['password'], null, $options['port'], $options['socket']))) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  12.1
         if (JError::$legacy) {
             $this->errorNum = 2;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL');
             return;
         } else {
             throw new JDatabaseException(JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL'));
         }
     }
     // Finalize initialisation
     parent::__construct($options);
     // Set sql_mode to non_strict mode
     mysqli_query($this->connection, "SET @@SESSION.sql_mode = '';");
     // If auto-select is enabled select the given database.
     if ($options['select'] && !empty($options['database'])) {
         $this->select($options['database']);
     }
 }
开发者ID:GMaup,项目名称:joomla-platform,代码行数:71,代码来源:mysqli.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param   array  $options  List of options used to configure the connection
  *
  * @since   11.1
  */
 protected function __construct($options)
 {
     // Get some basic values from the options.
     $options['host'] = isset($options['host']) ? $options['host'] : 'localhost';
     $options['user'] = isset($options['user']) ? $options['user'] : '';
     $options['password'] = isset($options['password']) ? $options['password'] : '';
     $options['database'] = isset($options['database']) ? $options['database'] : '';
     $options['select'] = isset($options['select']) ? (bool) $options['select'] : true;
     // Build the connection configuration array.
     $config = array('Database' => $options['database'], 'uid' => $options['user'], 'pwd' => $options['password'], 'CharacterSet' => 'UTF-8', 'ReturnDatesAsStrings' => true);
     // Make sure the SQLSRV extension for PHP is installed and enabled.
     if (!function_exists('sqlsrv_connect')) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  12.1
         if (JError::$legacy) {
             $this->errorNum = 1;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_SQLSRV');
             return;
         } else {
             throw new JDatabaseException(JText::_('JLIB_DATABASE_ERROR_ADAPTER_SQLSRV'));
         }
     }
     // Attempt to connect to the server.
     if (!($this->connection = @sqlsrv_connect($options['host'], $config))) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  12.1
         if (JError::$legacy) {
             $this->errorNum = 2;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_SQLSRV');
             return;
         } else {
             throw new JDatabaseException(JText::_('JLIB_DATABASE_ERROR_CONNECT_SQLSRV'));
         }
     }
     // Make sure that DB warnings are not returned as errors.
     sqlsrv_configure('WarningsReturnAsErrors', 0);
     // Finalize initialisation
     parent::__construct($options);
     // If auto-select is enabled select the given database.
     if ($options['select'] && !empty($options['database'])) {
         $this->select($options['database']);
     }
 }
开发者ID:Arturogcalleja,项目名称:herbolario,代码行数:50,代码来源:sqlsrv.php

示例8: substr

 /**
  * Database object constructor
  *
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		JDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Unlike mysql_connect(), mysqli_connect() takes the port and socket
     // as separate arguments. Therefore, we have to extract them from the
     // host string.
     $port = NULL;
     $socket = NULL;
     $targetSlot = substr(strstr($host, ":"), 1);
     if (!empty($targetSlot)) {
         // Get the port number or socket name
         if (is_numeric($targetSlot)) {
             $port = $targetSlot;
         } else {
             $socket = $targetSlot;
         }
         // Extract the host name only
         $host = substr($host, 0, strlen($host) - (strlen($targetSlot) + 1));
         // This will take care of the following notation: ":3306"
         if ($host == '') {
             $host = 'localhost';
         }
     }
     // perform a number of fatality checks, then return gracefully
     if (!function_exists('mysqli_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQLI');
         return;
     }
     // connect to the server
     if (!($this->_connection = @mysqli_connect($host, $user, $password, NULL, $port, $socket))) {
         $this->_errorNum = 2;
         $this->_errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL');
         return;
     }
     // finalize initialization
     parent::__construct($options);
     // Set sqli_mode to non_strict mode
     mysqli_query($this->_connection, "SET @@SESSION.sql_mode = '';");
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:akksi,项目名称:jcg,代码行数:56,代码来源:mysqli.php

示例9:

 function __construct($host = 'localhost', $user, $pass, $db = '', $table_prefix = '', $offline = true)
 {
     parent::__construct('mysql', $host, $user, $pass, $db, $table_prefix);
 }
开发者ID:RangerWalt,项目名称:ecci,代码行数:4,代码来源:database.php

示例10: __construct

 /**
  * Constructor.
  *
  * @param   array  $options  Array of database options with keys: host, user, password, database, select.
  *
  * @since   11.1
  */
 protected function __construct($options)
 {
     // Get some basic values from the options.
     $options['host'] = isset($options['host']) ? $options['host'] : 'localhost';
     $options['user'] = isset($options['user']) ? $options['user'] : 'root';
     $options['password'] = isset($options['password']) ? $options['password'] : '';
     $options['database'] = isset($options['database']) ? $options['database'] : '';
     $options['select'] = isset($options['select']) ? (bool) $options['select'] : true;
     // Make sure the PDO MySQL extension for PHP is installed and enabled.
     if (!class_exists('PDO')) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  12.1
         if (JError::$legacy) {
             $this->errorNum = 1;
             $this->errorMsg = 'The PDO adapter "pdo" is not available.';
             return;
         } else {
             throw new JDatabaseException('The PDO adapter "pdo" is not available.');
         }
     }
     // Add extra configuration options as necessary
     $extras = array();
     if (isset($options['ssl_ca']) && $options['ssl_ca'] && $options['host'] != 'localhost') {
         $extras[PDO::MYSQL_ATTR_SSL_CA] = $options['ssl_ca'];
     }
     // Attempt to connect to the server.
     if (!($this->connection = new PDO("mysql:host={$options['host']}", $options['user'], $options['password'], $extras))) {
         // Legacy error handling switch based on the JError::$legacy switch.
         // @deprecated  12.1
         if (JError::$legacy) {
             $this->errorNum = 2;
             $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL');
             return;
         } else {
             throw new JDatabaseException(JText::_('JLIB_DATABASE_ERROR_CONNECT_MYSQL'));
         }
     }
     $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     // Finalize initialisation
     parent::__construct($options);
     // Set sql_mode to non_strict mode
     // mysql_query("SET @@SESSION.sql_mode = '';", $this->connection);
     // If auto-select is enabled select the given database.
     if ($options['select'] && !empty($options['database'])) {
         $this->select($options['database']);
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:54,代码来源:pdo.php

示例11: substr

 /**
  * Database object constructor
  *
  * @access	public
  * @param	array	List of options used to configure the connection
  * @since	1.5
  * @see		JDatabase
  */
 function __construct($options)
 {
     $host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
     $user = array_key_exists('user', $options) ? $options['user'] : '';
     $password = array_key_exists('password', $options) ? $options['password'] : '';
     $database = array_key_exists('database', $options) ? $options['database'] : '';
     $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
     $select = array_key_exists('select', $options) ? $options['select'] : true;
     // Unlike mysql_connect(), mysqli_connect() takes the port and socket
     // as separate arguments. Therefore, we have to extract them from the
     // host string.
     $port = NULL;
     $socket = NULL;
     $targetSlot = substr(strstr($host, ":"), 1);
     if (!empty($targetSlot)) {
         // Get the port number or socket name
         if (is_numeric($targetSlot)) {
             $port = $targetSlot;
         } else {
             $socket = $targetSlot;
         }
         // Extract the host name only
         $host = substr($host, 0, strlen($host) - (strlen($targetSlot) + 1));
         // This will take care of the following notation: ":3306"
         if ($host == '') {
             $host = 'localhost';
         }
     }
     // perform a number of fatality checks, then return gracefully
     if (!function_exists('mysqli_connect')) {
         $this->_errorNum = 1;
         $this->_errorMsg = 'The MySQL adapter "mysqli" is not available.';
         return;
     }
     // connect to the server
     if (!($this->_resource = @mysqli_connect($host, $user, $password, NULL, $port, $socket))) {
         $this->_errorNum = 2;
         $this->_errorMsg = 'Could not connect to MySQL';
         return;
     }
     // finalize initialization
     parent::__construct($options);
     // select the database
     if ($select) {
         $this->select($database);
     }
 }
开发者ID:esumerfd,项目名称:ssol_joomla,代码行数:55,代码来源:mysqli.php


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