eugenezadorin / airtable-php

Simple PHP client for Airtable API
20 stars 7 forks source link

There is a critical issue in your code. #1

Closed awesome1128 closed 2 years ago

awesome1128 commented 2 years ago

How are you? Nice to meet you. I found a critical issue in your code. You mentioned only >, !=, =, <, and so on in Query builder. But for example, if I want to find data that contains a specific string from A column, then how can I build a Query? Please let me know. Thanks.

eugenezadorin commented 2 years ago

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} & ''))");
awesome1128 commented 2 years ago

Thank you for your kind reply. I really appreciate it. Yes, I wanted to find a record where column contains a substring. But I think, this will be working the one you gave me. Will it be working for my condition? Please let me know. Thanks. Regards

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} & ''))");

On Mon, Feb 7, 2022 at 5:16 PM Eugene Zadorin @.***> wrote:

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} & ''))");

— Reply to this email directly, view it on GitHub https://github.com/eugenezadorin/airtable-php/issues/1#issuecomment-1031237239, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANN5YMKSE27BIURIWIULCCTUZ6EVTANCNFSM5NUHJ2HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

eugenezadorin commented 2 years ago

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");
awesome1128 commented 2 years ago

It sounds good! Yes, if you provide some convenient query builder methods , then it will be great! I really love to use your code. Ill be waiting for your updates. Thank you so much.

On Tue, Feb 8, 2022 at 3:50 AM Eugene Zadorin @.***> wrote:

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 https://github.com/google/re2/wiki/Syntax.

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");

— Reply to this email directly, view it on GitHub https://github.com/eugenezadorin/airtable-php/issues/1#issuecomment-1031854381, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANN5YMKI5CHBVOY5PAF4LIDU2AO7HANCNFSM5NUHJ2HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

eugenezadorin commented 2 years ago

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%');