Ver Mensaje Individual
  #5 (permalink)  
Antiguo 23/06/2011, 11:48
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: lastInsertId es efectivo PDO

Sí, PostgreSQL por default no devuelve el ID, tendrías que hacer algo así:
Código PHP:
Ver original
  1. public function insert($employee){
  2.  
  3.         $sqlQuery = "INSERT INTO employee(user_id,name,address,city) VALUES(:user_id,:name,:address,:city) RETURNING employee_id";
  4.  
  5.         $statement = $this->prepare($sqlQuery);
  6.  
  7.         $a ="2002-03-11 12:01AM" ;
  8.  
  9.         $statement->bindParam(":user_id", $employee->getUserId(), PDO::PARAM_INT);
  10.         $statement->bindParam(":name", $employee->getName(), PDO::PARAM_STR);
  11.         $statement->bindParam(":address", $employee->getAddress(), PDO::PARAM_STR);
  12.         $statement->bindParam(":city", $employee->getCity(), PDO::PARAM_STR);
  13.         $statement->execute();
  14.        
  15.         $result = $statement->fetch(PDO::FETCH_ASSOC);
  16.         return $result["employee_id"];
  17.  
  18.     }

Para obtener el ID...

Saludos.