Orgasmist
Newbie
- Apr 15, 2021
- 10
- 5
Hey guys!
All this section seems to consist of 1 thing. Asking for decompiling. So I decided to share something actually useful.
So when you are writing database part of your scripts, how do you secure your queries to prevent SQL Injections? You most likely use PDO or Prepared Statements, and sanitize your data before.
I have found a really good ORM (Called Idiorm) to handle this. It sanitizes, automatically constructs prepared statements, and MAINLY, it allows you to use the data as PHP OBJECTS. This has saved me tons of time and headache, and have been using this for a year.
Here is the link of the GIT project: https://github.com/j4mie/idiorm
Here you can find docs and basic examples: https://idiorm.readthedocs.io/en/latest/
Instead of writing 10+ of lines with PDO, you can do it in 1 line, and use as OBJECTS, like:
Or since it return it as object, you could even just do this:
You save/edit/delete data the same easy way using this. And it does all the prepared statements for you, including pre-sanitization.
I hope someone actually looks into this, and it makes your life easier too.
Thank you.
All this section seems to consist of 1 thing. Asking for decompiling. So I decided to share something actually useful.
So when you are writing database part of your scripts, how do you secure your queries to prevent SQL Injections? You most likely use PDO or Prepared Statements, and sanitize your data before.
I have found a really good ORM (Called Idiorm) to handle this. It sanitizes, automatically constructs prepared statements, and MAINLY, it allows you to use the data as PHP OBJECTS. This has saved me tons of time and headache, and have been using this for a year.
Here is the link of the GIT project: https://github.com/j4mie/idiorm
Here you can find docs and basic examples: https://idiorm.readthedocs.io/en/latest/
Instead of writing 10+ of lines with PDO, you can do it in 1 line, and use as OBJECTS, like:
Code:
<?php
$person = ORM::for_table('person')->where('name', 'Fred Bloggs')->find_one();
Or since it return it as object, you could even just do this:
Code:
if(ORM::for_table("accounts")->where("username", $_POST["username"])->find_one()) {
$problems[] = "Username is already taken by another user. Please try to pick a different one";
}
You save/edit/delete data the same easy way using this. And it does all the prepared statements for you, including pre-sanitization.
I hope someone actually looks into this, and it makes your life easier too.
Thank you.