abstract business code coder


It’s been a bit since I last revisited my code journey, so I opted to make up for some lost time by blasting through quite a few lessons in one day. To clarify what I mean by this, here are the topics:

  • PDO First Steps
  • Extract a PHP Database Class
  • Environment and Configuration
  • Database Tables and Indexes
  • Rendering Content
  • Introduction to Authentication
  • Refactoring

Clearly, there’s a lot going on here. Basically, what I’ve ended up with is a simple application that can connect to a MySQL database, retrieve content, display the content – and reject my attempts to show the content if I’m not the correct user.

I learned about SQL injections – which to be honest I’m aware of how they work (who doesn’t remember Bobby Tables), but the method in which it was mitigated in this course confuses me a bit. Basically, the query is broken up into two halves – the hardcoded half, and the user-inputted half. I get that the user input is sanitized somehow, but I’m not quite clear on that part. Historically I used to escape everything using a function that is forgotten to me now, but for this, we just made the user input an array. It worked, but I’d be lying if I said my head didn’t hurt a bit.

Another item that I finally got to see was $this. As an amateur programmer looking in from the outside, $this SEEMS to make sense? But I finally got to use it! I think I know the cases in which it’s appropriate, but only time will tell!

Finally, we used a lot of -> and => and I have to say, another one I’m not totally clear on. Unfortunately, there’s enough here that I just don’t know enough yet to be comfortable with, so I will likely rewatch these lessons just to make sure they set in. Because I’ve written all of the code, I can concentrate on just learning the lesson and taking notes instead of writing code to keep up.

One thing I am proud of is when it came to concepts I did know (like foreach, or inline echo), I paused the video and wrote the code myself before the instructor did – just to see if I could work without a crutch.

Some code blocks:

$statement = $this->connection->prepare($query);Code language: PHP (php)
$dsn = 'mysql:' . http_build_query($config, '', ';');     
$this->connection = new PDO($dsn, $username, $password, [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]);Code language: PHP (php)
$currentUserId = 3;

if ($note['user_id'] !== $currentUserId) {

require "views/note.view.php";Code language: PHP (php)
Author: Greg
Middle-aged father of two - still a kid at heart! Lover of all things geeky, trivia, factoids, craft beers, and procrastination. #SnorlaxIsMySpiritAnimal. #CanadianEh! "I don't know. Fly casual."

1 thought on “#100DaysOfCode[’12’,’BigInt’];

Leave a Reply