database connection within modifier function
| From: | Peggy Schatz | Date: | Tue, 13 Feb 2007 11:10:30 +0000 |
| Subject: | database connection within modifier function | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-13683@lists.php.net to get a copy of this message | ||
Hello again ;o)
how would one relate to an existing database connection (PEAR::MDB2) within a plugin or modifier function?
The database connection is included as 'standard_db.inc.php' in 'standard.php' which finally displays the template containing the plugin.
Is there a way of directly relating to the global variable $mdb2 within a modifier-function or would I have
- to fetch 'standard_db.inc.php',
- define $mdb2 as constant (using $smarty.const),
- use config file,
- assign it to smarty or even
- open a new database connection?
in modifier.get_supplier.php:
function smarty_modifier_get_supplier($params)
{
...
$supplier = & $mdb2->queryCol($req);
...
}
Thanks in advance,
Peggy