@@ -71,6 +71,8 @@ public static function evaluate(
71
71
return self ::sqlBinary ($ conn , $ scope , $ expr , $ row , $ result );
72
72
case 'FROM_UNIXTIME ' :
73
73
return self ::sqlFromUnixtime ($ conn , $ scope , $ expr , $ row , $ result );
74
+ case 'UNIX_TIMESTAMP ' :
75
+ return self ::sqlUnixTimestamp ($ conn , $ scope , $ expr , $ row , $ result );
74
76
case 'GREATEST ' :
75
77
return self ::sqlGreatest ($ conn , $ scope , $ expr , $ row , $ result );
76
78
case 'VALUES ' :
@@ -845,6 +847,32 @@ private static function sqlFromUnixtime(
845
847
return \date ('Y-m-d H:i:s ' , (int ) $ column );
846
848
}
847
849
850
+ /**
851
+ * @param array<string, mixed> $row
852
+ */
853
+ private static function sqlUnixTimestamp (
854
+ FakePdoInterface $ conn ,
855
+ Scope $ scope ,
856
+ FunctionExpression $ expr ,
857
+ array $ row ,
858
+ QueryResult $ result
859
+ ) : ?int {
860
+ $ args = $ expr ->args ;
861
+
862
+ switch (\count ($ args )) {
863
+ case 0 :
864
+ return time ();
865
+ case 1 :
866
+ $ column = Evaluator::evaluate ($ conn , $ scope , $ args [0 ], $ row , $ result );
867
+ if (!\is_string ($ column )) {
868
+ return null ;
869
+ }
870
+ return \strtotime ($ column ) ?: null ;
871
+ default :
872
+ throw new ProcessorException ("MySQL UNIX_TIMESTAPM() SQLFake only implemented for 0 or 1 argument " );
873
+ }
874
+ }
875
+
848
876
/**
849
877
* @param array<string, mixed> $row
850
878
*
0 commit comments