1. Go to this page and download the library: Download windwalker/record 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/ */
windwalker / record example snippets
<?
class SakuraRecord extends Record
{
protected $casts = [
'id' => 'int',
'price' => 'string',
'created' => 'datetime',
'modified' => 'timestamp',
'images' => 'object', // or array will be json decoded
'params' => \Windwalker\Structure\Structure::class,
'other' => ['SomeClass', 'handle'] // Use callback
];
}
$sakuraRecord->load(3);
$sakuraRecord->id; // 3
$sakuraRecord->price; // '1200.00'
$sakuraRecord->created->format('Y/d/m'); // Auto convert to DateTime object
$sakuraRecord->modified; // 1497067876
$sakuraRecord->images[0]->url; // Store json in DB, can will auto decode to object.
$sakuraRecord->params->get('foo.bar'); // Use class name to store value to object
php
use Windwalker\Record\Record;
// Record object for users table
$user = new Record('users');
php
$user->load(25); // Load by primary key
$user->load(array('alias' => $alias)); // Load by field name.
php
class UserRecord extends Record
{
public function onAfterLoad(Event $event)
{
$this->foo = array('a', 'b', 'c');
}
}
php
// Use listener object
$record->getDispatcher()->addListener(new MyRecordListener);
// Use callback
$record->getDispatcher()->listen('onAfterStore', function (Event $event)
{
// Process your logic
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.