Thursday 24 May 2007 6:22:33 am
Revisiting an old post. The problem is that what I'm working with is an external system using its own database mechanisms and calls. So Lukasz Serwatka's solution above is not feasible without rewriting parts of the other system. When the external code calls
mysql_close();
this seems to disrupt eZ publish. I thought I solved it using
mysql_select_db('ezdatabase');
after the other code. However, when the external code is called more than once for a template, this also fails. So now, based on rereading the discussion above, I've worked out the following sollution:
$dsn = array(
'server' => $GLOBALS['eZDBGlobalInstance']->Server,
'user' => $GLOBALS['eZDBGlobalInstance']->User,
'password' => $GLOBALS['eZDBGlobalInstance']->Password,
'database' => $GLOBALS['eZDBGlobalInstance']->DB,
'show_errors' => $GLOBALS['eZDBGlobalInstance']->RecordError
);
//..... other code including mysql_close(); does its thing here .....
eZDB::instance( 'ezmysql', $dsn, true );
It feels sort of hackish, and I'm not sure about using the 'RecordError' variable, but it seems to work. Any comments or suggestions for better ways of doing this?
|