scrubbicus Posted March 23, 2011 Share Posted March 23, 2011 I've seen the @ sign before a lot of different syntax. What does it mean? I was reading up on some MySQL references and saw it here SET @str = BINARY 'New York'; but I've seen it in many other places as well and was always curious. Quote Link to comment https://forums.phpfreaks.com/topic/231545-whats-the-mean-before-things/ Share on other sites More sharing options...
Maq Posted March 23, 2011 Share Posted March 23, 2011 http://dev.mysql.com/doc/refman/5.0/en/user-variables.html Quote Link to comment https://forums.phpfreaks.com/topic/231545-whats-the-mean-before-things/#findComment-1191510 Share on other sites More sharing options...
Psycho Posted March 23, 2011 Share Posted March 23, 2011 Hmm, the example you posted appears to be MySQL, but for PHP usage it is used to suppress error reporting. For example, if your script tries to read a file and the file doesn't exist you wouldn't want to display some ugly PHP error. Instead you would attempt to read the file (suppressing the error if there is one), then display a friendly error to the user: More info in the manual: PHP: Error Control Operators: http://php.net/manual/en/language.operators.errorcontrol.php Quote Link to comment https://forums.phpfreaks.com/topic/231545-whats-the-mean-before-things/#findComment-1191511 Share on other sites More sharing options...
The Little Guy Posted March 23, 2011 Share Posted March 23, 2011 Some quick examples: SET @city = (select city_name from cities_table where id = 12321); -- pretend 12321 is the row for "New York" select @city; -- Returns 1 row: 'New York'; -- We don't need to reset the variable select * from my_table where city = @city; Quote Link to comment https://forums.phpfreaks.com/topic/231545-whats-the-mean-before-things/#findComment-1191548 Share on other sites More sharing options...
fenway Posted March 30, 2011 Share Posted March 30, 2011 Just be careful, it works differently based on where it appears in the statement. Quote Link to comment https://forums.phpfreaks.com/topic/231545-whats-the-mean-before-things/#findComment-1193972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.