2017 © Pedro Peláez
 

library lib-datamodel

Implements a callable object from an array of data that can be extended to implement inline formatting.

image

openlss/lib-datamodel

Implements a callable object from an array of data that can be extended to implement inline formatting.

  • Wednesday, May 8, 2013
  • by nullivex
  • Repository
  • 3 Watchers
  • 0 Stars
  • 73 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

openlss/lib-datamodel

Implements a callable object from an array of data that can be extended to implement inline formatting., (*1)

Real Name

A real name users all lower case with underscores in place of spaces Example, (*2)

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

All data array members must use this naming., (*3)

Camel Name

A camel name is generally used when calling functions Example, (*4)

echo $this->getMyRealNameHere();

Both are used and generated in this class, so make sure they are properly provided and formatted., (*5)

There are helper functions that can be used below to convert names., (*6)

Usage

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'

Methods

$this DataModel::_setup($arr)

Sets the data array to use and instantiates the object NOTE: should be single dimensional associative array, multidimensional arrays will be treated as a single dimensional array with array values, (*7)

$this DataModel::_setData($arr)

Used to set data same as above but on an existing object, (*8)

(array) DataModel::_getColumns($cols=array(),$flags=DataModel::KEYS_ASSOC)

Used to retrieve a specific set of columns $cols should be an array of column names (real_name) Accepts the same flags as _getAll(), (*9)

(array) DataModel::_getAll($flags=DataModel::KEYS_ASSOC)

Returns an array similar to that used in _setData except all the values are passed through getters. Flags can be one of the following * DataModel::KEYS_ASSOC return will be an associative array * DataModel::KEYS_NUMERIC return will be a numeric array Example, (*10)

$row = $obj->getAll();

(string) DataModel::_camelName($name,$prefix=null)

When passed a real_name it returns the camel name A prefix can be passed to get a usable function name Example, (*11)

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

(string) DataModel::_realName($name,$prefix=null)

Used to obtain a real_name from a function name. Example, (*12)

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

The Versions

08/05 2013

0.0.2

0.0.2.0 http://openlss.org

Implements a callable object from an array of data that can be extended to implement inline formatting.

  Sources   Download

LGPL-3.0+

The Requires

 

model data getters setters formatters

08/05 2013

dev-master

9999999-dev http://openlss.org

Implements a callable object from an array of data that can be extended to implement inline formatting.

  Sources   Download

LGPL-3.0+

The Requires

 

model data getters setters formatters

07/05 2013

dev-0.0.x-dev

dev-0.0.x-dev http://openlss.org

Implements a callable object from an array of data that can be extended to implement inline formatting.

  Sources   Download

LGPL-3.0+

The Requires

 

model data getters setters formatters

07/05 2013

0.0.1

0.0.1.0 http://openlss.org

Implements a callable object from an array of data that can be extended to implement inline formatting.

  Sources   Download

LGPL-3.0+

The Requires

 

model data getters setters formatters