Hector, what is your use case? I've thought about this a couple of
times, and I wonder if having a null adapter as part of the
Zend_Db_Adapter would make sense for some use cases.
The thing you have to consider is that several adapters do differnet
things when it comes to how they quote identifiers, values, and so on.
Also when it comes to creating a limit query.
One of your best options is to just create an adapter on your own that
you can proxy to with your select object that you are interacting with.
In this case, like Benjamin said, you could start with the adapter
inside Zend_Test_DbAdatper and customize it with vendor-specific db
query information as needed.
-ralph
Hector Virgen wrote:
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]
<mailto:[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