1

I like to use a column in Zend both in the Where clause as well as the Order:

$select = $this->select();
$select = $select->where('year = ?', $year)
                 ->where('order != ?', 0)
                 ->order('order');
$rows = $this->fetchAll($select);

But when I do this, I get the following error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order != 0) ORDER BY order ASC' at line 1

Why??!

1
  • When you remove the ->order()-call, does it work? Commented Feb 28, 2013 at 22:34

1 Answer 1

3

You must put the column name order into ticks since it is a reserved word of SQL syntax. Even better never name your columns like keywords in SQL, so rename your column order to something else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.