DB wildcards

From: Date: Sat, 14 May 2005 05:53:34 +0000
Subject: DB wildcards
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19209@lists.php.net to get a copy of this message
I can't seem to get wild cards (?) to work right, the below code returns nothing from the database. But if I change the first ? to last_name like: $q = $db->getAll('SELECT * FROM patients WHERE last_name LIKE ?', array($last_name)); it works fine, but when I change the field type to ? and try to pull the value in from a variable or $_POST I get nothing. I've just looked through three books and searched google but can't find an answer. Help please. Dan. <?php include 'DB.php'; $db = DB::connect('pgsql://foo:bar@localhost/foodb'); if (DB::isError($db)) { die("Can't connect to the database:" . $db->getMessage()); } $db->setErrorHandling(PEAR_ERROR_DIE); $db->setFetchMode(DB_FETCHMODE_OBJECT); $last_name = 'Brow'; $field = 'last_name'; $q = $db->getAll('SELECT * FROM patients WHERE ? LIKE ?', array($field, $last_name)); $error = $db->getMessage($q); print_r($q) ?>

« previous php.pear.general (#19209) next »