PHP-MySQLi-Database-Class icon indicating copy to clipboard operation
PHP-MySQLi-Database-Class copied to clipboard

How can I use insert into with where clause

Open armcar opened this issue 3 years ago • 4 comments

Hi

I have this script that works directly (mySql)

INSERT INTO at_crc_tratamento_manual (dia, nif, tribunal, processo, citacao, certidao, juizo, nome, sf) SELECT dia,nif,tribunal,processo,citacao,certidao,juizo,nome,sf from at_crc_reclamacao_de_creditos WHERE processo = '441/12.0TBTND . 1';

How can I use db Class with it. Something like that, but just find the correct terms $id = $db->insert ( at_crc_tratamento_manual , $array )

armcar avatar Sep 29 '22 16:09 armcar

You can also use this:

$db->rawQuery( 'INSERT INTO at_crc_tratamento_manual (dia, nif, tribunal, processo, citacao, certidao, juizo, nome, sf) SELECT dia,nif,tribunal,processo,citacao,certidao,juizo,nome,sf from at_crc_reclamacao_de_creditos WHERE processo = '441/12.0TBTND . 1' )

Brecht272727 avatar Sep 30 '22 12:09 Brecht272727

Ok! Thank You I have in mind something like that you (thanks) give:

$wSQL = "SELECT * FROM xxx WHERE yyy"; $data = $db->query( $wSQL );

It should return the same, but I realy didn't found something more like tradicional queries (using $db of course) $resposta['data'] = $db ->where('processo', $p ) ->get(DB_PRE.'crc_tratamento_manual tbl', null, 'DISTINCT tbl.*'); Understand? But the important is have a way, a solution, and i got it. Thank you so much

In Time Obrigado desde Portugal - Viseu

armcar avatar Sep 30 '22 14:09 armcar

Hi, you're welcome but it is $data = $db->rawQuery( $wSQL );

But for a better solution i don't know for your query. Maybe @ThingEngineer you can help here?

Brecht272727 avatar Sep 30 '22 14:09 Brecht272727

Of course. My mistake. Thank you

armcar avatar Oct 03 '22 11:10 armcar