示例#1
0
 function Conecta($strBD)
 {
     $this->Link = mysql_connect('mysql.opalaclubefranca.com.br', $strBD, 'racnela') or die('Erro BD_Conecta: ' . "<br>" . mysql_error($this->Link));
     mysql_select_db($strBD, $this->Link) or die('\\nErro Selecionando DB prod: ' . mysql_error($this->Link));
     //	define("SET CHARACTER SET ascii");
     //	define("SET COLLATION_CONNECTION='ascii_general_ci'");
 }
function alertnoticias_consultar($consulta,$accion)
{
	$enlace = mysql_connect('atc-nh-natsdb.nationalnet.com', 'staffcenter','XgwofvLY2ayLf') or die('No pudo conectarse : ' . mysql_error());
	mysql_select_db('staffcenter',$enlace) or die('No pudo seleccionarse la BD.');
	$sql = $consulta;
	$resultado = mysql_query($sql,$enlace) or die('La consulta fall&oacute;: ' . mysql_error());
	while ($row = mysql_fetch_array($resultado)){
	
		switch($accion)
		{
			case "noticiasdeldia":
				$idsnoticias[]=$row['idnoticia'].",".$row['titulo'];
			break;
		
		}
	}
	mysql_free_result($resultado);
	
	switch($accion)
	{
		case "noticiasdeldia":
			return $idsnoticias;
		break;
	}
}
示例#3
0
 /**
  * Construct the OAuthStoreMySQL.
  * In the options you have to supply either:
  * - server, username, password and database (for a mysql_connect)
  * - conn (for the connection to be used)
  * 
  * @param array options
  */
 function __construct($options = array())
 {
     if (isset($options['conn'])) {
         $this->conn = $options['conn'];
     } else {
         if (isset($options['server'])) {
             $server = $options['server'];
             $username = $options['username'];
             if (isset($options['password'])) {
                 $this->conn = mysql_connect($server, $username, $options['password']);
             } else {
                 $this->conn = mysql_connect($server, $username);
             }
         } else {
             // Try the default mysql connect
             $this->conn = mysql_connect();
         }
         if ($this->conn === false) {
             throw new OAuthException2('Could not connect to MySQL database: ' . mysql_error());
         }
         if (isset($options['database'])) {
             if (!mysql_select_db($options['database'], $this->conn)) {
                 $this->sql_errcheck();
             }
         }
         $this->query('set character set utf8');
     }
 }
示例#4
0
/**
 * Connects to a database. After connecting, you should always call disconnect_db() to close it when
 * done.
 */
function gd_db_connect()
{
    global $g_table_prefix, $g_db_hostname, $g_db_username, $g_db_password, $g_db_name;
    $link = mysql_connect($g_db_hostname, $g_db_username, $g_db_password) or die("Couldn't connect to database.");
    @mysql_select_db($g_db_name) or die("couldn't find database '{$g_db_name}'.");
    return $link;
}
示例#5
0
文件: mysql.inc.php 项目: OvBB/v1.0
 function DBConnection($aDBInfo)
 {
     global $aQueries;
     // Initialize query array.
     $aQueries = array();
     // Populate the special queries list.
     $this->aSpecialQueries[CONCAT_ATTACHMENT] = "UPDATE attachment SET filedata = concat(filedata, '%s') WHERE id=%u";
     $this->aSpecialQueries[CONCAT_AVATAR] = "UPDATE avatar SET datum = concat(datum, '%s') WHERE id=%u";
     // Try and connect to the database server.
     if ($this->objConnection = @mysql_connect($aDBInfo['address'], $aDBInfo['username'], $aDBInfo['password'])) {
         // Try and select our database.
         if (@mysql_select_db($aDBInfo['database'])) {
             // Destroy the database connection information.
             unset($aDBInfo['address']);
             unset($aDBInfo['username']);
             unset($aDBInfo['password']);
             unset($aDBInfo['database']);
             // Flag selection success.
             $this->objSelect = TRUE;
         } else {
             // Flag selection failure.
             $this->objSelect = FALSE;
         }
     } else {
         // Flag connection failure.
         $this->objConnection = FALSE;
     }
 }
