We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

auto-increment code in Phalcon

there any way to do auto-increment code Phalcon or performed in the conventional way



85.5k

if noone replies, can you explain me what auto-increment code is



20.4k
edited Nov '15

$i = $i + 1; ? or $new_id = $last_id ++; ? If you are working with a MySQL database then you will setup the field e.g. user_id to auto increment. If you need to do it for something else in your code, then just use plain php as above. I do not think there is a specific function in Phalcon to do this.



85.5k
edited Nov '15

++$new_id; ?

what do you need it for, i dont see a point of a function in any case i can imagine


function increament(&$i){
    ++$i;
}

pfff.. sorry. Tought you were the guy who asked the question. Sorry



20.4k

ha ha my icon's a slightly different shade of green! :)



81.2k

I want to autoincrementable a field from the database, a primary code example:

CODE-001 CODE-002 CODE-003 CODE-004