1. Go to this page and download the library: Download erickfirmo/phpmodel 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/ */
erickfirmo / phpmodel example snippets
use ErickFirmo\Model;
// Requires composer autoloader
g a class for the entity
class Car extends Model {
protected $table = 'cars';
protected $fillable = [
'name',
'company',
'year',
'plate',
'color'
];
}
// Insert register example, returns boolean
$saved = (new Car())->insert([
'name' => $name,
'company' => $company,
'year' => $year,
'plate' => $plate,
'color' => $color,
]);
// Select register example, returns collection
$cars = (new Car())->select()
->where('year', '=', $year)
->get();
// Returns all columns from `cars` table
$cars = (new Car())->select()
->get();
// Returns specific columns from model table
$cars = (new Car())->select(['name', 'company', 'year'])
->get();
$cars = (new Car())->select()
->where('company', '=', $company)
->get();