Skip to content
Francesco Bianco edited this page Oct 3, 2017 · 10 revisions

Store object

To save an object in the database, you must use a model class that extends Storable

use Javanile\Moldable\Storable;
class People extends Storable 
{
  public $id = self::PRIMARY_KEY;
  public $name = ''; 
}

Store object as is

$frank = new People();
$frank->name = 'Frank';
$frank->store();

Load object

To load objects from database, you must use a model class that extends Readable or Storable

use Javanile\Moldable\Readable;
class People extends Readable 
{
  public $id = self::PRIMARY_KEY;
  public $name = ''; 
}

Load object by primary key

$primaryKey = 1;
$frank = People::load($primaryKey)