本文整理匯總了PHP中Foo::retrieve方法的典型用法代碼示例。如果您正苦於以下問題:PHP Foo::retrieve方法的具體用法?PHP Foo::retrieve怎麽用?PHP Foo::retrieve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Foo
的用法示例。
在下文中一共展示了Foo::retrieve方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBelongsToWithImmediate
public function testBelongsToWithImmediate()
{
$t = new Thing();
$t->name = "sean";
$t->save();
$f = new Foo();
$f->name = "kate";
$t->associateWith($f);
$t1 = new Thing($t->id);
$t1->retrieve();
$f1 = new Foo($f->id);
$f1->retrieve(array('with' => array('thing' => array('join_strategy' => 'Immediate'))));
$this->assertTrue($t1->equals($f1->thing));
}
示例2: indirect
}
function indirect($other)
{
echo __METHOD__ . "\n";
$this = $other;
$result = $this = $other;
print $result->prop;
print $this->prop;
}
function retrieve(&$other)
{
echo __METHOD__ . "\n";
$other = $this;
}
}
$object = new Foo();
$object->prop = "Hello\n";
$other = new Foo();
$other->prop = "World\n";
$object->replace($other);
$object->indirect($other);
print $object->prop;
// still shows 'Hello'
$object->retrieve($other);
print $other->prop;
// shows 'Hello'
?>
===DONE===
--EXPECTF--
Fatal error: Cannot re-assign $this in %s on line %d, position %d
示例3: testTxInsertRollback
public function testTxInsertRollback()
{
$tx_cnx = $this->getCnxForTxn();
# begin a new cnx
$tx_cnx->beginTxn();
# create and save a foo on our new cnx
$foo = new Foo();
$foo->_setDb($tx_cnx);
$foo->name = "joe";
$foo->save();
# should be visible from txn
$tx_foo = new Foo($foo->id);
$tx_foo->_setDb($tx_cnx);
$ex = null;
try {
$tx_foo->retrieve();
} catch (Exception $e) {
$ex = $e;
}
$this->assertTrue(is_null($ex));
$this->assertEquals($foo->name, $tx_foo->name);
# rollback
$tx_cnx->rollbackTxn();
# should no longer be visible in txn
$tx_foo = new Foo($foo->id);
$tx_foo->_setDb($tx_cnx);
$ex = null;
try {
$tx_foo->retrieve();
} catch (Exception $e) {
$ex = $e;
}
$this->assertTrue(is_a($ex, 'Pfw_Exception_NotFound'));
}