Welcome Guest, Not a member yet? Register   Sign In
What's wrong with mysql reset auto increment in codeigniter?
#1

Hi, I'm a newbie in codeigniter. So far, I've tried to reset auto increment field in mysql using codeigniter. 

Code:
// Location: rb_model.php
function reset_ai() {
   $sql = "SET  @num := 0; UPDATE rancangan_bulanan SET id = @num := (@num+1);";
   $this->db->query($sql);
}

Unfortunately, it give me an error:
Code:
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE rancangan_bulanan SET id = @num := (@num+1)' at line 1

SET @num := 0; UPDATE rancangan_bulanan SET id = @num := (@num+1);

Filename: C:/xampp/htdocs/belajar/rkape/system/database/DB_driver.php

Line Number: 691

It's really strange, because the code was working in sql command line.

Any suggestion?
Reply


Messages In This Thread
What's wrong with mysql reset auto increment in codeigniter? - by Ukasyah - 05-17-2017, 05:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB