當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。