12 votes

Checking 160,000 records in a database for changes

There is multiple things that can be optimized in this code. It is pretty obvious that most time is spent in HTTP requests to remote API and in database queries, so these points should be first in ...
  • 231
5 votes
Accepted

Password reset functionality in Codeigniter 3

Some food for thought: I don't see any benefit to str_shuffle() why bother? Why bother referencing the email? If you need a random string, populate one in the ...
  • 8,269
4 votes

MVC design to fetch, store, and present data from an external source

Looks pretty good. Here are just some thoughts but nothing major: It would be more future-proof (and probably efficient) to use regular expressions in lieu of parsing hard-coded line numbers (in case ...
  • 141
4 votes

Web dashboard using many REST API requests

As Pimgd stated, all your request are synchronous (and wait that the previous one terminates before executing further). To make the calls asynchronous I see two possibilities: either the client (...
  • 1,892
4 votes
Accepted

Codeigniter 3: how can I avoid repeating this chunk of code in my controllers?

I had a very short look at lightblog/application/controllers/Pages.php and I noticed that these two values were not used in the ...
4 votes
Accepted

Codeigniter 3 Registration and Login System

There are a number of things I'd do differently and the first is a must. First, using md5() to encode a password is universally considered a bad practice. It's ...
  • 291
3 votes

Checking 160,000 records in a database for changes

This might be classified as a micro-optimization but... As handy as the Query Builder is, it runs quite a lot of code putting together a query statement. So instead of ...
  • 291
3 votes
Accepted

Volunteer Signup Page

Let's start with your controller (controllers/Volunteers.php): You have loaded list of models in __construct() which is not a good practice. Before loading list of ...
  • 196
3 votes

Web dashboard using many REST API requests

What's happening here is that if each request takes 0.3 seconds (pretty fast), the whole page takes 14 * 0.3 = 4.2 seconds to load (slow-ish). In cases like this, there's two things you could do. ...
  • 22.2k
3 votes
Accepted

Notification cron

Yes, you will miss every appointment that doesn't have :00 for seconds. And if your cron errs for any reason or skips a second, you'll miss even more. You should add another DATETIME column to your ...
3 votes

User model with user roles in Codeigniter PHP/MySQL

I think the schema is fine with one possible exception. I don't see any value in the status column in the user_user_role table. The same effect is achieved by removing the row connecting the user and ...
  • 291
3 votes
Accepted

PHP+JS Code Combining

No, it doesn't work like that because you're not escaping your PHP strings to be a safe JavaScript string. What you're doing is encoding them as JSON but if - for example - ...
3 votes

Login system with session using CodeIgniter

Validating emails is hard, and it's not a good idea to do it on your own with a regex. Here are a couple of valid email addresses you would not allow (there are a lot more): ...
  • 25k
3 votes
Accepted

Report Page on Volunteer Signup Website

Looking at your sql's you seem to be repeating the same queries in a loop. I will pick out one simple one for example, it doesn't take long to run on its own, but if you add them all up, the amount of ...
  • 2,086
3 votes

Get chat message data from table, grouped by date

Lots of little pieces of advice: Tab the lines of code inside of your loops and functions (etc) for improved readability. Only declare the $key variable in your <...
  • 8,269
3 votes

Codeigniter 3: how can I avoid repeating this chunk of code in my controllers?

In this case I would probably convert this $this->Static_model into a Config file that I can use through CI (that is what they are there for). You can even make ...
3 votes
Accepted

A contact form with CodeIgniter and Twig

Method declarations PSR-12: The opening brace MUST go on its own line Get into the habit of declaring argument types and return types whenever possible throughout your application -- it will help you ...
  • 8,269
3 votes

PHP blogging application with AJAX loading

I will briefly mention a few things I see in you're snippets. Is the code DRY enough? Given this line of code: ...
2 votes

Login system with session using CodeIgniter

It seems weird that in check_password the login would return multiple rows. I would expect only one user to be associated with a particular emails/password login. ...
  • 20.1k
2 votes

Codeigniter calling conditional data retrieval model method from controller

Readability and Usability Your function is indeed quite generic, which does give you a lot of power in your controller. But I would agree with you, that this is not necessarily a good thing. Just ...
  • 25k
2 votes

Checking 160,000 records in a database for changes

Cumbersome looping Let's just look at the two outer loops: ...
2 votes

PHP+JS Code Combining

As noted in the answer by Adriano Repetti, as you are outputing raw data into the javascript source, you could create invalid javascript. For example a quote in ...
  • 361
2 votes

Notification cron

Something you'll see sooner or later in production, although probably not in development, is duplicate emails. Even a very slight hiccup due to higher load on your end or poor performance of the ...
2 votes

MVC design to fetch, store, and present data from an external source

This is a CodeIgniter application, so I expect its submission gathering methods to be used rather than native $_GET and $_POST. ...
  • 8,269
2 votes

Building a task listing for a task manager

This is really a SQL question, I'd encourage you to keep learning true SQL because it's a skill that's invaluable and it's increasingly not learnt thanks to the popularisation of noSQL solutions and ...
  • 364
2 votes

Report Page on Volunteer Signup Website

Just some general advice: 375 queries to display 1 page does seem a lot, not only because of db execution time, but also due to transport latency and serial execution. For example: say average ...
2 votes

CodeIgniter CRUD using AJAX

I'm normally using Bonfire (an HMVC Framework on top of CodeIgniter), so I'm sometimes confused what is CodeIgniter specific and what is not. Anyway some remarks to your code: Your model is already ...
  • 131
2 votes
Accepted

Ajax table action and process

Take a step back and forget about what your code does; what does it look like? Find the text that's duplicated, then try sticking those in functions. If this code uses variables, make these arguments ...
  • 1,100
2 votes
Accepted

Codeigniter 3 micro-blogging application

Foreword I haven't used CodeIgniter in the past so I am not as well-versed with the idiomatic ways it is used but I have used similar frameworks like Laravel. I did look at the code in the github ...
2 votes
Accepted

PHP Edit Volunteer Group Form

There are a lot of possibilities laid out here, but I think I would lean towards: Idea 3 - Should I make more use of private methods within the giant controller class? Won't shrink the size of the ...

Only top scored, non community-wiki answers of a minimum length are eligible