1
vote
1answer
27 views

Rewriting dispatch method

Is it possible to rewrite this piece of code any better when it comes to efficiency and/or readability? ...
2
votes
1answer
54 views

UserDAO with CRUD functionality for my UserRepository

This is my first attempt at creating a DAO. I would like to get some feedback regarding the following aspects if possible: Code readability Efficiency Usability I also would appreciate any other ...
4
votes
2answers
63 views

Cleaning up validator class

I updated my class with more functionality, but I kind if feel like it's a mess or that it can at least be improved by a bit readability, efficiency and/or DRY wise. Anybody who could see if that can ...
4
votes
2answers
90 views

Validator refactored to be OO

Based on my previous post I completely re-factored my code to make it object oriented. Anything I could improve when it comes to: Object oriented code; Efficiency; Readability. Any other ...
5
votes
0answers
157 views

Puzzle game with sequence numbers

I am currently developing a puzzle game that has sequence numbers. The player has to fill the grid with sequence numbers in ascending order. Starting from 1 the player can move horizontally or across ...
3
votes
1answer
81 views

Validator Readability and Efficiency

This is my first validator I have created myself and I was wondering if there is anything about it that I could improve as far as: Code readability Code efficiency Note: The reason why I put an ...
11
votes
3answers
216 views

Search script code efficiency

Is there a more efficient way to write this? This script will be used heavily and I want to make sure I do not have any memory leaks or speed issues. This script gets an input from a form and ...
0
votes
1answer
69 views

How could I more optimize this code [closed]

how can I optimize this code more and more cleaned ok. Here is the code ...
3
votes
2answers
86 views

Is there a “prettier” way of forming this query, or a more efficient way of joining the tables?

Yesterday I posted a question involving multiple nested queries. The queries pulled information from the database and created a directory listing of all employees. There are two many-to-many ...
0
votes
1answer
54 views

Would multiple joins boost performance, or are the nested queries an acceptable way to handle the situation?

I'm working on a directory that lists employee information. Each employee can belong to multiple departments and each employee can have multiple job titles. I have 5 ...
3
votes
1answer
73 views

Redunancy Issues in PHP Class

I've been studying PHP for a while now and decided to dive into OOP. Most of my code was a mess and I've begun to refactor much of the website to OOP; however, I'm having an issue with redundancy in ...
1
vote
1answer
75 views

Codeigniter ActiveRecord Wrapper Model

Can someone help me refactor this to be more optimized? Performance seems to be very optimal, but I think more can be squeezed from it. ...
1
vote
1answer
47 views

Optimising and consolidating multiple PHPMailer functions

So the two functions below both send emails via PHPMailer but both hold different messages (which use different data from the db). I was just wondering (as I plan to use PHPMailer more) a way to ...
8
votes
1answer
175 views

PDO sign up function inserting data into multiple tables

This is a sign up function called on form submission. It firstly inserts key user data into the users table. If successful, secondary data is then inputted into ...
6
votes
1answer
64 views

Removing image records if no physical file exists

I have a working script that selects image fields in all tables and empty their values if the physical file doesnt exist. ...
5
votes
1answer
92 views

How can I optimize this database to array structure code?

I need to take data from a MySQL database and message it into a format expected by the front end of an application - I can not change the front end as other services provide it data in this same ...
5
votes
1answer
166 views

Reducing complexity of method

I'm trying to reduce the complexity of some methods, and I'm not exactly sure what approach to take. I'm currently building a PHP wrapper for a REST API, and the main problematic class is here: ...
1
vote
1answer
78 views

How to turn 201 queries into 1? [closed]

I have a PHP web app that manages contacts. It has four main functions that display: contacts with upcoming birthdays; the 20 most viewed contacts; all contacts (200 limit) plus their phone number ...
3
votes
1answer
64 views

Searching for news articles in database

The first thing I would like to say is that I do have a fully functioning script, but the script is ugly, and I am wondering if there is a way to optimize it. The script looks to see if I have at ...
3
votes
2answers
110 views

Is code optimization for branch predictor necessary now?

I would like to share a part of some code written several years ago (I have changed from mysql to mysqli); this code works perfectly. I am new to my company, and our senior programmers wrote some ...
1
vote
1answer
116 views

Optimize switch case for dynamic content

I have written a function for switching advert image based on $template. Function is working completely fine without any problem and getting everything dynamically ...
0
votes
1answer
31 views

Generating revision-table to accompany existing table

This morning, I wrote a quick-and-dirty table-revision generation script: (gist). It is intended to be run in the command line. Here's the entirety of it (149 lines): ...
4
votes
1answer
278 views

Optimize MySQL double select inside for-loop

I want to get the number if items with state 4 and 1 from my database for each day between a certain date. Is there a smarter ...
4
votes
1answer
310 views

Using POST data to call a function from a specified class

I've inherited a class in a project which is purposed to execute a function that exists in POST data from a specified class. I've tried to clean this up as much as possible as well as secure it ...
4
votes
1answer
86 views

Need help optimizing PHP/MySQL code snippet

I am sorry for the simple request, but I'm trying to figure out the best way to optimizing the following bit of code. I hate using 20 lines of code when 12-15 will suffice. I also don't like having ...
0
votes
2answers
67 views

