Re: [PHP-DB] Code optimization

2009-08-06 Thread Chris
kranthi wrote: you can avoid using mysql_connect and mysql_close for every query (they are the most costliest functions in your application) You're assuming that. It could be the queries being run are the costliest. you should not use mysql_result for this application http://in2.php.net/funct

Re: [PHP-DB] Code optimization

2009-08-06 Thread kranthi
you can avoid using mysql_connect and mysql_close for every query (they are the most costliest functions in your application) you should not use mysql_result for this application http://in2.php.net/function.mysql-result try using mysql_fetch_assoc instead. finally, use a good profiler, like xdebu

Re: [PHP-DB] Code optimization

2009-08-06 Thread Chris
Ron Piggott wrote: Is there a way to optimize this with better mySQL query? Step 1 - work out which bit is slow. $start_time = time(); mysql_query () echo "That took " . (time() - $start_time) . " seconds\n"; I'd guess the first one is slow because of the order by random() but that's j

Re: [PHP-DB] Re: "COUNT() returns 0 if there were no matching rows." .... really?!

2009-08-06 Thread Govinda
Here's an example (snip) from a var_dump of that $BuildPerUniqueDateArray: (note that the 'aweber_7solar_aw' table does NOT have a record for the date '2009-07-28', so I would expect to see that "1" to be a "0" there.) If a table doesn't have a record for a given date, I wouldn't expect t

[PHP-DB] Code optimization

2009-08-06 Thread Ron Piggott
Is there a way to optimize this with better mySQL query? # Select today's Bible verse mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM verse_of_the_day_Bible_verses WHERE `assigned_date` = '-00-00' AND se

[PHP-DB] Re: "COUNT() returns 0 if there were no matching rows." .... really?!

2009-08-06 Thread Ben Dunlap
> Here's an example (snip) from a var_dump of that $BuildPerUniqueDateArray: > (note that the 'aweber_7solar_aw' table does NOT have a record for the > date '2009-07-28', so I would expect to see that "1" to be a "0" there.) If a table doesn't have a record for a given date, I wouldn't expect to s

[PHP-DB] "COUNT() returns 0 if there were no matching rows." .... really?!

2009-08-06 Thread Govinda
Hi all I am 99.9% sure it is my lack of understanding something, but it sure seems like my PHP/MySQL code is returning something other than what i expect from reading the docs. to explain: this code is serving me (almost perfectly) well: