Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By lzande on
I need help converting the following MySQL code to a Drupal 7 API call.
select count(*) from cugoslide where cugoslide_status = 'A'
AND sysdate() >= cugoslide_begin_date
AND sysdate() <= cugoslide_end_date
I got this working by doing the following:
$sql = db_query("select * from cugoslide where cugoslide_status = 'A'
AND sysdate() >= cugoslide_begin_date
AND sysdate() <= cugoslide_end_date");
$result = db_query($sql)->rowCount();
Hope this helps someone later.
Comments
Other way
You can also use the combination of db_select() and db_and() to acheive the output.
Here is the api for db_and().