PHP code example of damacisaac / zf2-osd-entity

1. Go to this page and download the library: Download damacisaac/zf2-osd-entity 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/ */

    

damacisaac / zf2-osd-entity example snippets



use OsdEntity\BasicEntity;

class MyEntity extends BasicEntity { ... }

$myEntity->fill(
    array(
        'firstName' => 'Angus',
        'lastName' => 'MacIsaac',
        'excludedAttributeOne' => 'wontBeSet',
    ),
    array(
        'excludedAttributeOne',
    ));

MyEntity::create(
    array(
        'firstName' => 'Angus',
        'lastName' => 'MacIsaac',
        'excludedAttributeOne' => 'wontBeSet',
    ),
    array(
        'excludedAttributeOne',
    ));

$myEntity->update(
    array(
        'firstName' => 'Angus',
        'lastName' => 'MacIsaac',
        'excludedAttributeOne' => 'wontBeSet',
    ),
    array(
        'excludedAttributeOne',
    ));

protected $this->attributes = array(
    'firstName',
    'lastName'
);

protected $this->relations = array(
    'friends' => self::RELATION_MANY,
    'profile' => self::RELATION_ONE
);

$myUser->toArray(array('friends.job', 'friends.car'))

$myUser->toArray(array('friends'));

public function getDate()
{
    return $this->date()->format(\DateTime::W3C);
}

public function toArray(array $with = array())
{
    $result = parent::toArray($with);

    /* Add custom attributes */

    return $result;
}
sh
php composer.phar update