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

  • SEARCH
  • Home
  • 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 6737747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:17:07+00:00 2026-05-26T11:17:07+00:00

In model query – public function get_articles_from_query($squery){ $query = DB::query(Database::SELECT, ‘SELECT * FROM ieraksti

  • 0

In model query –

public function get_articles_from_query($squery){

    $query = DB::query(Database::SELECT, 'SELECT * FROM ieraksti WHERE virsraksts = "%:squery%" AND slug = "%:squery%" AND saturs = "%:squery%"')
            ->parameters(array(":squery" => $squery))->execute();
    return $query;
} 

Why this script is not working? I not have any errors, but blog articles not found.

  • 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-05-26T11:17:08+00:00Added an answer on May 26, 2026 at 11:17 am

    Well, my first question is:

    Do you have any rows that have that word, and nothing else, surrounded by % characters, in all three of the the title, content and slug (a)? This seems unlikely.

    If not, the query will return no rows.

    The use of the % wildcards is for like, not for =. If your squery word is banāns for example, your query will only match rows where all three columns are exactly the literal %banāns% value, not a value containing banāns somewhere within it.

    I think you want:

    SELECT * FROM ieraksti
        WHERE virsraksts like "%:squery%"
          AND slug       like "%:squery%"
          AND saturs     like "%:squery%"
    

    For your subsequent problem:

    I understand the problem. I put in model var_dump($query); and it shows the query – SELECT * FROM ieraksti WHERE virsraksts like "%'ar'%" OR slug like "%'ar'%" OR saturs like "%'ar'%. The is not word ‘ar’, but ar. How to remove ‘ from query?

    If that’s the case, you will have to change your query to something like:

    $query = DB::query(Database::SELECT,
        'SELECT * FROM ieraksti WHERE virsraksts like :squery AND slug ...')
            ->parameters(array(":squery" => "%$squery%"))->execute();
    

    In other words, move the attachment of the % characters to the parameter specification, not the query itself. From your debug, the parameters are automatically having single quotes wrapped around them so, if you want to do anything inside those quotes, you have to do it before the wrapping.

    And you obviously don’t need the double quotes in this case because that wrapping is taking place.

    And check that line with "%$squery%" in it, I’m not sure it’s the right syntax. I’d say my PHP was a bit rusty but, to be honest, I’ve only ever used it for about seven minutes in my whole life 🙂

    What you’re aiming for is a string consisting of %, the value of $squery and another %.


    (a) Man tiešām patīk, kā Google Translate padara mani izskatās es zinu desmitiem dažādās valodās 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this in my BlogRepository public IQueryable<Subnus.MVC.Data.Model.Post> GetPosts() { var query = from
I have defined a function in my Navigation model that executes a query, and
I get an error message on this query query = select count(*) from pgns_game
I have the following view model to query my table: QuestionViewModel.cs public enum TypeQuestion
I am trying to make one query, to get some statistic data from database.
I run script/generate model query edit query.rb in models.. class Query < ActiveRecord::Base #I
Trying to query a 'Favorites' model to get a list of items a user
Suppose that I have the model Foo in GAE and this query: query =
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
I'm using an ADO.NET Entity Model which I'm trying to query using LINQ. The

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.