ThingEngineer / PHP-MySQLi-Database-Class

Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Other
3.28k stars 1.35k forks source link

How can I use insert into with where clause #997

Open armcar opened 1 year ago

armcar commented 1 year ago

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 )

Brecht272727 commented 1 year ago

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' )

armcar commented 1 year ago

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

Brecht272727 commented 1 year ago

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?

armcar commented 1 year ago

Of course. My mistake. Thank you