0

this is model function

<?php
class change_data extends CI_Model {
    function __construct() {
        parent::__construct();
    }

    function change($id,$action)
    {
        if($action==0)
        $st=1;
        else
        $st=0;
        $data = array('gud_status' => $st);
        $where = "id=".$id; 
        $this->db->update_string('gallery', $data, $where);

        return $this->db->affected_rows();
    }

}

everything is working fine.. also getting 2 parameter values but table updation fails.. affect 0 rows!!!

any body can sort this!!

6
  • is you try your query in phpmyadmin is your query work fine? Commented May 27, 2016 at 5:25
  • yes its working fine in phpmyadmin.. is there any way to print mysql query errors in code igniter Commented May 27, 2016 at 5:30
  • use this for print query echo $this->db->last_query(); exit; Commented May 27, 2016 at 5:32
  • use this for last execute query echo $this->db->last_query();die; Commented May 27, 2016 at 5:33
  • checked but its prints nothing Commented May 27, 2016 at 5:36

1 Answer 1

1

Pass where condition in array. Ex-

function change($id,$action)
{
    if($action==0)
    $st=1;
    else
    $st=0;
    $data = array('gud_status' => $st);
    $where = array('id'=>$id); 
    $this->db->update_string('gallery', $data, $where);

    return $this->db->affected_rows();
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.