Hello,
I am currently working on an older project that is not in ZF, but I'd like
to use Zend_Db_Select to help me build some complex select queries. I don't
want to open a new connection to the database since this application already
has one open using good ol' mysql_connect().

My question is, since Zend_Db uses lazy-loading to create the actual
connection, would it be safe to create a "dummy" Zend_Db object to build my
selects with?

$db = Zend_Db::factory('Pdo_Mysql', array(
    'host' => '127.0.0.1',
    'username' => 'fakeuser',
    'password' => 'fakepassword',
    'dbname' => 'mydefaultdb'
));

$select = $db->select()
->from('users');

$sql = $select->toString();
*echo $sql; // this works and outputs SELECT * FROM `users`*

$select = $db->select()
->from('users')
*->where('username = ?', 'test'); // throws exception: SQLSTATE[HY000]
[2013] Lost connection to MySQL server at 'reading initial communication
packet', system error: 111*
It seems that quoteInto() is attempting to connect to the database. Is this
necessary? Is there a way to stub in a fake database connection in order to
use Zend_Db_Select?

--
Hector

Reply via email to