Answer the question
In order to leave comments, you need to log in
What is wrong in the query (Yii 1)?
Hello, help me with solving the problem, I have a query to the database (I'm doing it in Yii 1 )
$model = Yii::app()->db->createCommand()->select('id, module_id, key, value')-> from('settings')->
where('module_id=:module_id and key=:key', array(':module_id' => $module_id,
':key' => $key_type))->queryRow();
the query should take the value from the base in the value column with a selection of 2 parameters that are passed in the $module_id, $key_type variables, but my problem is that an error occurs
CDbCommand failed to execute SQL query: 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 'key='wooUrl'' at line 3. The SQL statement executed was: SELECT `id`, `module_id`, `key`, `value`
FROM `settings`
WHERE module_id=:module_id and key=:key
I can't understand why, how would everything be right or am I blind, please help me poke your finger.
Answer the question
In order to leave comments, you need to log in
I don’t remember yii1 already, but in my opinion it’s like this:
$user = Yii::app()->db->createCommand()
->select('id, module_id, key, value')
->from('settings')
->where('module_id=:module_id', array(':module_id' => $module_id))
->andWhere('key=:key', array(':key' => $key_type))
->queryRow();
$user = Yii::app()->db->createCommand()
->select('id, module_id, key, value')
->from('settings')
->where(array('module_id=:module_id','key=:key'), array(':module_id' => $module_id,
':key' => $key_type))
->queryRow();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question