1. Go to this page and download the library: Download mattvb91/lightmodel 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/ */
mattvb91 / lightmodel example snippets
$pdo = new PDO(/* Your PDO params*/);
LightModel::init($pdo);
namespace Project;
use mattvb91\LightModel\LightModel;
class User extends LightModel
{
//
}
namespace Project;
use mattvb91\LightModel\LightModel;
class User extends LightModel
{
public $username;
public function getValues()
{
return [
'username' => $this->username,
];
}
}
$user = new User();
$user->username = 'Name';
$user->save();
$filter = [
LightModel::FILTER_ORDER => 'id DESC',
];
$userKeys = User::getKeys($filter);
//We now have an array consisting of all the primary keys that
//match our criteria
foreach($userKeys as $primaryKey)
{
//Load the full individual record for further processing
$user = User::getOneByKey($primaryKey);
}
Class::getOneByKey($key)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.