Thanks, Benjamin! Do you know if it will create MySQL-compatible select queries?
-- Hector On Wed, Aug 19, 2009 at 9:53 AM, Benjamin Eberlei <[email protected]>wrote: > hello hector, > > you can use Zend_Test_DbAdapter, which is a testing adapter that does not > connect to the database. > > greetings, > Benjamin > > On Wednesday 19 August 2009 06:50:52 pm Hector Virgen wrote: > > 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 > > > -- > Benjamin Eberlei > http://www.beberlei.de >
