Good [insert time of day here] all!

I am trying to reorder my auto-inc field in my database, and I have
successfully done it with my "front end" that I use (SQLYog) with the
following code:

SET @var_name = 0; 
UPDATE `my_database`.`my_table` SET `id` = (@var_name := @var_name +1);


Now, when I try this within PHP... I can't get it to work at all.  I assume
that the SET is the issue, but I am not 100% sure.

I use the PEAR MDB2 class, and I have tried it in 1 statement, but it
failed, and I tried it with 2 statements, it didn't puke on it, but it
didn't work either.

<?php
        # db connection is already set up #
        echo $db->exec('SET @var_name = 0;')
        echo '<br />';
        echo $db->exec('UPDATE `my_database`.`my_table` SET `id` =
(@var_name:= @ var_name +1);');
        exit;
?>

Does anyone know how I can do this within PHP?  Worst case scenario, is that
I just write a php shell() command instead, but I would rather avoid that if
at all possible.

Thanks in advance!

Steven Staples



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to