table_name . " SET uid" /> table_name . " SET uid" /> table_name . " SET uid"/>

Pass lastInsertId() in variable

66 views Asked by At

I get the last insertid with pdo in object1.php:

object1.php

class 1234{
    public function test{
        $query = "INSERT INTO " . $this->table_name . "
        SET uid=:uid, order_id=:order_id, position=:position, optionindex=:optionindex, created=:created";

        if($stmt->execute()){
            $last_id = $this->conn->lastInsertId(); 
        }
        print_r($last_id); //works here fine
        return true;
        }
    }
}

So next i need to pass $last_id in object2.php.

The only way it works for me, to use sessions ... but isn“t there a better solution?

Thanks

0

There are 0 answers