示例#6
0
 function _Connect()
 {
     $value = false;
     if (!$this->connected) {
         if (!$this->server) {
             $this->server = 'localhost';
         }
         $host = $this->server;
         if ($this->port) {
             $host .= ':' . $this->port;
         }
         $this->link_id = mysql_connect($host, $this->username, $this->password);
     }
     if ($this->link_id > 0) {
         if (empty($this->database)) {
             $value = true;
         } elseif ($this->link_id !== -1) {
             $value = mysql_select_db($this->database, $this->link_id);
         } else {
             $value = mysql_select_db($this->database);
         }
     }
     if (!$value) {
         $this->error = mysql_error();
     }
     return $value;
 }
示例#7
0
 function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre = '', $time = 0)
 {
     $this->dbhost = $dbhost;
     $this->dbuser = $dbuser;
     $this->dbpw = $dbpw;
     $this->dbname = $dbname;
     $this->dbcharset = $dbcharset;
     $this->pconnect = $pconnect;
     $this->tablepre = $tablepre;
     $this->time = $time;
     if ($pconnect) {
         if (!($this->link = mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL server');
         }
     } else {
         if (!($this->link = mysql_connect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL server');
         }
     }
     if ($this->version() > '4.1') {
         if ($dbcharset) {
             mysql_query("SET character_set_connection=" . $dbcharset . ", character_set_results=" . $dbcharset . ", character_set_client=binary", $this->link);
         }
         if ($this->version() > '5.0.1') {
             //mysql_query("SET sql_mode=''", $this->link); //关闭严格模式
         }
     }
     if ($dbname) {
         mysql_select_db($dbname, $this->link);
     }
 }
示例#8
0
function HackingLog()
{
    echo "You're not allowed to use this program! This attempted violation has been logged and your IP address was captured.";
    Warehouse('footer');
    if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    if ($openSISNotifyAddress) {
        mail($openSISNotifyAddress, 'HACKING ATTEMPT', "INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
    }
    /*if($openSISNotifyAddress)
    		mail($openSISNotifyAddress,'HACKING ATTEMPT',"INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");*/
    if (false && function_exists('mysql_query')) {
        if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        $link = @mysql_connect('os4ed.com', 'openSIS_log', 'openSIS_log');
        @mysql_select_db('openSIS_log');
        @mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
        @mysql_close($link);
        /*$link = @mysql_connect('os4ed.com','openSIS_log','openSIS_log');
        		@mysql_select_db('openSIS_log');
        		@mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");
        		@mysql_close($link);*/
    }
}
示例#9
0
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
    $link=mysql_connect ("$servername","$dbuser","$dbpassword",TRUE);
    if(!$link){die("Could not connect to MySQL");}
    mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
    return $link;
}
示例#10
0
 function connect()
 {
     require_once 'db_config.php';
     $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
     $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
     return $con;
 }
示例#11
0
function Open($dbType, $connectType = "c", $connect, $username = "", $password = "", $dbName)
{
    switch ($dbType) {
        case "mssql":
            if ($connectType == "c") {
                $idCon = mssql_connect($connect, $username, $password);
            } else {
                $idCon = mssql_pconnect($connect, $username, $password);
            }
            mssql_select_db($dbName);
            break;
        case "mysql":
            if ($connectType == "c") {
                $idCon = @mysql_connect($connect, $username, $password);
            } else {
                $idCon = @mysql_pconnect($connect, $username, $password);
            }
            $idCon1 = mysql_select_db($dbName, $idCon);
            break;
        case "pg":
            if ($connectType == "c") {
                $idCon = pg_connect($connect . " user="******" password="******" dbname=" . $dbName);
            } else {
                $idCon = pg_pconnect($connect . " user="******" password="******" dbname=" . $dbName);
            }
            break;
        default:
            $idCon = 0;
            break;
    }
    return $idCon;
}
示例#12
0
function connect_db()
{
    global $myserv;
    $myserv = mysql_connect("localhost", MYSQL_USER, MYSQL_PASSWD);
    mysql_select_db(MYSQL_DATABASE);
    mysql_set_charset('utf8');
}
示例#13
0
文件: lib.php 项目: Tokhin/tokinMama
function runSQL($query)
{
    global $conf;
    $link = mysql_connect($conf['db_hostname'], $conf['db_user'], $conf['db_password']);
    mysql_select_db($conf['db_name']);
    return mysql_query($query);
}
示例#14
0
/**
 * Connects to database using config, supported types: mysql and mysqli (recommended)
 *
 * @param $loginInfo array Contains login info instead of params.
 * @return mixed returns mysqli class when using mysqli and link resource for mysql.
 */
function db_connect($loginInfo = null)
{
    global $sql_type, $sql_host, $sql_user, $sql_pass, $sql_base, $mysqlLink, $mysqli;
    // Use $loginInfo?
    if (is_array($loginInfo)) {
        if (isset($loginInfo['host'])) {
            $sql_host = $loginInfo['host'];
        }
        if (isset($loginInfo['user'])) {
            $sql_user = $loginInfo['user'];
        }
        if (isset($loginInfo['pass'])) {
            $sql_user = $loginInfo['pass'];
        }
        if (isset($loginInfo['db'])) {
            $sql_user = $loginInfo['db'];
        }
    }
    switch ($sql_type) {
        case "mysql":
            $mysqlLink = mysql_connect($sql_host, $sql_user, $sql_pass) or die("Could not connect to MySQL-host. Error is: " . mysql_error());
            ## This might jump to installer......
            mysql_select_db($sql_base, $mysqlLink) or die("Could not select MySQL DB. Error is: " . mysql_error());
            return $mysqlLink;
        case "mysqli":
            $mysqli = new mysqli($sql_host, $sql_user, $sql_pass, $sql_base);
            if ($mysqli->connect_error) {
                die('Could not connect to MySQL-host. Error is: ' . $mysqli->connect_error);
            }
            return $mysqli;
        default:
            die("Something seriously wrong with variable sql_type in function db_connect. The reported sql_type is '{$sql_type}'");
    }
    // end switch ($sql_type)
}
示例#15
0
 /**
  * 连接数据库方法
  * @access public
  * @throws ThinkExecption
  */
 public function connect($config='',$linkNum=0,$force=false) {
     if ( !isset($this->linkID[$linkNum]) ) {
         if(empty($config))  $config =   $this->config;
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'].($config['hostport']?":{$config['hostport']}":'');
         // 是否长连接
         $pconnect   = !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
         if($pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],131072);
         }else{
             $this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,131072);
         }
         if ( !$this->linkID[$linkNum] || (!empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) ) {
             E(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         //使用UTF8存取数据库
         mysql_query("SET NAMES '".C('DB_CHARSET')."'", $this->linkID[$linkNum]);
         //设置 sql_model
         if($dbVersion >'5.0.1'){
             mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected    =   true;
         // 注销数据库连接配置信息
         if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
     }
     return $this->linkID[$linkNum];
 }
示例#16
0
function check_db($db_name, $connection)
{
    if (!($db = @mysql_select_db($db_name, $connection))) {
        return false;
    }
    return true;
}
示例#17
0
/**
 *
 */
function validate_request()
{
    global $_REQUEST;
    $errors = array();
    $link = @mysql_connect($_REQUEST['dbhost'], $_REQUEST['dbuser'], $_REQUEST['dbpass']);
    if (!$link) {
        $errors['db'][] = "Unable to connect to the database. Please check your credentials and try again.";
    }
    if (!mysql_select_db($_REQUEST['dbname'])) {
        $errors['db'][] = "The database name you specified does not exist.";
    }
    require_once "include/class.twitter.php";
    $twitter = new twitter();
    $twitter->username = $_REQUEST['twuser'];
    $twitter->password = $_REQUEST['twpass'];
    if (!$twitter->verifyCredentials()) {
        $errors['twitter'][] = 'The Twitter username and password you entered is incorrect. Do you need <a href="http://twitter.com/account/resend_password">a reminder of your password</a>?';
    }
    // make sure tag has a value
    // make sure title and subtitle exists
    // make sure cache is writable
    if (count($errors) == 0) {
        return NULL;
    }
    return $errors;
}
示例#18
0
 /**
  * Use a database
  */
 function select_db($database)
 {
     if (mysql_select_db($database, $this->db)) {
         return TRUE;
     }
     return FALSE;
 }
示例#19
0
文件: db.php 项目: seph89/AmmProject
 private function dbConnection()
 {
     // Stabilisce connessione al DB
     $this->connectionResource = @mysql_connect($this->DB_HOST, $this->DB_USER, $this->DB_PASS) or conf::showerror();
     $dbSelect = @mysql_select_db($this->DB_NAME, $this->connectionResource) or conf::showerror();
     mysql_query("set names utf8") or conf::showerror();
 }
示例#20
0
function db_connect()
{
    // połączenie z mysql
    mysql_connect(DBHOST, DBUSER, DBPASS) or die('<h2>ERROR</h2> MySQL Server is not responding');
    // wybór bazy danych
    mysql_select_db(DBNAME) or die('<h2>ERROR</h2> Cannot connect to specified database');
}
示例#21
0
 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         if ($this->pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
示例#22
0
 /**
  * 连接数据库方法
  * @access public
  * @throws ThinkExecption
  */
 public function connect($config = '', $linkNum = 0, $force = false)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         // 是否长连接
         $pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
         if ($pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum]) || C('SPARE_DB_DEBUG')) {
             $errStr = mysql_error();
             $errno = mysql_errno();
             if ($errno == 13047 || C('SPARE_DB_DEBUG')) {
                 if (C('SMS_ALERT_ON')) {
                     Sms::send('mysql超额被禁用,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
                 }
                 //[sae]启动备用数据库
                 if (C('SPARE_DB_HOST')) {
                     $this->linkID[$linkNum] = mysql_connect(C('SPARE_DB_HOST') . (C('SPARE_DB_PORT') ? ':' . C('SPARE_DB_PORT') : ''), C('SPARE_DB_USER'), C('SPARE_DB_PWD'), true, CLIENT_MULTI_RESULTS);
                     if (!$this->linkID[$linkNum]) {
                         throw_exception('备用数据库连接失败');
                     }
                     mysql_select_db(C('SPARE_DB_NAME'), $this->linkID[$linkNum]);
                     //标记使用备用数据库状态
                     $this->is_spare = true;
                 } else {
                     throw_exception($errStr);
                 }
             } else {
                 //[sae] 短信预警
                 if (C('SMS_ALERT_ON')) {
                     Sms::send('数据库连接时出错,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
                 }
                 throw_exception($errStr);
             }
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= '4.1') {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
示例#23
0
 /**
  * DB Connect
  * this method is private
  * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
  * @return resource
  */
 function __connect($connection)
 {
     // Ignore if no DB information exists
     if (strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) {
         $connection["db_hostname"] .= ':' . $connection["db_port"];
     }
     // Attempt to connect
     $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
     if (!$result) {
         exit('XE cannot connect to DB.');
     }
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     // Error appears if the version is lower than 4.1
     if (version_compare(mysql_get_server_info($result), '4.1', '<')) {
         $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is ' . mysql_get_server_info());
         return;
     }
     // select db
     @mysql_select_db($connection["db_database"], $result);
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     return $result;
 }
示例#24
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->authorizeObj = new authorize($this->testSubject['employeeId'], $this->testSubject['isAdmin']);
     $conf = new Conf();
     $this->connection = mysql_connect($conf->dbhost . ":" . $conf->dbport, $conf->dbuser, $conf->dbpass);
     mysql_select_db($conf->dbname);
     $this->_deleteTestData();
     // Insert job titles
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB001', 'Manager', 'Manager job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB002', 'Driver', 'Driver job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB003', 'Director', 'Director job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_nick_name, coun_code) " . "VALUES (11, NULL, 'Arnold', 'Subasinghe', 'Arnold', 'AF')");
     $this->_runQuery("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, emp_nick_name) " . "VALUES (12, NULL, 'Mohanjith', 'Sudirikku', 'Hannadige', 'MOHA')");
     // employees with job titles
     // Driver
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(13, '0013', 'Rajasinghe', 'Saman', 'Marlon', 'JOB002', '*****@*****.**')");
     // Manager
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(14, '0014', 'Jayasinghe', 'Aruna', 'Shantha', 'JOB001', '*****@*****.**')");
     // Insert director
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(15, '0032', 'Samuel', 'John', 'A', 'JOB003', '*****@*****.**')");
     mysql_query("INSERT INTO `hs_hr_emp_reportto` VALUES ('012', '011', 1);");
     mysql_query("INSERT INTO hs_hr_customer(customer_id, name, description, deleted) " . "VALUES(1, 'Test customer', 'description', 0)");
     mysql_query("INSERT INTO hs_hr_project(project_id, customer_id, name, description, deleted) " . "VALUES(1, 1, 'Test project 1', 'a test proj 1', 0)");
     mysql_query("INSERT INTO hs_hr_project(project_id, customer_id, name, description, deleted) " . "VALUES(2, 1, 'Test project 2', 'a test proj 2', 0)");
 }
示例#25
0
 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $conn = $this->pconnect ? 'mysql_pconnect' : 'mysql_connect';
         $this->linkID[$linkNum] = $conn($config['hostname'] . ':' . $config['hostport'], $config['username'], $config['password']);
         if (!$this->linkID[$linkNum]) {
             throw_exception(mysql_error());
             return False;
         }
         if (!mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception($this->error());
             return False;
         }
         $this->dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($this->dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
示例#26
0
 private function __construct()
 {
     $this->connection = mysql_connect(DB_HOST, DB_USER, DB_PASS);
     if ($this->connection) {
         mysql_select_db(DB_NAME);
     }
 }
示例#27
0
 private function validate()
 {
     if (!defined('DB_HOSTNAME')) {
         $this->error['warning'] = 'Host required!';
     }
     if (!defined('DB_USERNAME')) {
         $this->error['warning'] = 'User required!';
     }
     if (!defined('DB_DATABASE')) {
         $this->error['warning'] = 'Database Name required!';
     }
     if (!($connection = @mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD))) {
         $this->error['warning'] = 'Error: Could not connect to the database please make sure the database server, username and password is correct in the config.php file!';
     } else {
         if (!@mysql_select_db(DB_DATABASE, $connection)) {
             $this->error['warning'] = 'Error: Database "' . DB_DATABASE . '" does not exist!';
         }
         mysql_close($connection);
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
示例#28
0
 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->password = $sqlpassword;
     $this->server = $sqlserver;
     $this->dbname = $database;
     if ($this->persistency) {
         $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
     } else {
         $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
     }
     if ($this->db_connect_id) {
         if ($database != "") {
             $this->dbname = $database;
             $dbselect = @mysql_select_db($this->dbname);
             if (!$dbselect) {
                 @mysql_close($this->db_connect_id);
                 $this->db_connect_id = $dbselect;
             }
         }
         return $this->db_connect_id;
     } else {
         return false;
     }
 }
示例#29
0
function getTangentText($type, $keyword)
{
    global $dbHost, $dbUser, $dbPassword, $dbName;
    $link = @mysql_connect($dbHost, $dbUser, $dbPassword);
    if (!$link) {
        die("Cannot connect : " . mysql_error());
    }
    if (!@mysql_select_db($dbName, $link)) {
        die("Cannot find database : " . mysql_error());
    }
    $result = mysql_query("SELECT sr_keywords, sr_text FROM soRandom WHERE sr_type = '" . $type . "' ORDER BY sr_ID ASC;", $link);
    $tempCounter = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $pKey = "/" . $keyword . "/";
        $pos = preg_match($pKey, $row['sr_keywords']);
        //echo $pos . " is pos<br>";
        //echo $keyword;
        //echo " is keyword and this is the search return: " . $row['keywords'];
        if ($pos != 0) {
            $text[$tempCounter] = stripslashes($row["sr_text"]);
            $tempCounter++;
        }
    }
    mysql_close($link);
    //$text=htmlentities($text);
    return $text;
}
示例#30
0
 function conectar($db, $host, $user, $pass)
 {
     if ($db != "") {
         $this->BaseDatos = $db;
     }
     if ($host != "") {
         $this->Servidor = $host;
     }
     if ($user != "") {
         $this->Usuario = $user;
     }
     if ($pass != "") {
         $this->Clave = $pass;
     }
     //conectamos al servidor de db
     $this->Conexion_ID = mysql_connect($this->Servidor, $this->Usuario, $this->Clave);
     if (!$this->Conexion_ID) {
         $this->Error = "La conexion con el servidor fallida";
         return 0;
     }
     //Seleccionamos la base de datos
     if (!mysql_select_db($this->BaseDatos, $this->Conexion_ID)) {
         $this->Error = "Imposible abrir " . $this->BaseDatos;
         return 0;
     }
     /*Si todo tiene exito, retorno el identificador de la conexion*/
     return $this->Conexion_ID;
 }