CodeClerks

dynamicPDO, fully dynamic, customizable & prepared OOP PDO PHP MYSQL script for $125

Level 1
Attention: The owner of this service has not logged into CodeClerks for more than 30 days. It is highly recommend that you contact them before ordering this service. Last Login: 796 days ago

dynamicPDO, fully dynamic, customizable & prepared OOP PDO PHP MYSQL script

These few lightweight PHP scripts are all you need to start any PHP MySQL project in the most practical OOP style, fully dynamic with strictly prepared statements.

You declare your tables fields once, your methods once (such as find by id, find all, find by keywords, insert, update and delete) and you use them everywhere by just calling the functions and your variables.

All common methods are already declared for you and you can easily adapt them for your own tables and needs.

No more SQL in your code, no more static complex local functions.

dynamicPDO is the only framework you need to freely and securely develop your PHP applications in any directions without any limits.

The package is comprised of 6 simple easy to grasp lightweight php scripts, and 1 instruction text file (readme.pdf).

They are the following:

1. account.php, an example class script that matches the MySQL "accounts" table (also included) and where you declare your table fields and your methods. Most common methods such as find by id, find all, find by multiple fields, find by keywords, insert, update and delete are all already included! All methods are extremely simple and intuitive to write.

2. constants.php where you declare your database connection constants: server name, DB name, user, user password.

3. db_connect.php which calls constants.php and sets up the connection to your DB.

4. initialize.php which is the only script you need to call wherever you want to access and manipulate your DB. initialize.php calls all the other scripts.

5. index.php which implement the whole thing and show you the use of the different methods declared in your class script (account.php). index.php is very similar to the presentation below. It is only meant as an example.

6. account.sql which is the DB table we are using in all the following examples and that you can import into your DB for immediate use.

7. readme.pdf which explains in details how to implement the whole package as well as duplicate and adapt your class script (account.php) to any table of your DB.


How does it work?

1. Declare your table's fields in your class script: account.php

class Account {
protected static $table_name="accounts";
static $db_fields = array('id', 'email', 'password', 'status', 'name', 'birth_year');
...
}

2. Declare and use your methods in your class script and call them from anywhere


Ex: insert row

Method is already declared for you, call it from anywhere like this:

$name = "Jenny";
$birth = "2005";
$values = array('name' => $name, 'birth_year' => $birth);
Account:: pdo_create($values);


Ex: update row

Method is already declared for you, call it from anywhere like this:

$id = "3";
$status = "member";
$birth = "1971";
$values = array('status' => $status, 'birth_year' => $birth);
Account:: pdo_update($values, $id);


Ex: retrieve all rows

Declare the method in account.php

public static function find_all() {
return self:: pdo_exe("SELECT * FROM accounts order by id ASC");
}

Call the method from anywhere, for example from index.php, and echo the results

$accounts = Account::find_all();
foreach ($accounts as $account) {
$id = $account->id;
$email = $account->email;
$status = $account->name;
$name = $account->status;
$birth_year = $account->birth_year;
echo $id . " - " . $email . " - " . $status . " - " . $name . " - " . $birth_year . "";
}


Ex: retrieve a single row by ID

Declare the method in account.php

public static function find_by_id($id=0) {
global $con;
$sql = "SELECT * FROM accounts WHERE id=? LIMIT 1";
$qry = $con->prepare($sql);
$qry->bindValue(1, $id);
$my_array = self:: pdo_exe_bind($qry);
return !empty($my_array) ? array_shift($my_array)
false;
}

Call the method from anywhere, ex. index.php, and echo the results

$id_lookup = 4;

$account = Account::find_by_id($id_lookup);
$id = $account->id;
$email = $account->email;
$status = $account->name;
$name = $account->status;


Tags

Pdo Php Mysql Dynamic Prepared Statements Oop

0.0

0 reviews

Rating breakdown


Other services by tuancharlie

$125 - In stock