I'm building an e-commerce site with custom code and custom tables. When an user purchases an item, I need the database to insert the current date in the order table using the MySql function 'CURDATE()' as the value for the date field. Instead of inserting the current date, it only inserts 0000-00-00.
My code looks like this (excerpt):
$orderFields = array('idClient' => $_SESSION['loggedIn']['id'], 'totalAmount' => $totalAmount, 'paymentType' => 'debit card', 'orderDate' => 'CURDATE()');
$order = $modx->newObject('Order', $orderFields);
$oSave = $order->save();
Momentarily, I'm obtaining the current date with PHP and inserting it directly:
$orderDate = date('Y-n-j');
$orderFields = array('idClient' => $_SESSION['loggedIn']['id'], 'totalAmount' => $totalAmount, 'paymentType' => 'debit card', 'orderDate' => $orderDate);
But, how can I access the MySql 'CURDATE()' function from a snippet inside Modx?
For this case, it doesn't produce any difference in the result; but I guess that there are other cases in which you definitely need to use a particular MySql function.
How can I access them?
Thank you!!