Ejemplo n.º 1
0
 /**
  * connect to the database
  *
  * @param bool $selectdb select the database now?
  * @return bool successful?
  */
 public function connect($selectdb = true)
 {
     if (!extension_loaded('mysqli')) {
         trigger_error('notrace:mysqli extension not loaded', E_USER_ERROR);
         return false;
     }
     $this->allowWebChanges = $_SERVER['REQUEST_METHOD'] !== 'GET';
     if ($selectdb) {
         $dbname = constant('XOOPS_DB_NAME');
     } else {
         $dbname = '';
     }
     if (XOOPS_DB_PCONNECT == 1) {
         $this->conn = new mysqli('p:' . XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS, $dbname);
     } else {
         $this->conn = new mysqli(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS, $dbname);
     }
     // errno is 0 if connect was successful
     if (0 !== $this->conn->connect_errno) {
         return false;
     }
     if (defined('XOOPS_DB_CHARSET') && '' !== XOOPS_DB_CHARSET) {
         // $this->queryF("SET NAMES '" . XOOPS_DB_CHARSET . "'");
         $this->conn->set_charset(XOOPS_DB_CHARSET);
     }
     $this->queryF('SET SQL_BIG_SELECTS = 1');
     return true;
 }