Search code examples
mysqlcs-cart

CS-Cart DB placeholder for OR


What is the CS-Cart DB placeholder for sql OR ? I try search on documentation already. But there is no example for OR so. The following code is what I am try to query!

$companies =  db_get_array('SELECT * FROM ?:companies WHERE categories LIKE ?l', $first_category, 'OR LIKE ?l', $middle_category, 'OR LIKE ?l', $last_category, 'OR LIKE ?l', $category_id);

But it's doesn't work.


Solution

  • db_get_array(
        'SELECT * FROM ?:companies 
        WHERE categories LIKE ?l OR categories LIKE ?l...',
        $first,
        $second,
        ...
    );
    

    db_get_array(query with all placeholders, first parameter, second parameter, etc)

    Remember to add %s to your parameters if you're using LIKE: $first = '%foo%';