Created
March 4, 2013 09:16
-
-
Save ameliaikeda/5081017 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'downloader/Maged/Controller.php'; | |
define('MAGE_VERSION', Maged_Controller::getVersion()); | |
/** | |
* @global PDO the database connection used globally | |
*/ | |
$DB = null; | |
/** | |
* Create and open database connection object | |
* | |
* @param string $host Database host name | |
* @param string $dbname Database name | |
* @param string $user Database user | |
* @param string $password Database password | |
* @param string $port Database port | |
* @param array $options extra parameters | |
* @throws Exception when occurring error | |
*/ | |
function open_db($host, $dbname, $user, $password, $port = "", $options = array()) { | |
global $DB; | |
// TODO assign the connection to global varriable $DB | |
if($port != "") { | |
$host = $host.":".$port; | |
} | |
if(!$DB = @mysql_connect($host, $user, $password)) { | |
throw new Exception("Can't connect to mysql: ".mysql_error()); | |
} | |
if(!mysql_select_db ($dbname, $DB)) { | |
throw new Exception("Can't select database: ".mysql_error()); | |
} | |
//$DB = mysql_connect($host, $user, $pass) or die("aaaaaaa"); | |
//mysql_select_db ($dbname, $DB) or die("bbbbbbb"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment