AUTO_INCREMENT column receives value 0

Locked
erikfinnegan
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat Aug 23, 2008 9:38 pm

AUTO_INCREMENT column receives value 0

Post by erikfinnegan » Sun Aug 24, 2008 8:27 am

Guys,

I am totally devastated. Have no clue what is happening : my own component is installed into the table #__components with an id of 0 (zero). That happens only on my development system, though, which is wampp 1.6.6.

I have nailed down the function _buildAdminMenus of the module libraries/joomla/installer/adapters/component.php. Line 531 ff. says

Code: Select all

$query = 'INSERT INTO #__components' .
' VALUES( '.$exists .', '.$db->Quote($db_name).', '.$db->Quote($db_link).', '.(int) $db_menuid.',' .
' '.(int) $db_parent.', '.$db->Quote($db_admin_menu_link).', '.$db->Quote($db_admin_menu_alt).',' .
' '.$db->Quote($db_option).', '.(int) $db_ordering.', '.$db->Quote($db_admin_menu_img).',' .
' '.(int) $db_iscore.', '.$db->Quote($db_params).', '.(int) $db_enabled.' )';
I have output the query into a log as it is executed. And it says

Code: Select all

INSERT INTO #__components VALUES( 0, 'Pygalle', 'option=com_pygalle', 0, 0, 'option=com_pygalle', 'Pygalle', 'com_pygalle', 0, 'components/com_pygalle/assets/pygalle_component.png', 0, '', 1 )
as expected. Why, for heaven's sake, is the table entry generated with id = 0 ?! The "next auto-increment value" is 34, as I can see in phpmyadmin.

What is worse : the line works fine in the command-line mysql client, creating the next auto-increment. It also works fine on the live system. And other components, which I tried, "fireboard" and "simplecaddy", install fine as well. :'(

The mysql documentation says something about server modes. Where only NULL would generate the next auto-increment value. However, why would other components install fine?

I have no idea! No idea.

Please excuse me not adding the jtspost_en.php - on my development system it causes the apache process to create an illegal memory access....

When I change the code above and list the columns in which to insert, and apparently sparing the id column...

Code: Select all

$query = 'INSERT INTO #__components (`name`, `link`, `menuid`, `parent`, `admin_menu_link`, `admin_menu_alt`, `option`, `ordering`, `admin_menu_img`, `iscore`, `params`, `enabled`)' .
' VALUES( '.$db->Quote($db_name).', '.$db->Quote($db_link).', '.(int) $db_menuid.',' .
' '.(int) $db_parent.', '.$db->Quote($db_admin_menu_link).', '.$db->Quote($db_admin_menu_alt).',' .
' '.$db->Quote($db_option).', '.(int) $db_ordering.', '.$db->Quote($db_admin_menu_img).',' .
' '.(int) $db_iscore.', '.$db->Quote($db_params).', '.(int) $db_enabled.' )';
...then the insert of my component works.

Locked

Return to “Joombie Coding Q/A”