如何调用"db" => array()中的'prefix'的值?

#1 小双

"db" => array(
'host' => 'localhost',
'login' => 'root',
'password' => 'root',
'database' => 'shopzc',
'prefix' => 'zc_',
),


在写sql语句读数据的时候会写表名,如果做成直接instrall安装数据的网站,一般是可以设置表前缀的,那么假如我要写这样的一句sql
 
$sql="select count(*) as total1 from zc_commodity ";


"zc_"是表达前缀,如果要调用"db" => array()中的'prefix'的值改怎么写那句sql呢?

2010-07-22 16:44:39

#2 小双

不知道老大明白我的意思吗?
类似:
$prefix = "zc_";
$sql="select count(*) as total1 from ".$prefix ."commodity ";

2010-07-22 18:19:11

#3 jake

$prefix = $GLOBALS['G_SP']['db']['prefix'];

你可以试试dump出$GLOBALS看看就明白了。

2010-07-22 20:57:51