For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > February 2007 > database connection within modifier function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author database connection within modifier function
Peggy Schatz

2007-02-13, 8:13 am

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com