Problem when executing a SQL query by PHP

0

I am trying to add data with insert into select to a table from php but it is not paying attention to me. When I do a echo $consulta ; Show me this:

INSERT INTO orden_requisitos SELECT NIA, COUNT(*) AS Total FROM alumnos_formacion inner join oferta_formacion ON alumnos_formacion.idFormacion=oferta_formacion.idFormacion WHERE idOferta=1 GROUP BY NIA ORDER BY COUNT(*) DESC;

I copy it and paste it into the PHPMyADMIN console and execute the query perfectly. I inserted the data. From PHP I do a affected_rows to know if there are rows affected, it tells me that if rows were affected, then in the BD those rows do not appear.

Why can it be?

EDIT

I do several queries in a row, but the other tables and insert into works

NOTE - > If I execute this query:

$consulta = "create table orden_requisitos(NIA char(7),TOTAL tinyint unsigned)"; $objetoBBDD->consultarBD($consulta);

After the multiquery, the order-requirements table does not create it for me, that's why I put it first.

My PHP code:

$consulta = "create  table orden_requisitos(NIA char(7),TOTAL tinyint unsigned)";
$objetoBBDD->consultarBD($consulta);

$query1 = "create  table oferta_formacion(idOferta tinyint unsigned,idFormacion tinyint unsigned);";
$objetoBBDD->consultarBD($query1);

$query2 = "insert into oferta_formacion 
        select idOferta, requisito1
          from ofertas
        where idOferta=".$idOferta.";  

        insert into oferta_formacion 
        select idOferta, requisito2
          from ofertas
        where idOferta=".$idOferta.";  

        insert into oferta_formacion 
        select idOferta, requisito3
          from ofertas
        where idOferta=".$idOferta.";  

        insert into oferta_formacion 
        select idOferta, requisito4
          from ofertas
        where idOferta=".$idOferta."; 

        insert into oferta_formacion 
        select idOferta, requisito5
          from ofertas
        where idOferta=".$idOferta."; 

        insert into oferta_formacion 
        select idOferta, actitud1
          from ofertas
        where idOferta=".$idOferta."; 

        insert into oferta_formacion 
        select idOferta, actitud2
          from ofertas
        where idOferta=".$idOferta.";    

        insert into oferta_formacion 
        select idOferta, actitud3
          from ofertas
        where idOferta=".$idOferta.";";

$objetoBBDD->consultarBDMulti($query2); //<-- multiquery


$query4 = "INSERT INTO orden_requisitos (SELECT NIA, COUNT(*) AS Total FROM alumnos_formacion inner join oferta_formacion
        ON alumnos_formacion.idFormacion=oferta_formacion.idFormacion WHERE idOferta=".$idOferta." GROUP BY NIA 
        ORDER BY COUNT(*) DESC);";
$objetoBBDD->consultarBD($query4);
    
asked by Mario Guiber 13.06.2018 в 20:46
source

0 answers