CodeIgniter Forums
Model basic CRUD methods and other queries on other tables using $this->db->table() - 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: Model basic CRUD methods and other queries on other tables using $this->db->table() (/showthread.php?tid=86860)

Pages: 1 2


RE: Model basic CRUD methods and other queries on other tables using $this->db->table() - kenjis - 02-22-2023

There is no data to update" means the model thinks there is no data to update.
If you read the stacktrace and the model code, you can find why there is no data.


RE: Model basic CRUD methods and other queries on other tables using $this->db->table() - serialkiller - 02-22-2023

(02-22-2023, 05:16 AM)kenjis Wrote: There is no data to update" means the model thinks there is no data to update.
If you read the stacktrace and the model code, you can find why there is no data.
I have to transform this


PHP Code:
$this->where('id', (int)$id_sottoevento)
    ->update(
        [
          'data_inizio' => '0000-00-00',
          'data_fine'  => '0000-00-00'
        ]
    ); 

in this


PHP Code:
$this->save(
    [
      'id'          => $id_sottoevento,
      'data_inizio' => '0000-00-00',
      'data_fine'   => '0000-00-00'
    ]
); 

so it works


If instead I want to use update() and not save()


PHP Code:
$this->update(
    $id_sottoevento
    [
      'data_inizio' => '0000-00-00',
      'data_fine'  => '0000-00-00'
    ]
); 

I haven't tested this but it should work


But I still don't understand why the first version doesn't work, it will be my limitation