Loosing MySQL variable (@var)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Pefo
Forum Newbie
Posts: 9
Joined: Wed Dec 16, 2009 5:10 pm

Loosing MySQL variable (@var)

Post by Pefo »

How should I organize my queries to keep a MySQLs variable through multiple queries?

The value of my @varname turns to null between queries.

I LOCK the table
do a couple of queries (with the need of a persistant @varname)
UNLOCK the table

Is this normal MySQL behaivor or am I missing something?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Loosing MySQL variable (@var)

Post by AbraCadaver »

I'm pretty sure this isn't supported in the PHP extension for MySQL, and it isn't needed. You're using PHP, use PHP vars in the query. If you must have these then you can try using mysqli and your queries in a transaction.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Pefo
Forum Newbie
Posts: 9
Joined: Wed Dec 16, 2009 5:10 pm

Re: Loosing MySQL variable (@var)

Post by Pefo »

Thanks.

Will have a look on your suggestions.
Post Reply