MySQL 40 - (p/t)query.
#7

Quote:
Originally Posted by Meller
Посмотреть сообщение
Alright, thank you.
You are welcome.

-------------

Quote:
Originally Posted by wallee
Посмотреть сообщение
I was also curious about this but never asked. The last time i was reading about "pquery" i remember somebody said something like:

"it can seriously mess up your server if you don't know what you're doing"

They didn't provide an example so if one could be provided that would be great. :P
Well, it can mess up some things if you expect the results to come in order. You may need to use mysql_tquery instead of mysql_pquery if you really need the results in order. For example, something like:
PHP код:
RegisterPlayerplayerid )
{
    
mysql_pquery1"INSERT INTO `users` VALUES( MY_KEY_ID, ... )""RegisteredPlayerInsert"playerid );
    
mysql_pquery1"SELECT * FROM `users` WHERE `id` = MY_KEY_ID""SelectInsertedValues"playerid );
}
function 
RegisteredPlayerInsertplayerid )
{
    
// blahblahblah
}
function 
SelectInsertedValuesplayerid )
{
    
// do things with user's row

won't be fine, as "SELECT * FROM `users` WHERE `id` = MY_KEY_ID" could be actually executed before the insert (so the result will be empty, no rows, but you may expect one row EVERYTIME ! if the SELECT is executed before INSERT, there won't be any row, otherwise it will have the full row you requested), not after it like you see in the code, for that you have to use mysql_tquery. Ideally, you can still keep using mysql_pquery, but do it in this way:
PHP код:
RegisterPlayerplayerid )
{
    
mysql_pquery1"INSERT INTO `users` VALUES( 0, ... )""RegisteredPlayerInsert"playerid );
}
function 
RegisteredPlayerInsertplayerid )
{
    
// blahblahblah
    
formatlString128"SELECT * FROM `users` WHERE `id` = %d"cache_insert_id( ) );
    
mysql_pquery1lString"SelectInsertedValues"playerid );
}
function 
SelectInsertedValuesplayerid )
{
    
// do things with user's row

Not the best real life example, but some other things may look similar to this. Most of the code can be made perfectly compatible with the mysql_pquery function, you just have to think how they may mess up if they won't get executed in order.
Reply


Messages In This Thread
MySQL 40 - (p/t)query. - by Meller - 17.11.2017, 20:13
Re: MySQL 40 - (p/t)query. - by IstuntmanI - 17.11.2017, 20:25
Re: MySQL 40 - (p/t)query. - by Meller - 17.11.2017, 20:29
Re: MySQL 40 - (p/t)query. - by IstuntmanI - 17.11.2017, 20:35
Re: MySQL 40 - (p/t)query. - by Meller - 17.11.2017, 20:37
Re: MySQL 40 - (p/t)query. - by wallee - 18.11.2017, 01:33
Re: MySQL 40 - (p/t)query. - by IstuntmanI - 18.11.2017, 14:16
Re: MySQL 40 - (p/t)query. - by wallee - 18.11.2017, 15:40

Forum Jump:


Users browsing this thread: 1 Guest(s)