Scandal
Well-known member
Hello all!
Well, I have two question that have to do with MySQL queries on XF2.
1. Let's say on Setup.php we want to add a new column on a table:
How exact could I apply as default the CURRENT_TIMESTAMP?
It is possible to make it manually via phpmyadmin, but I need to have it ready after initial installation (Setup.php /schemamanager).
Is it possible via a "XF2 way" like ->setDefault(blahblah); or to apply a manual query on the Setup.php separately?
->setDefault('CURRENT_TIMESTAMP'); is not working.
2. I don't need this currently, but occurs during some tests:
Let's say we want to insert a new row on the table with the NOW() datetime on the relevant column.
This example will not work as XF2 query, but as a regular mysql query would be fine:
The issue it the 'NOW()' counted as incorrect. Also if a try the php unixtimestamp and wrote time(), again incorrect.
Any idea?
Well, I have two question that have to do with MySQL queries on XF2.
1. Let's say on Setup.php we want to add a new column on a table:
PHP:
$table->addColumn('datetime', 'datetime')->nullable();
It is possible to make it manually via phpmyadmin, but I need to have it ready after initial installation (Setup.php /schemamanager).
Is it possible via a "XF2 way" like ->setDefault(blahblah); or to apply a manual query on the Setup.php separately?
->setDefault('CURRENT_TIMESTAMP'); is not working.
2. I don't need this currently, but occurs during some tests:
Let's say we want to insert a new row on the table with the NOW() datetime on the relevant column.
This example will not work as XF2 query, but as a regular mysql query would be fine:
Code:
$db->insert('xf_tablename', [
'datetime' => 'NOW()',
'ipaddress' => $ipAddress]);
Any idea?