我正在使用一个不断使用db_query
从PHP代码查询MySQL服务器的框架。我有点担心它如何打开和关闭连接,以及它是否会对命中服务器的连接总数产生影响。代码如下:
$sql = "select r.project_id from user_rights r where username = '".db_escape(USERID)."'";
$q = db_query($sql);
$count_i = 0;
while ($row = db_fetch_assoc($q))
{
$ids[$count_i] = $row;
$count_i++;
}
$list = '';
foreach ($ids as $id) {
$list .= 'r.project_id = "'.$id['project_id'].'" or ';
}
return substr($list,0,-3);