how to make variables in pre_controller hooks global to all controllers?
Posted
by ajsie
on Stack Overflow
See other posts from Stack Overflow
or by ajsie
Published on 2010-04-17T14:38:26Z
Indexed on
2010/04/17
14:43 UTC
Read the original article
Hit count: 219
codeigniter
|php
in my pre_controller hook i have this code for doctrine:
$manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection($db[$active_group][‘dsn’]);
then in my controller i have this code to use doctrine connection i’ve created:
$conn->export->createTable(‘test’, array(‘name’ => array(‘type’ => ‘string’))); $conn->execute(‘INSERT INTO test (name) VALUES (?)’, array(‘jwage’));
but $conn is undefined so it wont work. if i put the code in the pre_controller hook it will work.
how can i make variables i declare in hooks available for all controllers so that i dont have to create a new connection all the time?
© Stack Overflow or respective owner