dcblogdev / pdo-wrapper

PDO wrapper for MySQL
MIT License
110 stars 42 forks source link

search function example code #25

Open mucahidbaris opened 6 days ago

mucahidbaris commented 6 days ago

` /**

Errors may exist, but it serves my purpose. I would like to suggest adding the search function to the class. Thank you

mucahidbaris commented 6 days ago

codeimg-facebook-shared-link

ismailaatif commented 6 days ago

SUGGESTION

Instead of calling it search, make it a select and the args would be (string $table, array $where = []) and improve on the where such that you can use operators as well. And so you would have a more generic method.

example:


$db->select('users', [

    // simple = operator
    ['created_at' => date('Y-m-d')],

    // custom operator with nested assoc array
    ['created_at' => ['>=' => date('Y-m-d')]],

    // or it can like this
    ['created_at', '>=', date('Y-m-d')],
]);