How to use established db connection $dbinstance
Posted: Thu Apr 06, 2006 4:38 pm
If I am writing user tags that use a query is there a way to use the connection that is established by CMSMS, which I believe is $dbinstance?
Here's what I tried (not really expecting it to work--and it didn't) but you'll get the idea of what I'm trying to do. (I know how to get the parent id from the globals array, I'm just using that as a test scenario here):
Here's what I tried (not really expecting it to work--and it didn't) but you'll get the idea of what I'm trying to do. (I know how to get the parent id from the globals array, I'm just using that as a test scenario here):
Code: Select all
global $gCms, $dbinstance;
$alias = $gCms->variables['page'];
///Get the info for the current page
$query = "SELECT parent_id FROM cms_content WHERE content_alias = '$alias'";
$result = mysql_query($query,$dbinstance);
$content = mysql_fetch_assoc($result);
$parent_id = $content['parent_id'];
echo "Parent id: ".$parent_id;