6

I have this query:

$this->db->select("
    IF(predicts.predict_owner = votes.vote_user_id , IF(judges.judge_did_accept = 1 , True , False) , 'NotExists' )" , 'user_judgement');

I get syntax error on

  `'NotExists'` )

If I run the query directly inside the database, it works fine...
Is there any way to prevent CI to add the sign ` automatically?

Thanks

1
  • What are you passing there as a second parameter? Commented Aug 19, 2011 at 16:19

1 Answer 1

21

You can call the select method with FALSE as the last parameter, like this

$this->db->select("IF(predicts.predict_owner = votes.vote_user_id , IF(judges.judge_did_accept = 1 , True , False) , 'NotExists' ),'user_judgement'",false);

That will prevent CI to add the `

From User Guide

$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.

PS: I see you call select with the second param as "user_judgement", I'm not sure what that should be doing, it's not the cay CI wants you to use Active Record

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.