PHP code example of unclecheese / mock-dataobjects

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

    

unclecheese / mock-dataobjects example snippets


class StaffMember extends DataObject {

	private static $db = array (
		'FirstName' => 'Varchar(255)',
		'LastName' => 'Varchar(255)',
		'EmailAddress' => 'Varchar(255)',
		'Address' => 'Varchar(255)',
		'City' => 'Varchar(255)',
		'PostalCode' => 'Varchar(255)',
		'Country' => 'Varchar(255)',
		'Company' => 'Varchar(255)',
		'Website' => 'Varchar(255)',
		'PhoneNumber' => 'Varchar(255)',
	);


	private static $has_one = array (
		'Photo' => 'Image',
		'StaffHolder' => 'StaffHolder',
	);
}

$staff = new StaffMember();
$staff->fill();

$myDataObject->fill();

$myDataObject->fill(array(
	 'only_empty' => true, // only fill in empty fields
	 ' relations, limit creation
	 'download_images' => false, // Don't download images from the web. Use existing.
));

i18n::set_locale('en_US');
$staff = new StaffMember();
$staff->fill();
echo $staff->PhoneNumber; // (102) 806-3915

i18n::set_locale('fr_FR');
$staff = new StaffMember();
$staff->fill();
echo $staff->PhoneNumber; // +33 8 17 54 64 62