Syntax for "RETURNING" clause in Mysql PDO
        Posted  
        
            by dmontain
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dmontain
        
        
        
        Published on 2010-05-09T01:03:07Z
        Indexed on 
            2010/05/09
            1:08 UTC
        
        
        Read the original article
        Hit count: 325
        
I'm trying to add a record, and at the same time return the id of that record added. I read it's possible to do it with a RETURNING clause. 
$stmt->prepare("INSERT INTO tablename (field1, field2) 
                               VALUES (:value1, :value2)
                          RETURNING id");
but the insertion fails when I add RETURNING. There is an auto-incremented field called id in the table being added to.
Can someone see anything wrong with my syntax? or maybe PDO does not support RETURNING?
© Stack Overflow or respective owner