Skip to content

Tweaked extension for prepared statements and queries

License

Notifications You must be signed in to change notification settings

thielicious/slimPDO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

slimPDO

Tweaked extension for prepared statements and queries


INTRODUCTION

Just a small tweaked PDO extension for my own personal use.


SETUP INFORMATION

Use your CLI and enter the following to clone:
git clone https://github.com/thielicious/slimPDO.git


USAGE

Since it's packed in a trait called DB, you only need to use it in any class you want:

if (trait_exists("DB")) { // optional
  class some_class {
    use DB;
    // ...

Now, instead of:

$stmt = $this->pdo->prepare($sql);
$stmt->execute([":param" => $value]);

Just do this:

$this->pdo->prep($sql,[":param" => $value]);

Example:

foreach ($this->pdo->prep(
	"SELECT * FROM `members` WHERE `usr_name` = :name",
	[":name" => $username]
	) as $user) {
	return $user->usr_id;
}

This extension can be used as a callback hence very useful in loops. No separate declaration needed.



Feel free to pull/edit/fork w/e.

thielicious.github.io

Releases

No releases published

Packages

No packages published

Languages