Welcome Guest, Not a member yet? Register   Sign In
Query build - insert NOW()
#1

How would you go about having "NOW()" in insert?

The current insert doc:
PHP Code:
$data = array(
 
       'title' => 'My title',
 
       'name' => 'My Name',
 
       'date' => 'My date'
);

$this->db->insert('mytable'$data);
// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date') 

And when wanting to insert "NOW()" for timestamp/datetime, you have to do it using PHP
PHP Code:
date("Y-m-d H:i:s"

Problem? Can be.
If the database time is different than the server time,
Or, you have multiple servers using the same DB, and can sometimes go out of sync in milliseconds (and with time in seconds) - there are sync methods, not the point
Or, latency between servers to the DB is different,
Time will not be correct. It can have very very minor artifacts.

There is a solution for updating, which is using the "Set" function.

So how would you go about that?
Reply


Messages In This Thread
Query build - insert NOW() - by AmitMY - 11-23-2016, 04:34 AM
RE: Query build - insert NOW() - by InsiteFX - 11-23-2016, 05:26 AM
RE: Query build - insert NOW() - by Narf - 11-23-2016, 06:04 AM
RE: Query build - insert NOW() - by sv3tli0 - 11-24-2016, 12:36 AM
RE: Query build - insert NOW() - by AmitMY - 11-24-2016, 01:44 AM
RE: Query build - insert NOW() - by sv3tli0 - 11-24-2016, 02:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB