/** * Connects to the database. * * This function connects to a MySQL database * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean TRUE, if connected, otherwise FALSE * @access public * @author Adam Greene <*****@*****.**> * @since 2004-12-10 */ function connect($host, $user, $passwd, $db) { $this->conn = @sybase_pconnect($host, $user, $passwd); if (empty($db) || $this->conn === false) { PMF_Db::errorPage('An unspecified error occurred.'); die; } return @sybase_select_db($db, $this->conn); }
/** * Connects to the database. * * This function connects to a ibase database * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean true, if connected, otherwise false * @access public * @author Thorsten Rinne <*****@*****.**> * @since 2005-04-16 */ function connect($host, $user, $passwd, $db) { $this->conn = ibase_connect($db, $user, $passwd); if (false == $this->conn) { PMF_Db::errorPage(ibase_errmsg()); die; } return true; }
/** * Connects to the database. * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean TRUE, if connected, otherwise FALSE */ function connect($host, $user, $passwd, $db) { $this->conn = mssql_pconnect($host, $user, $passwd); if (empty($db) or $this->conn == false) { PMF_Db::errorPage(mssql_get_last_message()); die; } return mssql_select_db($db, $this->conn); }
/** * This function connects to a DB2 database * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean TRUE, if connected, otherwise FALSE * @access public * @author Thorsten Rinne <*****@*****.**> * @since 2005-04-16 */ function connect($host, $user, $passwd, $db) { $this->conn = db2_pconnect($db, $user, $passwd, $this->options); if (false == $this->conn) { PMF_Db::errorPage(db2_conn_errormsg()); die; } return true; }
/** * Connects to the database. * * This function connects to a MySQL database * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean true, if connected, otherwise false * @access public * @author Thorsten Rinne <*****@*****.**> * @since 2005-02-21 */ public function connect($host, $user, $passwd, $db) { $this->conn = new mysqli($host, $user, $passwd, $db); if (mysqli_connect_errno()) { PMF_Db::errorPage(mysqli_connect_error()); die; } return true; }
/** * Connects to the database. * * This function connects to a MySQL database * * @param string $host Hostname * @param string $username Username * @param string $password Password * @param string $db_name Database name * @return boolean TRUE, if connected, otherwise false */ public function connect($host, $user, $password, $db) { $this->conn = mysql_connect($host, $user, $password); if (empty($db) || $this->conn == false) { PMF_Db::errorPage($this->error()); die; } return mysql_select_db($db, $this->conn); }
/** * Connects to the database. * * @param string * @return boolean */ public function connect($host, $user = false, $passwd = false, $db = false) { $this->conn = new SQLite3($host); if (!$this->conn) { PMF_Db::errorPage($this->conn->lastErrorMsg()); die; } return true; }
/** * Connects to the database. * * @param string * @return boolean */ public function connect($host, $user = false, $passwd = false, $db = false) { $this->conn = sqlite_open($host, 0666); if (!$this->conn) { PMF_Db::errorPage(sqlite_error_string(sqlite_last_error($this->conn))); die; } return true; }
/** * Connects to the database. * * This function connects to a MySQL database * * @param string $host A string specifying the name of the server to which a connection is being established * @param string $user Specifies the User ID to be used when connecting with SQL Server Authentication * @param string $passwd Specifies the password associated with the User ID to be used when connecting with * SQL Server Authentication * @param string $database Specifies the name of the database in use for the connection being established * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $passwd, $database) { $this->setConnectionOptions($user, $passwd, $database); $this->conn = sqlsrv_connect($host, $this->connectionOptions); if (!$this->conn) { PMF_Db::errorPage(sqlsrv_errors()); die; } return true; }
/** * Connects to the database. * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean TRUE, if connected, otherwise FALSE * @access public * @author Thorsten Rinne <*****@*****.**> * @since 2005-09-20 */ public function connect($host, $user, $passwd, $db) { $this->conn = oci_connect($user, $passwd, $db); if (empty($db) or $this->conn == true) { $error = oci_error(); PMF_Db::errorPage($error['message']); return false; } return true; }
/** * Connects to the database. * * @param string $host Hostname * @param string $user Username * @param string $password Password * @param string $database Database name * * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $password, $database = '') { try { $this->conn = new PDO('mysql:host=' . $host . ';dbname=' . $database . ';charset=UTF8', $user, $password); $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { PMF_Db::errorPage('Database connection failed: ' . $e->getMessage()); } return true; }
/** * Connects to the database. * * @param string $host Database hostname * @param string $user Database username * @param string $password Password * @param string $database Database name * * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $password, $database = '') { $connectionString = sprintf('host=%s port=5432 dbname=%s user=%s password=%s', $host, $database, $user, $password); $this->conn = pg_pconnect($connectionString); if (empty($database) || $this->conn == false) { PMF_Db::errorPage(pg_last_error($this->conn)); die; } $this->query("SET standard_conforming_strings=on"); return true; }
/** * Connects to the database. * * @param string $host * @param string $user * @param string $password * @param string $database * * @return boolean TRUE, if connected, otherwise FALSE */ public function connect($host, $user, $password, $database = '') { $this->conn = mssql_pconnect($host, $user, $password); if ($this->conn === false) { PMF_Db::errorPage(mssql_get_last_message()); die; } if ('' !== $database) { return mssql_select_db($database, $this->conn); } return true; }
/** * Connects to the database. * * This function connects to a MySQL database * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean true, if connected, otherwise false * @access public * @author Thorsten Rinne <*****@*****.**> * @author Tom Rochester <*****@*****.**> * @since 2003-02-24 */ public function connect($host, $user, $passwd, $db) { /* if you use mysql_pconnect(), remove the next line: */ $this->conn = pg_pconnect('host=' . $host . ' port=5432 dbname=' . $db . ' user='******' password=' . $passwd); /* comment out for more speed with mod_php or on Windows */ // $this->conn = @pg_pconnect("host=$host port=5432 dbname=$db user=$user password=$passwd"); if (empty($db) || $this->conn == false) { PMF_Db::errorPage(pg_last_error($this->conn)); die; } return true; }
/** * Connects to the database. * * This function connects to a MySQL database * * @param string $host * @param string $username * @param string $password * @param string $db_name * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $passwd, $db) { $this->conn = new mysqli($host, $user, $passwd, $db); if (mysqli_connect_errno()) { PMF_Db::errorPage(mysqli_connect_error()); die; } /* change character set to UTF-8 */ if (!$this->conn->set_charset('utf8')) { PMF_Db::errorPage($this->error()); } return true; }
/** * Connects to the database * * @param string $host MySQL Hostname * @param string $user MySQL Username * @param string $password MySQL Password * @param string $database MySQL Database name * * @return boolean */ public function connect($host, $user, $password, $database = '') { $this->conn = mysql_connect($host, $user, $password); if ($this->conn === false) { PMF_Db::errorPage($this->error()); die; } mysql_set_charset('utf8', $this->conn); if ('' !== $database) { return $this->selectDb($database); } return true; }
/** * Connects to the database. * * @param string $host Database hostname * @param string $username Database username * @param string $password Password * @param string $database Database name * * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $password, $database) { $connectionString = sprintf('host=%s port=5432 dbname=%s user=%s password=%s', $host, $database, $user, $password); /* if you use mysql_pconnect(), remove the next line: */ $this->conn = pg_pconnect($connectionString); /* comment out for more speed with mod_php or on Windows */ // $this->conn = @pg_pconnect($connectionString); if (empty($database) || $this->conn == false) { PMF_Db::errorPage(pg_last_error($this->conn)); die; } $this->query("SET standard_conforming_strings=on"); return true; }
/** * Connects to the database * * @param string $host MySQL Hostname * @param string $username MySQL Username * @param string $password MySQL Password * @param string $db_name MySQL Database name * * @return boolean TRUE, if connected, otherwise false */ public function connect($host, $user, $password, $db) { $this->conn = mysql_connect($host, $user, $password); if (empty($db) || $this->conn == false) { PMF_Db::errorPage($this->error()); die; } if (version_compare(PHP_VERSION, '5.2.3', '>')) { mysql_set_charset('utf8', $this->conn); } else { $this->query('SET NAMES utf8'); } return mysql_select_db($db, $this->conn); }
/** * Connects to the database. * * @param string $host Hostname or path to socket * @param string $user Username * @param string $password Password * @param string $database Database name * * @throws PMF_Exception * * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $password, $database = '') { $this->conn = new mysqli($host, $user, $password); if ($this->conn->connect_error) { PMF_Db::errorPage($this->conn->connect_errno . ': ' . $this->conn->connect_error); die; } // change character set to UTF-8 if (!$this->conn->set_charset('utf8')) { PMF_Db::errorPage($this->error()); } if ('' !== $database) { if (!$this->conn->select_db($database)) { throw new PMF_Exception('Cannot connect to database ' . $database); } } return true; }
/** * Connects to the database. * * @param string $host Hostname * @param string $user Username * @param string $password Password * @param string $database Database name * * @throws PMF_Exception * * @return boolean true, if connected, otherwise false */ public function connect($host, $user, $password, $database = '') { if (substr($host, 0, 1) == '/') { // Connect to MySQL via socket $this->conn = new mysqli(null, $user, $password, null, null, $host); } else { // Connect to MySQL via network $this->conn = new mysqli($host, $user, $password); } if ($this->conn->connect_error) { PMF_Db::errorPage($this->conn->connect_errno . ': ' . $this->conn->connect_error); die; } // change character set to UTF-8 if (!$this->conn->set_charset('utf8')) { PMF_Db::errorPage($this->error()); } if ('' !== $database) { if (!$this->conn->select_db($database)) { throw new PMF_Exception('Cannot connect to database ' . $database); } } return true; }
require PMF_CONFIG_DIR . '/database.php'; } require PMF_CONFIG_DIR . '/constants.php'; // // Set the error handler to our pmf_error_handler() function // set_error_handler('pmf_error_handler'); // // Create a database connection // try { PMF_Db::setTablePrefix($DB['prefix']); $db = PMF_Db::factory($DB['type']); $db->connect($DB['server'], $DB['user'], $DB['password'], $DB['db']); } catch (PMF_Exception $e) { PMF_Db::errorPage($e->getMessage()); exit(-1); } // // Fetch the configuration and add the database connection // $faqConfig = new PMF_Configuration($db); $faqConfig->getAll(); // // We always need a valid session! // ini_set('session.use_only_cookies', 1); // Avoid any PHP version to move sessions on URLs ini_set('session.auto_start', 0); // Prevent error to use session_start() if it's active in php.ini ini_set('session.use_trans_sid', 0);