Reputation: 161
I have mystical error with MySQL query. I'm using CI php-framework. This is my function in controller:
public function editParam($id_article_params='')
{
if(IS_AJAX)
{
$this->load->model('Article_params_model','article_params');
$this->article_params->updateSizeById($id_article_params,$_GET['size']);
}
}
Article_params model:
class Article_params_model extends CI_Model
{
public function updateSizeById($id_article_params,$size)
{
$this->db->query("UPDATE article_params SET size='".$size."' WHERE id_article_params='".$id_article_params."'");
}
}
I'm trying to get error but error not isset. For example, next function also in Article_params_model but work!
public function all()
{
return $this->db->query("SELECT * FROM article_params");
}
Upvotes: 0
Views: 71
Reputation: 9
class Article_params_model extends CI_Model
{
public function updateSizeById($id_article_params,$size)
{
$this->db->where('id_article_params', $id_article_params);
$this->db->update('article_params', $size);
}
}
Upvotes: -1
Reputation: 578
In Article_params model put below code.
class Article_params_model extends CI_Model
{
public function updateSizeById($id_article_params,$size)
{
$this->db->where('id_article_params', $id_article_params);
$this->db->update('article_params', $size);
}
}
Upvotes: 2