Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/02/2012, 11:50
SJENERT
 
Fecha de Ingreso: julio-2009
Mensajes: 178
Antigüedad: 14 años, 9 meses
Puntos: 1
Respuesta: ¿Se puede ver el query hecho en PDO?

Gracias por responder Carlos, hice lo que dices y me dice que la variable no esta definida, si hago el echo despues del prepare me dice
Catchable fatal error: Object of class PDOStatement could not be converted to string in E:\......

pondré el código que tengo,

funcion generica que maneja cualquier query sin importar la cantidad de parametros
Código PHP:
public function obtener($q$ar null)
    {
        
self::set_names();
        
$stmt=$this->dbh->prepare($q);
        
        if (
$stmt->execute$ar ))
        {
            while (
$row $stmt->fetch())
            {
                
$this->resultado[]=$row;
            }
            return 
$this->resultado;
            
$this->dbh=null;
        } else {
          return 
false;
        }
        
    } 
ahiora como lo uso


Código PHP:
$q "SELECT * FROM `opciones` WHERE votacion_id = ?;";
          
$ar = array($fila['votacion_id']);
          
$resp $oGen->obtener($q$ar);