PHP code example of php-platform / persist

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

    

php-platform / persist example snippets



use PhpPlatform\Persist\Model;


/**
 * @tableName t_normal1
 * @prefix TNormal1
 */
class TNormal1 extends Model {
    /**
     * @columnName F_PRIMARY_ID
     * @type integer
     * @primary
     * @autoIncrement
     * @get
     */
    private $fPrimaryId = null;

    /**
     * @columnName F_VARCHAR
     * @type varchar
     * @set
     * @get
     */
    private $fVarchar = null;

    /**
     * @columnName F_FOREIGN
     * @type integer
     * @set
     * @get
     */
    private $fForeign = null;


    function __construct($fPrimayId = null){
        $this->fPrimaryId = $fPrimayId;
        parent::__construct();
    }

    static function create( $fVarchar, $fForeign){
        $this->fVarchar = $fVarchar;
        $this->fForeign = $fForeign;
        parent::create();
    }

    static function find($filters){
        return parent::find($filters);
    }

    function delete(){
        parent::delete();
    }

    function setAttribute($name,$value){
        $args = array();
        $args[$name] = $value;
        $attrValues = $this->setAttributes($args);
    }

    function setAttributes($args){
        parent::setAttributes($args);
    }

    function getAttribute($name){
        $args = array();
        $args[] = $name;
        $attrValues = $this->getAttributes($args);
        return $attrValues[$name];
    }

    function getAttributes($args){
        return parent::getAttributes($args);
    }

}