Esempio n. 1
0
<?php

require 'bootstrap.php';
require 'LazyRecord/ConfigLoader.php';
$dbLoader = new LazyRecord\ConfigLoader();
$dbLoader->load(__DIR__ . '/.lazy.yml');
$dbLoader->init();
$todo = new Todos\Model\Todo();
$ret = $todo->create(array('title' => 'Sample A'));
if (!$ret->success) {
    echo $ret;
}
echo $ret->message, "\n";
$todos = new Todos\Model\TodoCollection();
foreach ($todos as $todo) {
    echo $todo->id, ' - ', $todo->title, "\n";
}
// for more details, please see documentation in doc/
Esempio n. 2
0
<?php

require 'bootstrap.php';
$config = new LazyRecord\ConfigLoader();
$config->load('../.lazy.yml');
$config->init();
ActionKit\RecordAction\BaseRecordAction::createCRUDClass('Product\\Model\\ProductCategory', 'Create');
ActionKit\RecordAction\BaseRecordAction::createCRUDClass('Product\\Model\\ProductCategory', 'Update');
ActionKit\RecordAction\BaseRecordAction::createCRUDClass('Product\\Model\\Category', 'Create');
ActionKit\RecordAction\BaseRecordAction::createCRUDClass('Product\\Model\\Category', 'Update');
ActionKit\RecordAction\BaseRecordAction::createCRUDClass('Product\\Model\\ProductType', 'Create');
ActionKit\RecordAction\BaseRecordAction::createCRUDClass('Product\\Model\\ProductType', 'Update');
// handle actions
if (isset($_REQUEST['action'])) {
    try {
        $container = new ActionKit\ServiceContainer();
        $runner = new ActionKit\ActionRunner($container);
        $result = $runner->run($_REQUEST['action']);
        if ($result && $runner->isAjax()) {
            // Deprecated:
            // The text/plain seems work for IE8 (IE8 wraps the
            // content with a '<pre>' tag.
            header('Cache-Control: no-cache');
            header('Content-Type: text/plain; Charset=utf-8');
            // Since we are using "textContent" instead of "innerHTML" attributes
            // we should output the correct json mime type.
            // header('Content-Type: application/json; Charset=utf-8');
            echo $result->__toString();
            exit(0);
        }
    } catch (Exception $e) {