Kindly review my code

・1 min read

I added some code on github a few weeks back(My first repo, actually) and I'd love some review on it. You don't necessarily have to contribute, you could just tell me what you think I should be doing and what I shouldn't be doing. I'm still adding more code so the project isn't complete yet. Criticism and roasting are allowed. This is the URL https://github.com/youngestdj/alumni

DISCUSS (7)
 

Quick 'review' is that

  1. It should be best if you would separate the 'views' from the business logic
  2. The database class isn't using prepared statements so you're exposed to SQL injection of sorts.
 

Thanks for the review. I used prepared statements in the database class. perhaps you missed it.

[img]thepracticaldev.s3.amazonaws.com/i...

 

My bad on the prepared statements, somehow I missed the : when doing the string concatenation on where

github.com/youngestdj/alumni/blob/...

However I am confused about that since the docs say ->where should be used like ->where("firstname='Jessam'") , but ->where directly accepts that as the argument $this->where = $arg; and in the code you have

if(!empty($this->where)) {
    $keys = join(array_keys($this->where),"");
    $query.=" WHERE {$keys} = :{$keys}";
}

Oh! The where clause was originally designed to accept a string as an argument. I later updated it to accept arrays. I forgot to update the doc.


$db=parent::select("password")->from("users")->where(array("email" =>self::$email))->result();

This is how it should be used.

 

Seems alright to me, I saw Nigerian pidgin in your code something like loginDey(). 😅

 

Lmao. It's cookieDey(). Didn't know I'll be putting the code online when I did that. Thanks for the feedback

 
Classic DEV Post from Aug 31 '18

How do you stop the desire to learn too much?

Example: While you are learning a specific thing ( language, framework, new tec...

Web developer passionate about the web. Constantly reading and learning stuff.

dev.to is where software developers stay in the loop and avoid career stagnation.

Sign up (for free)