Call to a member function insert() on string - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Call to a member function insert() on string (/showthread.php?tid=87458) |
Call to a member function insert() on string - byoosdigital - 04-21-2023 good evening CI4 coders I get this error when running the line $success = $builder->insert($data); I'm looking on the formulas but with no real success can you help me? This array $data into model: array(7) {"agent_string"]=> string(70) "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" ["ip"]=> string(9) "127.0.0.1" ["agent_type"]=> string(7) "Browser" ["agent_name"]=> string(7) "Firefox" ["agent_version"]=> string(5) "109. 0" ["referrer"]=> string(94) "http://localhost/1__codeigniter_dev/1__2023/ci4_opensourceospos/ci4_erponline_new/public/login" ["uri"]=> string(93) "http://localhost/1__codeigniter_dev/1__2023/ci4_opensourceospos/ci4_erponline_new/public/home" } the model <?php namespace App\Models; use CodeIgniter\Model; use CodeIgniter\Database\ResultInterface; class Analytics_model extends Model { public function __construct() { $this->db = \Config\Database::connect(); } public function saveUserInfo(){ $success = FALSE; $this->db->transStart(); $data['agent_string'] = ''; .... $builder = $this->db->prefixTable($this->table); //var_dump( $data );die;//BYOOS_tag $success = $builder->insert($data); $this->db->transComplete(); $success &= $this->db->transStatus(); return $success; } Thanks you Gabriel RE: Call to a member function insert() on string - kenjis - 04-21-2023 See https://www.codeigniter.com/user_guide/database/queries.html#db-prefixtable I recommend you read https://www.codeigniter.com/user_guide/models/model.html |