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

mysql_insert_id

when i want to insert to database how can i find mysql_insert_id?

            $uof = new UserOrderForm();

            $uof->user_id = $user_id;
            $uof->aff_name = $order_name;
            $uof->order_date = $order_date;
            $uof->order_id = $order_no;
            $uof->amount = $order_amount;
            $uof->note = $order_note;
            $uof->status = 0;
            $uof->username = $order_email;

            $uof->save();

thanks



1.9k
Accepted
answer

if($uof->save()) { // $uof->id <=== inserted id }