|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 | ||
|
Foldin' For PCMech!
|
PHP queries
This may be a dumb question, but I'll ask anyway. If you have more than 1 query in a PHP script do you need to use mysql_close() after each query or only have 1 mysql_close at the end of the page?
One other thing, can I do more than 1 query each time I connect to the database? I have a number of queries on a page I'm working on and I'm trying to speed up the load time by combining queries. TIA
__________________
Eric
|
||
|
|
|
|
|
#2 |
|
Member (7 bit)
Join Date: Dec 2005
Posts: 87
|
If you are doing insert queries it is recommended you seperate each query with a semi-colon and run the entire string:
$query='INSERT INTO test1 VALUES("a","b","c");INSERT INTO test2 VALUES("1","2","3")'; $result=mysql_query($query); I believe the connection to the database is made with the mysql_query command. The connection for mysql_connect and mysql_db_select aren't made with those commands I believe. If you were doing select queries where you had to get a value out of it you would have to have two different mysql_result commands although it isn't recommended. Try to use a different approach so you only have one query, whether it is in your script our database structure. My experience with optimization is that bandwidth is the major bottleneck. MySQL queries are next but only appear if you have really bad design. PHP is a distant third and they only slow the page down if you are reading an external file. I would first say check the image size of your pictures if it is loading slow. |
|
|
|
|
|
#3 |
|
Foldin' For PCMech!
|
Well the images are the same on every page so thats not the problem. I deleted all the mysql_connect scripts out except for the first and that seems to have helped a lot, I have something like 20 queries on this page so in doing this it helped a lot.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|