Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/11/2014, 15:20
ymolinay
 
Fecha de Ingreso: febrero-2014
Mensajes: 25
Antigüedad: 12 años, 7 meses
Puntos: 1
you can't run this command now

Tengo un procedure que hace todo el crud de la BD.. funciona muy bien cuando llamo directamente al procedure desde phpMyAdmin / workbench.. o cuando lo ejecuto directamente desde php. PERO cuando intento borrar más de un registro luego de haber insertado otros me aparece este error "Commands out of sync; you can't run this command now".

He leído que se debe a que debo limpiar/liberar la consulta anterior o algo así.. pero después de varios intentos no puedo solucinarlo u.u

Aquí creo el objeto MySqli

Código PHP:
try {
            
$this->connection = new mysqli($this->objConfig->host, $this->objConfig->user, $this->objConfig->password, $this->objConfig->dataBase);
            
$this->connection->set_charset('utf8');
            
$this->connection->connect_errno;
        } catch (
exception $e) {
            
$this->objLog->setMessage('00002: ' . $e->getMessage());
            
$this->objLog->setError($this->objLog);
            return 
false;
        } 
Aquí está la función que ejecuta los procedures

Código PHP:
public function mysqlSimpleExecute($sql) {
        try {
            
$result = $this->connection->query($sql);
            
//$result->free();
            //mysqli_free_result($result);
            //$this->connection->next_result();
            //echo $this->connection->error; error que les digo que me bota
            
            
if (!$result) {
                return 
false;
            } else {
                return 
true;
            }
        } catch (
exception $e) {
            
$this->objLog->setMessage('00003: {' . $sql . '} ' . $e->getMessage());
            
$this->objLog->setError($this->objLog);
            return 
false;
        }
    } 
Esta eslafunción para generar procedure que hará el DELETE

Código PHP:
public function executeDelete() {
        
$mTable = explode(" ", $this->getTables());
        
$table = $mTable[0];
        
$where = $this->getWhereFields('delete');
        
$sqlExecute = 'call spTransaction("DELETE","' . $table . '","","","","' . $where . '","","","");';
        return 
$this->mysqlSimpleExecute($sqlExecute);
    } 
Alguna idea? Gracias de antemano