no commit message
This commit is contained in:
@@ -30,9 +30,18 @@ $sender_io->on('connection', function($socket) use (&$push_value){
|
|||||||
|
|
||||||
// 连接时自动推送最新的未回价数量
|
// 连接时自动推送最新的未回价数量
|
||||||
try {
|
try {
|
||||||
|
// 从ThinkPHP数据库配置文件读取数据库连接信息
|
||||||
|
$db_config = require __DIR__ . '/config/database.php';
|
||||||
|
$db_host = isset($db_config['hostname']) ? $db_config['hostname'] : 'localhost';
|
||||||
|
$db_name = isset($db_config['database']) ? $db_config['database'] : 'pgserver';
|
||||||
|
$db_user = isset($db_config['username']) ? $db_config['username'] : 'root';
|
||||||
|
$db_pass = isset($db_config['password']) ? $db_config['password'] : '';
|
||||||
|
$db_port = isset($db_config['hostport']) ? $db_config['hostport'] : '3306';
|
||||||
|
$db_charset = isset($db_config['charset']) ? $db_config['charset'] : 'utf8';
|
||||||
|
|
||||||
// 使用PDO连接数据库查询最新数量
|
// 使用PDO连接数据库查询最新数量
|
||||||
$dsn = 'mysql:host=localhost;dbname=pgserver;charset=utf8';
|
$dsn = "mysql:host=$db_host;port=$db_port;dbname=$db_name;charset=$db_charset";
|
||||||
$pdo = new PDO($dsn, 'root', '');
|
$pdo = new PDO($dsn, $db_user, $db_pass);
|
||||||
$stmt = $pdo->query('SELECT COUNT(*) as count FROM pg_inquiry WHERE return_price_status = 2');
|
$stmt = $pdo->query('SELECT COUNT(*) as count FROM pg_inquiry WHERE return_price_status = 2');
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$count = $result['count'] ?? 0;
|
$count = $result['count'] ?? 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user