jbreits Posted April 28, 2006 Share Posted April 28, 2006 I'm designing a site that uses php and a MySQL database, but I want to make it as efficient as possible so as to not put too much load on my hosting company's server. I have a couple questions about speeding things up.1. For MySQL connectivity, is it more efficient to use the standard mysql functions within php or to use the ADOdb classes? How about ADOdb lite? Persistent connections are probably not a good idea right (I seem to have found that they will probably hit the max number of open connections to the database)?2. If I use ADOdb, should I take advantage of caching?3. It appears that my hosting company has the Zend optimizer installed (via the phpinfo() function). Do I need to do anything to take advantage of this, or will it automatically optimize my files?4. Is it more efficient to use static HTML in conjunction with php? i.e. which of these 2 is more efficient (when the concept is applied to a larger scale):php only[code]<?php if (IsUserLoggedIn ()) { echo ('You are logged in as: '.$_SESSION['UserName']); echo ('<br>'); echo ('<a href="logout.php">Logout</a>'); } echo ('<table width="100%">'); echo ('<tr>'); echo ('<td width="50%">'); echo ('User Name: '); echo ('</td>'); echo ('<td>'); echo ('<input type="text" name="UserName" id="UserName" size="7" maxlength="50">'); echo ('</td>'); echo ('</tr>'); echo ('<tr>'); echo ('<td>'); echo ('Password: '); echo ('</td>'); echo ('<td>'); echo ('<input type="password" name="Password" id="Password" size="14" maxlength="50">'); echo ('</td>'); echo ('</tr>'); echo ('</table>');?> [/code]or static html with php[code]<?php if (IsUserLoggedIn ()) { echo ('You are logged in as: '.$_SESSION['UserName']); echo ('<br>'); echo ('<a href="logout.php">Logout</a>'); }?> <table width="100%"> <tr> <td width="50%"> User Name: </td> <td> <input type="text" name="UserName" id="UserName" size="7" maxlength="50"> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" name="Password" id="Password" size="14" maxlength="50"> </td> </tr> </table>[/code]Thanks!jbreits Quote Link to comment https://forums.phpfreaks.com/topic/8671-efficiency/ Share on other sites More sharing options...
JasonLewis Posted April 28, 2006 Share Posted April 28, 2006 hey to make it easier with echoing you can go like this:[code]<?phpecho <<<htmlShow the text in here!html;?>[/code]or you can do it through a variable:[code]<?php$content = <<<htmlThis is the top bithtml;if(session_is_registered("member")){$content .= <<<html //You put the . to add extra to the variableWelcome member!html;}echo $content;?>[/code]Either is effective, but i use the variable. Quote Link to comment https://forums.phpfreaks.com/topic/8671-efficiency/#findComment-31835 Share on other sites More sharing options...
jbreits Posted May 4, 2006 Author Share Posted May 4, 2006 I really thought I would have more people weigh in on this topic. I'm just trying to create my scripts so that use minimal server resources.1. What are people's thoughts on ADOdb? Is it more efficient than the mysql functions in PHP?2. Is embedding PHP in html a more efficient way to go? For example, if I have a form that might be re-populating itself based on the $_POST variables, is it more efficient to jump in to PHP mode once and output the entire form with values, or to primarily use HTML mode, but jump in to PHP mode for each value in the form:<input type="text" name="username" size=30 value="<?PHP echo ($_POST[username]); ?>">Thanks,jbreits Quote Link to comment https://forums.phpfreaks.com/topic/8671-efficiency/#findComment-33317 Share on other sites More sharing options...
ober Posted May 4, 2006 Share Posted May 4, 2006 1) I don't suggest using ADO. Use the included PHP libraries. From what I've found, they're faster. I'd challenge anyone else to suggest otherwise.2) I don't know about taking advantage of the Zend optomizer. I suggest you contact your host about that.3) The second option is far more efficient. Keep in mind that everything you pass through a PHP function has to be parsed by the PHP processor. If you send just HTML with PHP mixed in, it will ignore the HTML and hence parse your document faster. And just as a side note, the parenthesis are unnecessary for echos.4) <input type="text" name="username" size=30 value="<?PHP echo ($_POST[username]); ?>"> is faster, but it can be done even easier:<input type="text" name="username" size=30 value="<?=$_POST['username']?>"> Quote Link to comment https://forums.phpfreaks.com/topic/8671-efficiency/#findComment-33321 Share on other sites More sharing options...
jbreits Posted May 4, 2006 Author Share Posted May 4, 2006 Thanks for the response. I will skip the ADO stuff and keep as much stuff out of PHP as possible. I'll see what I can find out about Zend.Thanks!Jbreits Quote Link to comment https://forums.phpfreaks.com/topic/8671-efficiency/#findComment-33406 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.