This topic is locked

creat temporary table on event

1/13/2023 9:39:04 AM
PHPRunner General questions
I
IKA9 author

dear phprunner users ,

im trying to insert into events befor display as follow

$query : ("CREATE TEMPORARY TABLE details AS
select * from table where id = 1")
DB::excu($query)

my goes is to creat temporary table .
any suggestion i would appretiate thank you

aadham 1/14/2023

Please provide more details on what exactly you're trying to achieve.

admin 1/15/2023

I can tell that DB::excu() is incorrect and the proper syntax is DB::exec().

I
IKA9 author 1/15/2023

@aadham im trying to creat a temporary table
@admin yes mybad am I on correct track?

admin 1/15/2023

Creating a temporary table is only part of the process. Okay, you created it, what's next?

You need to explain the whole thing, every single detail.

I
IKA9 author 1/15/2023

that is all as i've tried it but not successed . but through workbench is works fine .
so my only question is DB:exec($query) is accurate or not . as i mentioned i have tried in events befor display but i still get ( database no exist )
Regards

fhumanes 1/16/2023

Hello,

I don't know if you have found how temporary tables works.

https://dev.mysql.com/doc/refman/8.0/en/create-temporary-table.html

A TEMPORARY table is visible only within the current session, and is dropped automatically when the session is closed. This means that two different sessions can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.)

On the web and mysql, every time a request to the server comes you create a new instance/session of the data server.

This way of working produces that from one execution to the next, the temporary table does not exist.

I think this your problem.

Regards,
fernando

aadham 1/16/2023

Hi IKA9,
In my case, I created temp tables in the Before Record Added/Updated events to do something with it in the After Record Added/Updated events, but never encountered the (database does not exist) error message. If PHPRunner can connect to the database, you shouldn't see such messages.

Please provide the exact code here with screen shots of the error message(s), so that we may be able to help you solve the issue.

Good luck!

I
IKA9 author 1/17/2023

@fhumanes
Thank you for taking the time to explain things to me. Your explanation was very helpful eventhough im aware about temporary table uses as i mentioned i used in workbench is good for me but in phptunner cant run. im not sure i did miss sth
@aadham
thank you for . following i made some screenshots it may use of anyhelp ? as im clueless .

and as i mentioned before post my code was . as following :

$query : ("CREATE TEMPORARY TABLE details AS
select * from table where id = 205221")
DB::excu($query)

img alt

img alt

img alt

img alt