Welcome Guest, Not a member yet? Register   Sign In
$this->db->escape() vs $this->db->escape_str()
#1

[eluser]Evollution[/eluser]
i dont understand when i shoud use $this->db->escape_str() and when $this->db->escape() what is the diffrence ?
#2

[eluser]Evollution[/eluser]
for example my controller

Code:
function create(){
        $this->load->library('form_validation');
        // field name, error message, validation rules
        $this->form_validation->set_rules('name', 'Title', 'trim|required|min_length[4]|xss_clean');
        $this->form_validation->set_rules('autoplayon', 'Autoplay ON', 'trim|required');
        $this->form_validation->set_rules('autoplayoff', 'Autoplay OFF', 'trim|required');
        if($this->form_validation->run() == FALSE)
        {
            $this->load->view('admin/add');
        }
        else
        {            
            $data = array(
            'name' => $this->input->post('name'),
            'slug' => url_title($this->input->post('name'),'dash', TRUE),
            'autoplayon' => $this->input->post('autoplayon'),
            'autoplayoff' => $this->input->post('autoplayoff'),
            'autor' => $this->MyBBI->mybb->user['username']
            );
        
        $this->radio_m->add_record($data);
        $this->index();
        }

and my model

Code:
function add_record($data){
        // insert
       $this->db->insert('radio', $this->db->escape($data));
        $return;

I done it corectly ?
#3

[eluser]guidorossi[/eluser]
You don't need to escape the data if you're using Active Record because "All values are escaped automatically producing safer queries."

http://ellislab.com/codeigniter/user-gui...tml#insert




Theme © iAndrew 2016 - Forum software by © MyBB