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 kunalkursija on
Hello,
I have a table called "drupal_timestamps" with column "timestamp". Structure is as mentioned below.
Timestamp
12345567671
12345567672
12345567673
12345567674
12345567675
12345567676
Requirement : I have to,
Select from drupal_timestamps where timestamp if of any monday of calender. And it needs to be done with DB_SELECT ONLY.
p.s : Fetching from DB table should produce result and no external PHP code to be used after fetching record from DB.
Kindly Help !
Comments
SELECT DAYOFWEEK(FROM
SELECT * FROM drupal_timestamps WHERE DAYOFWEEK(FROM_UNIXTIME(timestamp)) = 2;
DAYOFWEEK gives a number from 1 to 7 where 1 = Sunday.
Nice!
Here is how you can use it in a db_select()-returned object.
What's new and changing in PHP 8
Thanks Guys.
Hi Rob & Ayesh,
I Just quickly tried in devel PHP on users table & That did solve my problem, Thank you :) . This is what i tried...
@ayesh :
But i did not understood what
is..
Is that some sort of alias ? if yes then fetching record did not yield any thing called dayid in output.
That is the parameter. This
That is the parameter. This way, Drupal DB API can sanitize your variable (3 in this case) before running the query.
What's new and changing in PHP 8