当前位置: 首页>>代码示例>>PHP>>正文


PHP Foo::save方法代码示例

本文整理汇总了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();
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:31,代码来源:sfPropelFinderSelectTest.php

示例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));
 }
开发者ID:crodas,项目名称:activemongo2,代码行数:8,代码来源:SimpleTest.php

示例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);
 }
开发者ID:seansitter,项目名称:picnicphp,代码行数:18,代码来源:Pfw_Model_Mysqli_Test.php

示例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);
 }
开发者ID:seansitter,项目名称:picnicphp,代码行数:20,代码来源:Pfw_Model_Test.php

示例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);
开发者ID:cyve,项目名称:orm,代码行数:31,代码来源:EntityTest.php


注:本文中的Foo::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。