Problems
Hi,
Can someone please recreate this script and see if it produces the same results. I cannot use the same db connection for multiple queries.
Thanks
** SQL
CREATE TABLE `test` (
`test_id` int(11) NOT NULL,
`name` text,
PRIMARY KEY (`test_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into `test`(`test_id`,`name`) values (1,'test 1'),(2,'test3'),(3,'test4'),(4,'testx');
** OOP code
require_once 'Zend/Db/Adapter/Mysqli.php';
$db = new Zend_Db_Adapter_Mysqli(array(
'host' => 'localhost',
'username' => 'us',
'password' => 'pw',
'dbname' => 'db'
));
class searchAll{
function __construct($dbIn){
$this->db = $dbIn;
}
private function allowedImages($cid){
$db = $this->db;
$sql = "Select * from test where test_id='$cid'";
return $db->fetchAll($sql);
}
public function imageSearch(){
$db = $this->db;
$search = $db->query("Select * from test");
while ($row = $search->fetch())
{
$cid = $row['test_id'];
echo print_r($this->allowedImages($cid));
echo "<hr>";
}
}
}
$test = new searchAll($db); // this should therefore output 4 rows of arrays
$test->imageSearch();
|