1. Go to this page and download the library: Download javanile/schemadb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
javanile / schemadb example snippets
// library namespace
use Javanile\Moldable\Database;
// initialize a database connection object
$db = new Database([
'host' => 'localhost',
'dbname' => 'db_marketing',
'username' => 'root',
'password' => 'p4ssw0rd',
'prefix' => 'prefix_',
]);
// '$db' is ready to use for your manipulation
// library namespace
use Javanile\Moldable\Storable;
// define ORM class-model
class Customer extends Storable
{
public $id = self::PRIMARY_KEY;
public $name = '';
}
// instance empty object
// database tables and fields are automatic generated
// or updated if change Customer class
$customer = new Customer();
// assign values
$customer->name = 'Franky Franco';
// now object persist on DB
$customer->store();
// '$db' is pre-connected database object (follow: 'How to: Connect to database')
// apply method send queries to create
// or align database to defined schema
$db->apply([
// customer table name
'Customer' => [
// customer fields
'id' => $db::PRIMARY_KEY, // define field as a primary key
'name' => '', // empty string define field as VARCHAR
'points' => 0, // 0 (zero) define field as INT(11)
'born' => $db::DATE, // use to define as date field
'bio' => $db::TEXT, // text for large string and contents
],
// products table name
'Products' => [
// products fields
'id' => $db::PRIMARY_KEY, // define field as a primary key
'name' => '', // empty string define field as VARCHAR
'price' => .0, // for float number init field with point-zero ".0"
],
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.