-1
我有表config
contian config_name
| config_value
知道我要提取它 像php array任何mysql问题
`config_name` | `config_value`
`articles_limit` | `10`
现在我想的PHP代码给我像一个数组 articles_limit => 10
我有表config
contian config_name
| config_value
知道我要提取它 像php array任何mysql问题
`config_name` | `config_value`
`articles_limit` | `10`
现在我想的PHP代码给我像一个数组 articles_limit => 10
你可能会喜欢使用一个数据库包装像ADODb尝试,其中,这样的事情,简直是
$config=$db->GetAssoc('select config_name, config_value from config');
为纯PHP,这将是这样的
$config=array();
$result = mysql_query('select config_name, config_value from config');
if (!$result)
{
//handle error
die(mysql_error());
}
else
{
while ($row = mysql_fetch_assoc($result))
{
$config[$row['config_name']] = $row['config_value'];
}
mysql_free_result($result);
}
不,我不会用它请告诉我用的方式 – 2010-07-10 21:17:28
以及通常的方式是使用包装而不是写所有的! – 2010-07-10 21:21:20
新程序应该使用mysqli扩展。 – Artefacto 2010-07-10 21:54:21