Giter Club home page Giter Club logo

Comments (5)

eugenezadorin avatar eugenezadorin commented on July 23, 2024

Hi. Could you please provide me some more details about your specific case?

Do you mean search by substring? Or this is about filtering rows by cell without knowing exact value of this cell?

Currently query builder has no methods to make such query in handy way, but you always can use raw formula.

If we talking about searching by substring, it can look something like that:

// find records where My Column value starts with foo
$query->whereRaw("REGEX_MATCH({My Column}, '^foo')");

You can also use values from other cells in your formula:

// find records where My Column contains value from Other Column
$query->whereRaw("REGEX_MATCH({My Column},('' & {Other Column} & ''))");

from airtable-php.

awesome1128 avatar awesome1128 commented on July 23, 2024

from airtable-php.

eugenezadorin avatar eugenezadorin commented on July 23, 2024

Sure, raw formula will work for you. Assume you look for users with name containing substring "Ivan". There are few options:

$query->whereRaw("REGEX_MATCH({Username}, 'Ivan')"); // case-sensitive, any place in cell

$query->whereRaw("REGEX_MATCH({Username}, '^Ivan')"); // case-sensitive, cell value must start with Ivan

$query->whereRaw("REGEX_MATCH({Username}, '(?i)Ivan')"); // case-insensitive, any place in cell

You can read more about regexp syntax here.

I think I could provide some convenient query builder methods for this later. Something like that:

$query->whereLike("Username", "Ivan");
$query->where("Username", "like", "Ivan%");
$query->whereMatch("Username", "(?i)ivan");

from airtable-php.

awesome1128 avatar awesome1128 commented on July 23, 2024

from airtable-php.

eugenezadorin avatar eugenezadorin commented on July 23, 2024

Implemented in v0.3.0

Few examples:

// look for emails, matching @gmail.com in case-insensitive way
$query->where('email', 'match', '(?i)^(.+)@gmail.com$');

// look for names, which starts with Ivan (case-sensitive!)
$query->where('name', 'like', 'Ivan%');

from airtable-php.

Related Issues (7)

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.