本文整理汇总了PHP中Doctrine_Query::fetchOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::fetchOne方法的具体用法?PHP Doctrine_Query::fetchOne怎么用?PHP Doctrine_Query::fetchOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::fetchOne方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveAsso
public function retrieveAsso(Doctrine_Query $q)
{
$alias = $q->getRootAlias();
$q->select("{$alias}.name, {$alias}.login, {$alias}.description, {$alias}.logo, {$alias}.salle, {$alias}.phone, {$alias}.facebook, p.id, p.asso_id, p.couleur");
$q->leftJoin("{$alias}.Pole p");
return $q->fetchOne();
}
示例2: fetchOne
public function fetchOne($params = array(), $hydrationMode = null)
{
$breadcrumb = $this->getBreadcrumb();
$result = parent::fetchOne($params, $hydrationMode);
$this->restoreBreadcrumb($breadcrumb);
return $result;
}
示例3: testInlineMultiple
public function testInlineMultiple()
{
$yml = <<<END
---
DC147_Multiple:
ISBN2:
name: isbn2
ISBN3:
name: isbn3
DC147_Product:
Product_1:
name: book3
MultipleValues:
Multi_1:
value: 123345678
Multiple: ISBN2
Multi_2:
value: 232323233
Multiple: ISBN3
Product_2:
name: book4
MultipleValues:
Multi_3:
value: 444455555
Multiple: ISBN2
Multi_4:
value: 232323233
Multiple: ISBN3
END;
try {
file_put_contents('test.yml', $yml);
Doctrine_Core::loadData('test.yml', true);
$this->conn->clear();
$query = new Doctrine_Query();
$query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book3');
$product = $query->fetchOne();
$this->assertEqual($product->name, 'book3');
$this->assertEqual($product->MultipleValues->count(), 2);
$this->assertEqual($product->MultipleValues[0]->value, '123345678');
$this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
$this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
$query = new Doctrine_Query();
$query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book4');
$product = $query->fetchOne();
$this->assertEqual($product->name, 'book4');
$this->assertEqual($product->MultipleValues->count(), 2);
$this->assertEqual($product->MultipleValues[0]->value, '444455555');
$this->assertEqual($product->MultipleValues[1]->value, '232323233');
$this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
$this->assertEqual(is_object($product->MultipleValues[1]->Multiple), true);
$this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
$this->assertEqual($product->MultipleValues[1]->Multiple->name, 'isbn3');
$this->pass();
} catch (Exception $e) {
$this->fail();
}
unlink('test.yml');
}
示例4: testTicket
public function testTicket()
{
Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
$q = new Doctrine_Query();
$q->select('s.*')->from('Ticket_1116_User s')->where('s.username = ?', array('test'));
// to see the error switch dbh to a real db, the next line will trigger the error
$test = $q->fetchOne();
//will only fail with "real" mysql
$this->assertFalse($test);
$sql = $q->getSqlQuery();
// just getSql()?!?! and it works ? the params are ok after this call
$params = $q->getFlattenedParams();
$this->assertEqual(count($params), 1);
// now we have array('test',null) very strange .....
$this->assertEqual($sql, "SELECT u.id AS u__id, u.username AS u__username, u.deleted_at AS u__deleted_at FROM user u WHERE (u.username = ? AND (u.deleted_at IS NULL))");
$this->assertEqual($params, array('test'));
//now also this works! (always works witch mock only fails with mysql)
$test = $q->fetchOne();
$this->assertFalse($test);
Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, false);
}
示例5: fetchOne
public function fetchOne($params = array(), $hydrationMode = null)
{
$result = parent::fetchOne($params, $hydrationMode);
$_p = $this->getParams($params);
if ('exist' === $_p['where'][0]) {
$tpl = new myTemplate();
$tpl->fromArray(array('id' => 1, 'name' => 'exist', 'body' => 'exist', 'renderer' => 'php'));
return $tpl;
} elseif ('empty' === $_p['where'][0]) {
$tpl = new myTemplate();
$tpl->fromArray(array('id' => 1, 'name' => '', 'body' => '', 'renderer' => 'php'));
return $tpl;
}
return $result;
}
示例6: testBug
public function testBug()
{
$person = $this->newPerson('Fixe');
$profile = $this->newProfile('Work', $person);
$guardUser = $person->get('sfGuardUser');
$id = $guardUser->get('id');
$guardUser->free();
$query = new Doctrine_Query();
$query->select('s.*, p.*, ps.*');
$query->from('sfGuardUser s');
$query->innerJoin('s.Person p');
$query->leftJoin('p.Profiles ps');
$query->where('s.id = ?', $id);
$user = $query->fetchOne();
$array = $user->toArray(true);
$this->assertEqual($array['id'], 1);
$this->assertEqual($array['name'], 'Fixe');
$this->assertTrue(isset($array['Person']['Profiles'][0]));
}
示例7: routeTest10
public function routeTest10(Doctrine_Query $q)
{
$q->orWhere($q->getRootAlias() . '.is_on_homepage = ?', 0);
return $q->fetchOne();
}
示例8: fetchOne
public function fetchOne($params = array(), $hydrationMode = null)
{
$this->limit(1);
return parent::fetchOne($params, $hydrationMode);
}
示例9: retrieveActiveJob
public function retrieveActiveJob(Doctrine_Query $q)
{
$q->andWhere('a.expires_at > ?', date('Y-m-d H:i:s', time()));
return $q->fetchOne();
}
示例10: testFetchingCtiRecordsSupportsLimitSubqueryAlgorithm
public function testFetchingCtiRecordsSupportsLimitSubqueryAlgorithm()
{
$record = new CTITestOneToManyRelated;
$record->name = 'Someone';
$record->cti_id = 1;
$record->save();
$this->conn->clear();
$q = new Doctrine_Query();
$q->from('CTITestOneToManyRelated c')->leftJoin('c.CTITest c2')->where('c.id = 1')->limit(1);
$record = $q->fetchOne();
$this->assertEqual($record->name, 'Someone');
$this->assertEqual($record->cti_id, 1);
$cti = $record->CTITest[0];
$this->assertEqual($cti->id, 1);
$this->assertEqual($cti->name, 'Jack Daniels');
$this->assertEqual($cti->verified, true);
$this->assertTrue(isset($cti->added));
$this->assertEqual($cti->age, 13);
}
示例11: retrieveActiveJob
public function retrieveActiveJob(Doctrine_Query $query)
{
$query->addWhere('a.expires_at > ?', date('Y-m-d H:i:s', time() - 86400 * sfConfig::get('app_active_days')));
return $query->fetchOne();
}
示例12: retrieveForRoute
public function retrieveForRoute(Doctrine_Query $q)
{
$q->leftJoin($q->getRootAlias() . '.Articles');
return $q->fetchOne();
}