Optimize this path location script?

Example Script is located in /home/insp/public_html/deploy/ I want to return the /home/insp/ section ...
2
votes
2answers
57 views

Looking for a better way to handle this growing array used for preg_replace

first time visiting Code Review. I figured this was a more appropriate spot than SO for this question. Here goes... Currently, I have a php function that converts bbcode format text in to HTML ...
4
votes
1answer
135 views

Getting JSON from a remote API sometimes hangs. Can I make this any faster?

Testing on localhost, it takes a bit longer to get the results than I would like and gives me this PHP error: Fatal error: Maximum execution time of 30 seconds exceeded I am wondering if there ...
3
votes
1answer
200 views

How to make this csv-reading PHP code more efficient?

I have the following code that reads a .csv file that than outputs the result in the form of a HTML table: ...
2
votes
1answer
114 views

How to optimize the following code in order to decrease the execution time?

I'm dealing with huge amount of data. I've written following code into a function to find out similar questions. It's working perfectly but it is taking too much time in execution. Can anyone help me ...
0
votes
1answer
310 views

Performance of autofit text method (using Imagick) is horrible, unfortunately

I've hacked a method that auto-fits text into an Imagick image, given a bounding box: the image's width (minus optional margins) and a certain maximum height. What ...
1
vote
2answers
177 views

How can I optimize my login script?

I've created an Ajax login for my website but I feel like I can optimize it, but I'm not sure how and where. Questions: How can I optimize my code? Is the code secure? Any ways to break it ...
2
votes
3answers
215 views

Service status checker… Is there a more efficient way?

I've been working on a website status checker.. However this array that I use has around 30 sites within it, I've noticed it's taking around 6-7 seconds to load it. I was wondering if there's any ...
2
votes
2answers
425 views

My simple CMS system - security and code obscurity?

I'm working on a simple CMS with the intent of making it as secure as possible (a personal challenge) and the code as clean as possible. I think I've a long way to go so I would appreciate any input, ...
2
votes
1answer
147 views

Correct use of my JOIN and arrays to fetch the data?

After learning a lot about programming, I've decided to write some code pertaining to scripting and use of different functions. I've come to a point where I'd like others to verify my code for ...
1
vote
1answer
859 views

Bootstrap 3.0 Carousel gallery post WordPress

I have working code to show in index.php and content-gallery.php of WordPress with Bootstrap 3.0 Carousel. But, I know it's not ...
1
vote
1answer
373 views

PHP framework building: Template parsing

I am building a PHP framework and would like to get some feedback on a few different section of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
1
vote
0answers
262 views

Passing data to JS on page load with a cookie [closed]

I am starting a class that will pass data from the server to javascript. Right now it uses a cookie which it destroys on page load. This avoids adding items to the DOM, writing javascript, or making a ...
1
vote
0answers
40 views

Remapping Heading Angle to Coordinates to Move By

I wrote the following code to take the heading of an object, and determine which direction (x,y) it needs to move to be heading forward in a 2D plane. I have ...
0
votes
2answers
729 views

Performance testing in PHP

I need to test performance of a function in PHP. This has to happen accurately, of course. In the end I need to know how long it takes for a function to perform. What I'm doing now: ...
2
votes
1answer
100 views

Practical advise for CMS

I'm working on a CMS system. The basis is pretty much done but before going any further I would like to know if there are things I really should change in the way I code things. I am pretty sure ...
1
vote
2answers
188 views

Image Resize/Crop Class

I've combined some of my own functions with a function I found and I'm curious to know what others think of it. It will be used to upload and resize/crop images that are jpeg, jpg, png. ...
1
vote
0answers
181 views

Unzip and move function

I'm a PHP novice and so looking for some advice on a PHP function I have created to use within a WordPress installation. As you can see from the code below, it runs when one of the admin's press ...
1
vote
2answers
152 views

Better code indentation

I'm sure code indentation is a basic requirement for correct development. I have checked out may pages to learn more and results of my coding are below. I like to share that here to receive opinions ...
1
vote
1answer
77 views

How to optimize the pagination query?

This is completely optimization question, I have a pagination query like that ...
1
vote
1answer
98 views

Given an ASCII string, replace all ASCII chars with their Cyrillic equivalents

The objective of the following PHP function is simple: given an ASCII string, replace all ASCII chars with their Cyrillic equivalents. As can be seen, certain ASCII chars have two possible ...
1
vote
1answer
318 views

PHP - Redirect based on OS optimization

I'm new to PHP and I would like to redirect the visitors of my website based on their operating system. Below is my solution. Is there anything that needs to be optimized? ...
2
votes
1answer
109 views

Optimize Clock Update Code To Prevent Bottleneck Resulting In Time Lost

I use the following PHP Code to output the user's local time and the servers time (office time). $local_time and $remote_time ...
1
vote
2answers
502 views

Basic PHP comment form: what ways can I improve security, efficiency/cleanliness, or conventionality?

I am a programming novice. I've written this simple PHP script to run a very basic comment form and would appreciate any feedback, especially on these three topics: Efficiency (not sure the right ...
0
votes
1answer
195 views

PHP File Serving code

I've been writing a small site which is essentially just a service API for other applications but deals with the caching and serving of files. In an effort to make the site as scalable and ...