GithubHelp home page GithubHelp logo

Multiple ids about db.php HOT 2 CLOSED

tschoffelen avatar tschoffelen commented on August 16, 2024
Multiple ids

from db.php.

Comments (2)

tschoffelen avatar tschoffelen commented on August 16, 2024

That last version is indeed correct, but there are some other ways to do IN statements:

Combining query builder with manual statements

You can combine the automatic query builder with manual query parts:

$db->select('some_table',  [
	'Name' => 'Thomas',
	'Status IN (0, "AA")'
])->result_array();

Using arrays for IN syntax

But in this case you don't even need to manually write the IN part, you can just use an array as a the value:

$db->select('some_table', [
	'Name' => 'Thomas',
	'Status' => ['0', 'AA']
])->result_array();

from db.php.

PierreG89 avatar PierreG89 commented on August 16, 2024

Ok, I tested all of this.

In fact, even if with my latest method: $db->select('some_table', "Status IN (0, 'AA')")->result_array();

I get results with wrong status (ex. "BB"). So the same with your first example.

I think I understand why, 0 must be written "0" (as my column is not only numbers).

So in your last syntax, it is working great, and I'm stick with it (without the IN), thanks !

I can update readme if u want.

from db.php.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.