My problem is, when i want to read datas from database with zend framework 1, I get the exactly same result even if i use different conditions.
My table named 'maps' contains 2 rows:
id: 1 date: date1 description: sth1 userid: 30
id: 2 date: date2 description: sth2 userid: 30
application.ini:
resources.db.params.charset = "utf8"
resources.db.adapter = pdo_mysql
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password =
resources.db.params.dbname = gallery
in my controller:
$gallery = new Gallery_Model_DbTable_Maps();
$maps = $gallery->getMaps($user_id);
$this->view->datas = array(
'maps' => $maps,
);
in my model:
class Gallery_Model_DbTable_Maps extends Zend_Db_Table_Abstract
{
protected $_name = 'maps';
public function getMaps($id){
$select = $this->select();
$select->where('userid = ?', $id);
$rows = $this->fetchAll();
return $rows->toArray();
}
}
If I replace the "$id" to something else than 30 in "Gallery_Model_DbTable_Maps" I always get the 2 rows mentioned above... If I change the function for this...
public function getMaps($id){
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$stmt = $dbAdapter->query('SELECT * FROM maps WHERE userid = 32');
$rows = $this->fetchAll()->toArray();
return $rows;
}
...the problem still occurs, and get the same result. But if i run the query in the phpmyadmin, everything is fine
And one additional think(maybe help to find out what is the problem), if i use joins, the joined table datas doesn't appear in the result(in zf structure), but if i run this query(containing join) in phpmyadmin, everything is fine.