Stryves Posted May 8, 2009 Share Posted May 8, 2009 I've been doing minor adjustments to my code lately and I was curious about the following... 1. Let's say we run $query = "select * from clients" (I'm suming up here... ) 2. If I declare that $clientname=$query['clientname']; 3. I use the variable $clientname 10 times in my code. Does it check the database ten times to find the clientname, or does it only check the first time to determine the variable value? The reason I ask, I don't want to constantly check the database if it can be avoided... It may be very minimal, but I was lead to believe that using $query['clientname'] ten times would check the database each time. Sometimes I use variable 50-100 times in my code I'm building. Quote Link to comment https://forums.phpfreaks.com/topic/157398-solved-php-variable-loading-from-database-constantly-checking/ Share on other sites More sharing options...
rckehoe Posted May 8, 2009 Share Posted May 8, 2009 It does NOT call the mysql_query 10 times... It just gets the value that you passed to it. Quote Link to comment https://forums.phpfreaks.com/topic/157398-solved-php-variable-loading-from-database-constantly-checking/#findComment-829770 Share on other sites More sharing options...
Stryves Posted May 8, 2009 Author Share Posted May 8, 2009 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/157398-solved-php-variable-loading-from-database-constantly-checking/#findComment-829773 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.