php - Call to undefined function inval() -
i have error in my_model in codeigniter. i've looked everywhere nothing my_model:
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class my_model extends ci_model { protected $_table_name = ''; protected $_primary_key = 'id'; protected $_primary_filter = 'intval'; protected $_order_by = ''; protected $_rules = array(); protected $_timestamps = false; function __construct(){ parent::__construct(); $this->load->database(); } public function get($id = null, $single = false) { if ($id != null) { $filter = $this->_primary_filter; $id = $filter($id); $this->db->where($this->_primary_key,$id); $method = 'row'; } elseif($single == true) { $method = 'row'; } else { $method = 'result'; } if(!count($this->db->ar_orderby)) { $this->db->order_by($this->_order_by); } return $this->db->get($this->_table_name)->$method(); } public function get_by($where, $single = false) { $this->db->where($where); return $this->get(null, $single); } public function save($data, $id = null) { //set timestamp if($this->_timestamps == true) { $now = date('y-m-d h:i:s'); $id || $data['created'] = $now; $data['modified'] = $now; } //insert if ($id ===null) { !isset($data[$this->_primary_key]) || $data[$this->_primary_key] = null; $this->db->set($data); $this->db->insert($this->_table_name); $id = $this->db->insert_id(); } //update else { $filter = $this->_primary_filter; $this->db->set($data); $this->db->where($this->_primary_key,$id); $this->db->update($this->_table_name); } return $id; } public function delete($id) { $filter = $this->_primary_filter; $id = $filter($id); $this->db->where($this->_primary_key,$id); $this->db->limit(1); $this->db->delete($this->_table_name); } } ?>
and in controller call function in way:
public function delete() { $this->page_m->delete(3); }
when write:cms/page/delete...the error is:
fatal error: call undefined function inval() in c:\xampp\htdocs\application\core\my_model.php on line 75
help me please
i think problem in delete()
function
$filter = $this->_primary_filter; $id = $filter($id);
make sure receive correct id
, type
(int, bool)
Comments
Post a Comment