Tagged Questions
PHP is a general-purpose scripting language originally designed to produce dynamic web pages.
0
votes
1answer
11 views
Nested while loop for getting db data. Timing out at random times because of the PHP. Any way to make this more efficient?
So today I jumbled together a script that would get data from a database, from different tables and such. I had wanted to just use simple ifs without the whiles, but I couldn't make it possible. The ...
2
votes
1answer
19 views
PHP DAO classes inherit from a generic DAO classes and only change the table name
I am building a web app that needs to access various tables in a given MySQL db. To do that, I have created a generic class, see DAO_DBRecord.php below, and I create children classes for each table I ...
2
votes
3answers
77 views
How can I improve this code by reducing foreach?
I have a piece of code that get errors from form and display to view:
$errors = $form->getMessages();
$msg = '';
foreach ($errors as $error)
{
foreach ($error as $err)
{
$msg .= ...
2
votes
2answers
51 views
Shell script: is it doing what I think it's doing
I've not written many shell scripts and cobbled this together from examples. The 'if' condition should check if this is already running and quite if so. The 'wget' call should trigger the php page and ...
1
vote
3answers
43 views
How to optimize redundant IF statements in PHP
I was wondering if someone could give some tips as to how improve long strings of if-else statements and redundant if statements. For example, how should I optimize this if statement so it would be ...
1
vote
2answers
63 views
Is it acceptable to pass an Exception into a function that then may or may not throw it?
I am still getting the hang of Exception Handling in PHP; Here is the scenario where I am using the convention:
There are times where I have a SQL query that I need to turn into an object, so I wrote ...
2
votes
4answers
97 views
optimize my foreach
I have the following script and I think it's a bit inefficient. With a array from 1 to 3, this isn't a real problem, but this array can get way bigger. So how to boost it's performance/optimize this ...
0
votes
0answers
32 views
Optimizing URL router behaviour
I'm trying to create an URL-router, where the website language is defined by the first two chars in the domain. Example: domain.com/en (the site will then display content in english).
The script ...
1
vote
2answers
37 views
JSON for one column of a csv file?
I wrote this to pull one column of data from a csv file, divide each of the results in 2, and then format it as JSON so I can do stuff with it in a web app. It works, but it feels wonky and weird. ...
2
votes
2answers
85 views
REGEXless dispatcher
I've recently helped fellow SOFer to answer his question @ http://stackoverflow.com/questions/8407647/routing-in-my-php-mvc-framework/8408106#8408106 (Routing in my PHP MVC framework).
Then I thought ...
1
vote
1answer
55 views
Improve code of BDDs in phpunit
no one in my team knows how to write BDD tests, so I started writing some and its quite working well for but I think the time has come to improve the code quality.
Here is my code and it contains a ...
4
votes
1answer
76 views
PHP data structure review and critique
I have been working lately on an educational framework project to learn more about web development and problems that arise in more complex applications. Part of the framework's principles is to be as ...
4
votes
3answers
64 views
How can I improve this set of queries in PHP
Okay so as I learn more about PHP and really strive to improve my code I have a few questions about a current setup of mine and how to approach it in the best way.
I think I have all the tools ...
1
vote
1answer
33 views
Any optimization suggestions for this php code to detect if CAPTCHA is needed?
I wish to ask if the code written below has any holes (probably it will be useful for someone else). This code checks if more than 5 attempts within the last 5 minutes were made to login. Checked by ...
1
vote
1answer
34 views
is there a better and short way to getting that array from joined sql query and converting it to superfish dropdown menu?
I'm trying to build a superfish dropdown menu from a sql query. Working example is can be seen from here check the "emlak bul" category: ...