PHP code example of openlss / lib-datamodel

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

    

openlss / lib-datamodel example snippets


$arr['my_real_name_here'] = 'foo';

echo $this->getMyRealNameHere();

use \LSS\DataModel;

class MyDataModel extends DataModel {

	public function getFoo(){
		return ucwords($this->data['foo']);
	}

}

$row = array('foo'=>'test','bar'=>'foo');

$obj = MyDataModel::_setup($row);
var_dump($obj->getFoo()); //outputs 'Test'
var_dump($obj->getBar()); //outputs 'foo'

$obj->setFoo('test2');
var_dump($obj->getFoo()); //outputs 'Test2'

$row = $obj->getAll();

var_dump(DataModel::_camelName('my_name','get')); //outputs 'getMyName'
var_dump(DataModel::_camelName('my_name'); //outputs 'myName';

var_dump(DataModel::_realName('getMyName','get')); //outputs 'my_name'
var_dump(DataModel::_realName('myName')); //outputs 'my_name'