Default ID is inserting "0"

edited January 2011 in Bug Reports
Hello,

I have made one module & inserting record..
Record is inserting properly.. But by default for first record it is inserting id as "0" (primary key) (Hence, I can't do delete/edit from admin)

Here is my table structure, & my model


My entity_medium_model.php
require_once(FUEL_PATH.'models/base_module_model.php'); class Entity_medium_model extends Base_module_model { public $required = array('medium_name'); function __construct() { parent::__construct('entity_medium'); } }


CREATE TABLE `aks_medium` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`medium_name` varchar(50) NOT NULL,
`published` enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

Comments

  • edited 10:47AM
    In above DB SQL I forget to reset the "AUTO_INCREMENT" Value. Please truncate the DB & then try it.. So AutoIncrement become reset
  • edited 10:47AM
    Is the table name suppose to be aks_medium or entity_medium?
  • edited 10:47AM
    Also, I've ran into that issue a couple times and restarting MySQL fixed the problem.
  • edited 10:47AM
    Restarting MySQL has fixed the problem...
  • edited 10:47AM
    I ran into the problem again last night. Were you by any chance doing anything with the Tester module? I'm trying to find out if there is a pattern to it that may be causing MySQL to act that way.
  • edited 10:47AM
    No, I am not doing anything in tester module.. I have just create fresh DB & module.. And for testing, I have inserted one record and that's it, I found "0" id in DB.
  • edited 10:47AM
    I have notice one more thing, and I think it is cache problem..

    I have inserted 2 records, and on list page when I mouse over on "edit" link then both id are same.. both are "1" number id.. while, I have checked in DB then it was ok..
    in DB it was 1 & 2 orderwise.. So definitely it's something cache or request/response problem.


    Follow the below Steps..

    first truncate the table
    Create new record,
    Go to list page.. Click again on "create"
    Insert again another record
    Go to list page and now check with mouse over on "Edit" link
  • edited January 2011
    ah sorry, It was my mistake, In list item I have set wrong Id reference, That's why it was showing same id in "edit' link
Sign In or Register to comment.