$ecs对象定义数据库和表前缀
class ECS { var $db_name = ‘‘; var $prefix = ‘ecs_‘; function ECS($db_name, $prefix) { $this->db_name = $db_name; $this->prefix = $prefix; } function table($str) { return ‘`‘ . $this->db_name . ‘`.`‘ . $this->prefix . $str . ‘`‘; }
$ecs = new ECS(test, test_cp_);
$ecs -> table(‘identity_approve‘) 组合成一个带数据库名的表名 test.test_cp_identity_approve
以前只知道查询写成
SELECT * FROM test_cp_identity_approve WHERE
原来带上数据库名和不带数据库名皆可以
SELECT * FROM test.test_cp_identity_approve WHERE
关于$GLOBALS['ecs']->table()的问题?
时间: 2024-10-11 04:33:47