MVC Error

I have a page on my website, that is built on MVC Zend Framework.  I am getting an error message and I am not sure what it means.  The following is the error message.  Can anyone shed any light on what might be the issue?

 Message: 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 BY `date_entered` DESC, `t_id` DESC' at line 1
Stack trace:
#0 /usr/local/lib/php/Zend/Db/Statement.php(320): Zend_Db_Statement_Pdo->_execute(Array) #1 /usr/local/lib/php/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) #2 /usr/local/lib/php/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #3 /usr/local/lib/php/Zend/Db/Table/Abstract.php(1516): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #4 /usr/local/lib/php/Zend/Db/Table/Abstract.php(1332): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #5 /home/mrstaxin/public_html/dev/library/Stax/User/Regional.php(198): Zend_Db_Table_Abstract->fetchAll(Object(Zend_Db_Table_Select)) #6 /home/mrstaxin/public_html/dev/application/controllers/ReportsController.php(46): Stax_User_Regional->getInvoiceReports('', NULL) #7 /usr/local/lib/php/Zend/Controller/Action.php(513): ReportsController->invoicesAction() #8 /usr/local/lib/php/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('invoicesAction') #9 /usr/local/lib/php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #10 /usr/local/lib/php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #11 /usr/local/lib/php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #12 /home/mrstaxin/public_html/dev/index.php(37): Zend_Application->run() #13 {main} 

Open in new window


This is the code that I think it is refering to:
	public function getInvoiceReports($where = null, $order = "date_entered DESC")
	{
		if (is_null($order)) {
			$order = "date_entered DESC";
		}
		$invoices = new Db_Invoices();
		$sel = $invoices->select();
		$sel->where('user_id IN (?)', new Zend_Db_Expr($this->managedUsers(true)))
			->order(array(trim($order), 't_id DESC'));

		if ($where) {
			$sel->where($where);
		}


		return $invoices->fetchAll($sel);
	}

Open in new window

LVL 8
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Terry WoodsIT GuruCommented:
The problem may originate in the value of $where. Can you find out what that is, and post it if you can't see the problem? Perhaps there are non-matching round brackets?

It may also be helpful to output the SQL somehow. I use CodeIgniter rather than Zend so I don't know how to do this, but there should be a way.
0
Ray PaseurCommented:
There is a syntax error in the query.  I think you're in the right place tracking it down.  The generated SQL string ends in this.  I'm not sure I can see the error there.

ORDER BY `date_entered` DESC, `t_id` DESC' at line 1

You might want to add var_dump($invoices) at line 15, before the return.  Then you can probably see the entire query string.
0
GaryCommented:
The double bracket in the error would be a bit suspicious

right syntax to use near ')) ORDER BY `date_entered
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.