Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:24:27+00:00 2026-06-18T11:24:27+00:00

The raw query I’m trying to get plugged in here is: SELECT * FROM

  • 0

The raw query I’m trying to get plugged in here is:

SELECT * FROM x WHERE CONCAT(y, ' ', x) LIKE '%value%';

I’ve checked through the AR docs and can’t find anything that would allow me to do this. I’m not very familiar with how exactly it’s constructing these queries, and was hoping someone could point me in the right direction. Thanks a bunch.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:24:28+00:00Added an answer on June 18, 2026 at 11:24 am

    If you want to use the AR class you need to pass FALSE as third parameter to avoid the query being escaped automatically. You are now left to escaping the argument by yourself:

    $value = $this->db->escape_like_str($unescaped);
    
    $this->db->from('x');
    $this->db->where("CONCAT(y, ' ', x) LIKE '%".$value."%'", NULL, FALSE);
    $result = $this->db->get();
    

    Refer to point 4) in the Active Record session of the manual. Quoting:

       Custom string:
    
       You can write your own clauses manually:
       $where = "name='Joe' AND status='boss' OR status='active'";
       $this->db->where($where);
       $this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.
       $this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);
    

    An easier way, imho, whould be to run a “regular” query and take advantage of binding:

    $result = $this->db->query("CONCAT(y, ' ', x) LIKE '%?%'", array($value));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get an error message on this query query = select count(*) from pgns_game
I've got this raw query : counters = Counter.objects.raw( SELECT id, name FROM building_counter
I am trying to make one query, to get some statistic data from database.
I'm trying to do a raw query in SQLite. I want to select all
Possible Duplicate: Get updated rows count from SQLite in Android using a raw query?
select @result=@input.query('*') for xml raw,type Above statement will generate following alert: Msg 6819, Level
I'm using a raw query and i'm having trouble finding out how to get
I've used answer from this question: Django: making raw SQL query, passing multiple/repeated params?
I have the following raw query which moves items from a shopping cart to
I want projection in mongoengine raw query , here is my query but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.