PHP code example of triplei / c5_base_model

1. Go to this page and download the library: Download triplei/c5_base_model 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/ */

    

triplei / c5_base_model example snippets



use TripleI\C5BaseModel\BaseModel

class Widget extends BaseModel
{
    /**
     * @var string
     * @Column(type="string", nullable=true)
     */
    protected $name;
    
    /**
     * @var string
     * @Column(type="text", nullable=true)
     */
    protected $description;
}

$widget = new Widget();
$widget->name = 'testing';
$widget->save();

$widget2 = new Widget();
$widget->setData(
    [
        'name' => 'widget name',
        'description' => 'description here'
    ]
);
$widget->save();

$allWidgets = Widget::getAll();

$oddWidgets = Widget::loadByIDs([1, 3, 5]);

$singleWidget = Widget::getByID(1);
$singleWidget->destroy();