示例#1
0
 public static function getInstance($aDbConfig)
 {
     extract($aDbConfig);
     $oDb = new DbMysql();
     $oDb->connect($host, $user, $password, $dbname, $charset);
     return $oDb;
 }
示例#2
0
 public function initDb($index, $indexCfg, $force)
 {
     $db = new DbMysql(Config::$db);
     $sql = "SHOW TABLES LIKE '{$index}'";
     $rst = $db->queryFirst($sql);
     if ($rst) {
         if ('force' !== $force) {
             echo "[" . date('Y-m-d H:i:s') . "]Warning:该数据表已存在,继续执行则会清空原有数据,强制执行请在命令最后加force\n";
             echo "eg. {PHP_BIN}/php -f {Psearch_PATH}/cli.php INDEXNAME init force\n";
             exit;
         } else {
             $sql = "DROP TABLE `{$index}`";
             $db->execute($sql);
             echo "[" . date('Y-m-d H:i:s') . "]删除原索引数据表并清除数据\n";
         }
     }
     $sql = "CREATE TABLE `{$index}`(";
     $sql .= "`id` int(11) unsigned NOT NULL,";
     foreach ($indexCfg as $key => $val) {
         list($value, $attr) = explode('|', $val);
         $sql .= "`{$key}` {$value} NOT NULL,";
     }
     $sql .= "PRIMARY KEY (`id`)";
     $sql .= ")ENGINE=MyISAM DEFAULT CHARSET=utf8";
     $db->execute($sql);
     echo "[" . date('Y-m-d H:i:s') . "]生成新索引数据表\n";
     echo "[" . date('Y-m-d H:i:s') . "] <<<<< Succeed\n";
     exit;
 }
 public function doRetrieve()
 {
     $mysql = new DbMysql();
     if (!$mysql->connect()) {
         return "ERROR: Sql server connect error!\n";
     }
     $ret = $mysql->getList();
     return $ret;
 }
 public function excluir(Membro $obj)
 {
     $strSQL = "DELETE FROM ADM_HMEC_HISTORICO_MEMBROS_ESTADOS_CIVIS ";
     $strSQL .= "WHERE PES_ID = '" . $obj->getId() . "'";
     if (DbMysql::getInstance()->update($strSQL)) {
         return true;
     } else {
         return false;
     }
 }
示例#5
0
文件: DbMysql.class.php 项目: jyht/v5
 public function close()
 {
     if (is_resource($this->link)) {
         mysql_close($this->link);
         self::$isConnect = null;
         $this->link = null;
     }
 }
 protected function setUp()
 {
     $this->db = DbMysql::getDBInstance('localhost', 'test', 'root', '');
 }
示例#7
0
    }
    /**
     * close db connection
     * @return bool whether close connection successful
     */
    function close()
    {
        return mysql_close($this->conn);
    }
    /**
     * Character encoding conversion
     * @return character
     */
    //	function setCharsetEncoding($data){;
    //		$data = ($data,'iso8859-1','utf-8');
    //		return $data;
    //	}
    /**
     * display error message and exit
     * @param string $message
     * @param string $sql, sql statememt
     */
    function halt($message = '', $sql = '')
    {
        echo $message;
        echo "The method or operation is not implemented.";
        exit;
    }
}
$dbmgr = DbMysql::getInstance();
$myconn = $dbmgr->connect($CONFIG['database']['host'], $CONFIG['database']['user'], $CONFIG['database']['psw'], $CONFIG['database']['database']);
示例#8
0
文件: tenpay.php 项目: omusico/jianli
$reqHandler->setParameter("transport_desc", "");
//物流说明
$reqHandler->setParameter("trans_type", "1");
//交易类型
$reqHandler->setParameter("agentid", "");
//平台ID
$reqHandler->setParameter("agent_type", "");
//代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id", "");
//卖家的商户号
//请求的URL
$reqUrl = $reqHandler->getRequestURL();
$debugInfo = $reqHandler->getDebugInfo();
//---保存数据库操作
require_once "classes/dbmysql.class.php";
$oDb = DbMysql::getInstance($aDbConfig);
$data = array('type' => $_REQUEST['type'], 'target' => $_REQUEST['target'], 'money' => $order_price, 'mch_vno' => $mch_vno, 'req_url' => $reqUrl, 'debug_info' => $debugInfo, 'createtime' => time());
$ret = $oDb->insert('tb_pay', $data);
if (!$ret) {
    file_put_contents('error.txt', var_export($data, true) . "\n", FILE_APPEND);
}
//---跳转
header("Location:" . $reqUrl);
exit;
//获取debug信息,建议把请求和debug信息写入日志,方便定位问题
/**/
echo "<br/>" . $reqUrl . "<br/>";
echo "<br/>" . $debugInfo . "<br/>";
?>
<html>
<head>
include_once "includes/timer.class.php";
$BenchmarkTimer = new c_Timer();
$BenchmarkTimer->start();
// Start benchmarking immediately
//Now, include the configuration.
require_once "library.php";
if ($debug === true) {
    include_once "includes/benchmark.class.php";
    $benchmark = new DebugLib();
    $benchmark->scratch_dir = $scratch_dir;
}
if ($debug) {
    $benchmark->memory_checkpoint(__LINE__, __FILE__);
}
include_once 'includes/mysql.class.php';
$db = new DbMysql();
//instantiate the database object
$db->connect($db_server, $db_user, $db_pass, $db_name, $db_persistent);
$db->prefix = $prefix;
if ($debug) {
    $benchmark->memory_checkpoint(__LINE__, __FILE__);
}
#  Include Configs & Variables
#################################################################################################
//TODO: main.php 32 Eliminate this cookie shit, use sessions for logged in users, track what they have viewed or not
//TODO: this is where we would check user login , and if logged in set up their specific page views needs.
//TODO: we want to build a cache of the core, and only need to dynamically write the stuff "around" it.. some pages can be fully cached as html
if (!empty($_COOKIE["checkviewed"]) && $_COOKIE["checkviewed"] != "1") {
    setcookie("checkcookie", "1", $cookietime, "{$cookiepath}");
    if ($_COOKIE["checkviewed"] == "1") {
        $cookietime = time() + 24 * 3600 * 365;
示例#10
0
}
session_start();
require './util.php';
require './config.php';
date_default_timezone_set($config['timezone']);
require './SAE_detect.php';
// Useless for you, comment out this line
require './DbMysql.Class.php';
require './Paging.Class.php';
$out['title'] = $config['title'];
$out['blog_name'] = $config['blog_name'];
$out['author'] = $config['author'];
$out['description'] = $config['description'];
$out['site'] = $config['site'];
$out['archives'] = array();
$mysql_obj = new DbMysql($config['database_address'], $config['database_user_name'], $config['database_password'], $config['database_name'], $config['database_connection_encode'], $config['database_port']);
$sql = 'select content,max(time) from declaration';
$notice = $mysql_obj->query($sql);
$out['notice'] = '';
if ($mysql_obj->get_rows_count()) {
    $temp = $mysql_obj->fetch_array($notice);
    $out['notice'] .= $temp['content'];
} else {
    $out['notice'] .= '主人很懒,没写过公告';
}
$sql = 'select post_time from note order by post_time desc';
$archive = $mysql_obj->query($sql);
if ($mysql_obj->get_rows_count()) {
    for (; $temp = $mysql_obj->fetch_array($archive);) {
        $out['archive_list'][] = $temp;
    }
示例#11
0
function getDb()
{
    global $aNewDbConfig;
    $oDb = DbMysql::getInstance($aNewDbConfig);
    return $oDb;
}