Thursday, May 3, 2012

retrieving-your-data.html: DboSource::fetchAll()

At the end of http://book.cakephp.org/2.0/en/models/retrieving-your-data.html are some examples of the use
of DboSource::fetchAll() :

$db
= $this->getDataSource();
$db->fetchAll(      'SELECT * from users where username = ? AND password = ?',      array('jhon', '12345')  );
$db->fetchAll( 'SELECT * from users where username = :username AND password = :password', array('username' => 'jhon','password' => '12345') );

I can't imagine how the first use of fetchAll() is supposed to work, but surely the second is supposed to read:

$db->fetchAll(
String::insert(
'SELECT * from users where username = :username AND password = :password', array('username' => 'jhon','password' => '12345')
)
);

Is there some magic whereby the call to String::insert() can be omitted and yet the substitutions happen anyway?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: