本文整理汇总了PHP中Foo::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Foo::save方法的具体用法?PHP Foo::save怎么用?PHP Foo::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foo
的用法示例。
在下文中一共展示了Foo::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select
$finder = sfPropelFinder::from('Category c')->
select(array('c.Id', 'c.Name'), sfModelFinder::ASSOCIATIVE);
$categories = $finder->find();
$t->is($finder->getLatestQuery(), propel_sql('SELECT [P12category.ID, ]category.ID AS "c.Id", category.NAME AS "c.Name" FROM category'), 'select(array) accepts complete column names with table aliases');
$cat1 = array_shift($categories);
$t->is_deeply(array_keys($cat1), array('c.Id', 'c.Name'), 'Each row returned by find() after select(array) is an associative array where the keys are the requested complete column names with table aliases');
$finder = sfPropelFinder::from('Category')->
select(array('Id','Name'));
$categories = $finder->find();
$cat1 = array_shift($categories);
$t->is_deeply(array_keys($cat1), array('Id', 'Name'), 'select(array) uses the associative mode by default');
$foo1 = new Foo();
$foo1->setReallylongcolumnnameforassoctesting('long1');
$foo1->save();
// fix for a bug/limitation in pdo_dblib where it truncates columnnames to a maximum of 31 characters when doing PDO::FETCH_ASSOC
$finder = sfPropelFinder::from('Foo')->
select(array('Foo.Reallylongcolumnnameforassoctesting'));
$foo = $finder->findOne();
$t->is_deeply($foo, array('Foo.Reallylongcolumnnameforassoctesting' => 'long1'), 'select() does not mind long column names');
/********************************************************/
/* sfPropelFinder::select(array, sfModelFinder::SIMPLE) */
/********************************************************/
$t->diag('sfPropelFinder::select(array, sfModelFinder::SIMPLE)');
ArticlePeer::doDeleteAll();
CategoryPeer::doDeleteAll();
示例2: testDoubleReference
public function testDoubleReference()
{
$x = new Foo();
$x->x = 1;
$x->bar = new Foo();
$x->save();
$this->assertTrue(getconnection()->getCollection('Foo')->is($x->bar));
}
示例3: testTxnQo
public function testTxnQo()
{
$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 = "sean";
$foo->save();
$tx_foo = Foo::Q($tx_cnx)->getById($foo->id)->exec();
$this->assertEquals($foo->name, $tx_foo->name);
$notx_foo = Foo::Q()->getById($foo->id)->exec();
$this->assertTrue(empty($notx_foo));
$tx_cnx->commitTxn();
$notx_foo = Foo::Q()->getById($foo->id)->exec();
$this->assertEquals($foo->name, $notx_foo->name);
}
示例4: testRetrieveWithManyImplicit
public function testRetrieveWithManyImplicit()
{
$thing = new Thing();
$thing->name = 'mything';
$thing->save();
$foo = new Foo();
$foo->name = 'sean';
$foo->save();
$thing->associateWith($foo);
$foo = new Foo();
$foo->name = 'sammy';
$foo->save();
$thing->associateWith($foo);
$thing = new Thing($thing->id);
$thing->retrieve();
$foos = $thing->foos;
$this->assertTrue(is_array($foos));
$this->assertEquals('sean', $foos[0]->name);
$this->assertEquals('sammy', $foos[1]->name);
}
示例5: array
echo "Foo::find(null, array('name' => 'desc'));";
var_dump(Foo::find(null, array('name' => 'desc')));
echo "Foo::find(1);";
var_dump(Foo::find(1));
echo "Foo::find(array('name' => 'bar'));";
var_dump(Foo::find(array('name' => 'bar')));
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);