PEAR::MDB2
| From: | Damian Bursztyn | Date: | Tue, 21 Nov 2006 20:00:08 +0000 |
| Subject: | PEAR::MDB2 | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25898@lists.php.net to get a copy of this message | ||
Hi, im trying to work with MDB2 and hace some problems. Maybe someone can
help me.
First, once i have a mdb2 connection on $mdb2 im trying to make a query
using quote to prevent SQL Injections.
$int = $mdb2->quote('11', 'integer');
$query = 'SELECT someDate, someNumber FROM myTable WHERE someInteger = ' .
$int;
var_dump($query);
$result = $mdb2->exec($query, array('date', 'integer'));
I suppouse that $query should be something like SELECT someDate, someNumber
FROM myTable WHERE someInteger = 11 or maybe SELECT someDate, someNumber
FROM myTable WHERE someInteger = '11' (i preffer this one, can i choose to
put or not the quotes?)
But instead of that the var_dump of query give me something like SELECT
someDate, someNumber FROM myTable WHERE someInteger = Object id #2
How can i fix this?
Because when i make $result = $mdb2->exec($query); an error takes place.
Second, can i use prepare for select querys? i saw that the result object of
prepare only have exec method. If i want to make a query with parameters (in
the where condition) and i want to set types to that parameters. And i want
to work my input data to prevent SQL injections and blind the variable
(after filter it) the the parameter in the query wich is the best way?
I was try to do the prepare with the types and then blinds the variables but
i dont know if this makes the quote using the parameter type or not.
Thanks for your help.