Welcome Guest, Not a member yet? Register   Sign In
Using Maria/MySQL Internal Time Functions in the Builder Class?
#4

(09-08-2020, 03:40 PM)stlake2011 Wrote: Hi guys, 

Quick question, minor problem (I think)!

I am trying to update a 'DateTime' column in MariaDB/MySQL using the builder class but I keep getting this error:

Call to undefined function App\Models\now()  

I tried setting the update column using the following methods:

Method 1:

PHP Code:
$UpdateData = [
    'title' => $title,
    'slug' => $slug,
    'updated' => NOW(),
    'post' => $post
];
        
$builder
->where('slug',$slug);

$builder->update($UpdateData); 

Method 2:

PHP Code:
$builder->set('updated=NOW()');
$builder->where('slug',$slug);

$builder->update($UpdateData); 

Method 3: 

PHP Code:
$builder->set('updated',NOW());
$builder->where('slug',$slug);

$builder->update($UpdateData); 


Is there something I am missing here? Or is it impossible to work with Maria/MySQL's internal functions using the Builder Class?

No biggie if its impossible, as I can always resort to PHP Date/Time functions and have PHP do the work instead of MariaDB doing it. 
So this is more of a curiosity question as well as a serious one. 

How about

PHP Code:
$builder->set('updated''NOW()'false);
$builder->where('slug',$slug);

$builder->update($UpdateData); 
Reply


Messages In This Thread
RE: Using Maria/MySQL Internal Time Functions in the Builder Class? - by nfaiz - 09-09-2020, 09:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB