Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use insert into with where clause #997

Open
armcar opened this issue Sep 29, 2022 · 4 comments
Open

How can I use insert into with where clause #997

armcar opened this issue Sep 29, 2022 · 4 comments

Comments

@armcar
Copy link

armcar commented Sep 29, 2022

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
Copy link

Brecht272727 commented Sep 30, 2022

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
Copy link
Author

armcar commented Sep 30, 2022

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
Copy link

Brecht272727 commented Sep 30, 2022

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
Copy link
Author

armcar commented Oct 3, 2022

Of course. My mistake.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants