Why is this string being made into an array and how do I stop it please?
Snippet: (to get date)
public function setDate(){
$this->date = date("Y-m-d");
return $date;
}
public function getDate(){
return $this->date;
}
$date = getDate();
Snippet: (part of query)
->where_equal_to(
array(
'sales_date' => $date
)
)
When you dump the query its doing this…
Output:
array(1) { ["sales_date"]=> array(11) { ["seconds"]=> int(42) ["minutes"]=> int(10) ["hours"]=> int(14) ["mday"]=> int(3) ["wday"]=> int(1) ["mon"]=> int(10) ["year"]=> int(2011) ["yday"]=> int(275) ["weekday"]=> string(6) "Monday" ["month"]=> string(7) "October" [0]=> int(1317647442) } }
instead of something like this…
Output:
array(1) { ["sales_date"]=> "2011-10-03 00:00:00" }
You’re calling the PHP function
getdate()rather than $obj->getDate(), so it’s returning an array based off of the return value from the built-in function.https://www.php.net/getdate