Database Err: SQLSTATE[HY000] [2002] Connection refused
- /www/wwwroot/sqzhongming.com/protected/include/core.php on line 363
358.
{
359.
if($force_replace || empty($GLOBALS['instance']['mysql'][$db_config_key]))
360.
{
361.
try{
362.
$GLOBALS['instance']['mysql'][$db_config_key] = new PDO('mysql:dbname='.$db_config['MYSQL_DB'].';host='.$db_config['MYSQL_HOST'].';port='.$db_config['MYSQL_PORT'], $db_config['MYSQL_USER'], $db_config['MYSQL_PASS'], array(PDO::MYSQL_ATTR_INIT_COMMAND=>'SET NAMES \''.$db_config['MYSQL_CHARSET'].'\''));
363.
364.
}catch(PDOException $e){err('Database Err: '.$e->getMessage());}
}
365.
return $GLOBALS['instance']['mysql'][$db_config_key];
366.
}
367.
368.
private function _where($conditions)
- /www/wwwroot/sqzhongming.com/protected/include/core.php on line 345
340.
$slave_key = array_rand($GLOBALS['mysql']['MYSQL_SLAVE']);
341.
$sth = $this->db_instance($GLOBALS['mysql']['MYSQL_SLAVE'][$slave_key], 'slave_'.$slave_key)->prepare($sql);
342.
}
343.
else
344.
{
345.
346.
$sth = $this->db_instance($GLOBALS['mysql'], 'master')->prepare($sql);
}
347.
348.
if(is_array($params) && !empty($params))
349.
{
350.
foreach($params as $k=>&$v) $sth->bindParam($k, $v);
- /www/wwwroot/sqzhongming.com/protected/include/core.php on line 333
328.
return empty($this->page) ? '' : " LIMIT {$this->page['offset']},{$this->page['limit']}";
329.
}
330.
return $limit ? ' LIMIT '.$limit : '';
331.
}
332.
333.
334.
public function query($sql, $params = array()){return $this->execute($sql, $params, true);}
335.
public function execute($sql, $params = array(), $readonly = FALSE)
336.
{
337.
$this->sql[] = $sql;
338.
if($readonly && !empty($GLOBALS['mysql']['MYSQL_SLAVE']))
- /www/wwwroot/sqzhongming.com/protected/include/core.php on line 225
220.
public function find($conditions = array(), $sort = null, $fields = '*')
221.
{
222.
$conditions = $this->_where($conditions);
223.
$sql = ' FROM '.$this->table_name.$conditions["_where"];
224.
$sort = !empty($sort) ? ' ORDER BY '.$sort : '';
225.
226.
$res = $this->query('SELECT '. $fields . $sql . $sort . ' LIMIT 1', $conditions["_bindParams"]);
return !empty($res) ? array_pop($res) : false;
227.
}
228.
229.
public function update($conditions, $row)
230.
{
- /www/wwwroot/sqzhongming.com/protected/controller/news_controller.php on line 32
27.
28.
public function action_view()
29.
{
30.
$id = (int)request('id', 0);
31.
$article_model = new article_model();
32.
33.
if($news = $article_model->find(array('id' => $id)))
{
34.
35.
$this->cate_list = vcache::instance()->article_cate_model('indexed_list');
36.
foreach($this->cate_list as $v){
37.
if($v['cate_id']==$news['cate_id']) $this->cate = $v;
- /www/wwwroot/sqzhongming.com/protected/include/core.php on line 94
89.
$action_name = 'action_'.$__action;
90.
if(!class_exists($controller_name, true)) {header('location:/404.html');exit();}
91.
$controller_obj = new $controller_name();
92.
if(!method_exists($controller_obj, $action_name)) err("Err: Method '$action_name' of '$controller_name' is not exists!");
93.
94.
95.
$controller_obj->$action_name();
96.
function url($c = 'main', $a = 'index', $param = array())
97.
{
98.
if(is_array($c))
99.
{
- /www/wwwroot/sqzhongming.com/index.php on line 5
1.
<?php
2.
define('APP_DIR', realpath('./'));
3.
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
4.
define('INCL_DIR', APP_DIR.DS.'protected'.DS.'include');
5.
require(INCL_DIR.DS.'core.php');