I was running a MySQL database but from now I need more stuff... So I
decided to install a PostgreSQL database on my development
environment. I added a [pgsql] section in my config.ini file...
Anyway, when I try to launch the index of my website, I get a SQL
syntax error with the following query :
SELECT *
FROM "user" AS "us"
INNER JOIN "is" ON us.user_id = is.user_id
INNER JOIN "role" AS "ro" ON is.role_id = ro.role_id
WHERE (ro.role_type <> 2 AND ro.role_type <> 1)
ORDER BY "user_date" DESC
This query is generated by my model class 'User' with the following method:
public function getLastRegistered()
{
$select = $this->select();
$select->setIntegrityCheck(false)
->from(array('us' => 'user'))
->join('is', 'us.user_id = is.user_id')
->join(array('ro' => 'role'), 'is.role_id = ro.role_id')
->where('ro.role_type <> '.ROLE_TYPE_INACTIVE.' AND ro.role_type
<> '.ROLE_TYPE_BANNED)
->order('user_date DESC')
->limit(0, 10);
return ($this->fetchAll($select)->toArray());
}
I have to add double-quotes (") around every alias and field names by
myself? I hope no and maybe Zend_Db has a "magic" function to do that
work? Cause, as you know, following the database engine, you have to
insert double-quotes (") or back-quote (`)...
Thank you for your help!
--
Thomas VEQUAUD http://thomas.vequaud.free.fr/
Ingénieur Systèmes pour le compte d' ITS GROUP
Bénévole et secouriste à la Croix-Rouge Française
没有评论:
发表评论