0

I want generate following query.

SELECT `Scale`.`id`, `Scale`.`name` 
FROM `woa`.`scales` AS `Scale` 
WHERE `Scale`.`enabled` = '1'

So i wrote following lines in cackphp controller.

$this->set('scales', $this->Scale->find('list', array(
    'conditions' => array('Scale.enabled' => '1')
)));

But it generate following query with out quotation in Scale.enabled value.

SELECT `Scale`.`id`, `Scale`.`name` 
FROM `woa`.`scales` AS `Scale` 
WHERE `Scale`.`enabled` = 1

How can i use quotations with numeric (bt actually it is string) value?

1
  • what's wrong with the executed sql? What error does it trigger? Commented May 31, 2014 at 19:17

1 Answer 1

2

CakePHP handles the quotes according to the actual column datatype. But if you really want to force quotes try this:

$this->set('scales', $this->Scale->find('list', array(
    'conditions' => array("Scale.enabled='1'")
)));
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.