Esempio n. 1
0
if (++$counter == $test || $test == null) {
    $mark = microtime(true);
    for ($i = 0; $i < 1000; $i++) {
        $rs = lmbActiveRecord::find('Foo', array('proxy' => true));
        foreach ($rs as $obj) {
            $foo = $obj->bar;
        }
    }
    echo "{$counter}) lmbActiveRecord fetching(proxied), attr access: " . (microtime(true) - $mark) . "\n";
}
if (++$counter == $test || $test == null) {
    $mark = microtime(true);
    $rs = lmbActiveRecord::find('Foo');
    for ($i = 0; $i < 1000; $i++) {
        foreach ($rs as $obj) {
            $foo = $obj->bar;
        }
    }
    echo "{$counter}) lmbActiveRecord fetching(out of loop), attr access: " . (microtime(true) - $mark) . "\n";
}
if (++$counter == $test || $test == null) {
    $mark = microtime(true);
    for ($i = 0; $i < 1000; $i++) {
        $rs = Foo::find();
        foreach ($rs as $obj) {
            $foo = $obj->get('bar');
        }
    }
    echo "{$counter}) Foo fetching, getter: " . (microtime(true) - $mark) . "\n";
}
@unlink($db);
Esempio n. 2
0
echo "Foo::count(array('name' => 'bar'));";
var_dump(Foo::count(array('name' => 'bar')));
echo "Foo::find(array('name' => 'ba%'));";
var_dump(Foo::find(array('name' => 'ba%')));
echo "Foo::find(null, null, 1);";
var_dump(Foo::find(null, null, 1));
echo '<hr>';
$foo = new Foo(null, 'miam');
var_dump($foo->isNew());
$foo->save();
$foo = Foo::find($foo->id);
var_dump($foo);
$foo->name = 'miam 2';
$foo->save();
$foo = Foo::find($foo->id);
var_dump($foo);
$foo->delete();
$foo = Foo::find($foo->id);
var_dump($foo);
echo '<hr>';
$property = new ReflectionProperty('Foo', 'em');
$property->setAccessible(true);
$property->setValue(null);
$property = new ReflectionProperty('Foo', 'table');
$property->setAccessible(true);
$property->setValue('foo2');
$property = new ReflectionProperty('Foo', 'fields');
$property->setAccessible(true);
$property->setValue('name,location');
echo "Foo::getEntityManager();";
var_dump(Foo::getEntityManager());