CodeIgniter Forums
updated_at is not updating - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: updated_at is not updating (/showthread.php?tid=79932)

Pages: 1 2


RE: updated_at is not updating - InsiteFX - 08-20-2021

If you all take and look at the BaseModel insert and update methods, you will see how it's done.

PHP Code:
// BaseModel Class

protected $useTimestamps true;  // if you look at the methods this has to be set to true

// The fields have to be in the database table.

-- insert method

if ($this->useTimestamps && $this->createdField && ! array_key_exists($this->createdField$data)) {
    $data[$this->createdField] = $date;
}

if (
$this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField$data)) {
    $data[$this->updatedField] = $date;
}

-- 
update method

if ($this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField$data)) {
    $data[$this->updatedField] = $this->setDate();



Hope that this sheds some light on this.


RE: updated_at is not updating - paliz - 08-20-2021

Go to your model
protected $useTimestamps = true;

To
protected $useTimestamps = false;