create a sequence in MySQL, with mysql variable?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • awebguynow

    create a sequence in MySQL, with mysql variable?

    This might be fairly easy to do and I think I've seen the code before,
    but I haven't seen many good examples of this. Of course Pear::DB
    probably uses this code in some of its API, probably in dealing with
    auto-increment indexes and prepared statements.

    Maybe I'm off base here, but I'm looking for something like this:
    (psuedo-code)
    Of course the seq table only needs 1 row holding id, which is
    updated.
    select id from tbl;
    // get result resouce and do fetch, store value in $myid
    set @myvar = $myid + 1; // can php send to MySQL with a query? (
    never seen this )
    update myseq set id=@myvar // send this statement through in a
    update/query

    // for use in PHP code
    $newSeqVal = $myid +1

    A link to an example would be great.
    TIA

Working...