本文整理汇总了PHP中Doctrine_Query::parseDqlQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::parseDqlQuery方法的具体用法?PHP Doctrine_Query::parseDqlQuery怎么用?PHP Doctrine_Query::parseDqlQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::parseDqlQuery方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Doctrine_Query $query the base query
*/
public function __construct($query)
{
if (is_string($query)) {
$this->query = Doctrine_Query::create();
$this->query->parseDqlQuery($query);
} elseif ($query instanceof Doctrine_Query) {
$this->query = $query;
} else {
throw new Doctrine_Exception('Constructor argument should be either Doctrine_Query object or valid DQL query');
}
$this->query->getSqlQuery();
}
示例2: __construct
/**
* Constructs Neo_Doctrine_Paginator_Adapter
*
* @param Doctrine_Query_Abstract|string $query
* @param integer $hydratationMode Use constaints Doctrine_Core::HYDRATE_*.
* @param array[string]=>mixed $options Options may be:
* 'countQuery'-custom query for count counting. Dql or Doctrine_Query instance.
*/
public function __construct($query, $hydrationMode = null, $options = array())
{
if (is_string($query)) {
$newQuery = new Doctrine_Query();
$newQuery->parseDqlQuery($query);
$query = $newQuery;
} else {
if (!$query instanceof Doctrine_Query_Abstract) {
require_once 'Neo/Doctrine/Paginator/Adapter/Exception.php';
throw new Neo_Doctrine_Paginator_Adapter_Exception("Given query is not instance of Doctrine_Query");
}
}
$this->_query = $query;
$this->_hydrationMode = is_null($hydrationMode) ? Doctrine_Core::HYDRATE_RECORD : $hydrationMode;
//options
if (!empty($options['countQuery'])) {
if (is_string($options['countQuery'])) {
$countQuery = new Doctrine_Query();
$countQuery->parseDqlQuery($options['countQuery']);
$options['countQuery'] = $countQuery;
} else {
if (!$options['countQuery'] instanceof Doctrine_Query) {
require_once 'Neo/Doctrine/Paginator/Adapter/Exception.php';
throw new Neo_Doctrine_Paginator_Adapter_Exception("Given count-query is not instance of Doctrine_Query");
}
}
$this->_countQuery = $options['countQuery'];
$this->_countQuery->select('count(*) as count');
}
}
示例3: testJoinWithConditionAndNotInClause
public function testJoinWithConditionAndNotInClause()
{
// Related to ticket #1329
$q = new Doctrine_Query();
$q->parseDqlQuery("SELECT a.name, b.id FROM User a LEFT JOIN a.Phonenumber b WITH a.id NOT IN (1, 2, 3)");
$this->assertEqual($q->getSqlQuery(), "SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id AND (e.id NOT IN (1, 2, 3)) WHERE (e.type = 0)");
}
示例4: testSubqueryInSelectPart2
public function testSubqueryInSelectPart2()
{
// ticket #307
$q = new Doctrine_Query();
$q->parseDqlQuery("SELECT u.name, (SELECT COUNT(w.id) FROM User w WHERE w.id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1");
$this->assertNotEqual($q->getSqlQuery(), "SELECT e.id AS e__id, e.name AS e__name, (SELECT COUNT(e.id) AS e__0 FROM entity e WHERE e.id = e.id AND (e.type = 0)) AS e__0 FROM entity e WHERE e.name = 'zYne' AND (e.type = 0) LIMIT 1");
}
示例5: testDeleteWithLimitAndOffset
public function testDeleteWithLimitAndOffset()
{
$q = new Doctrine_Query();
$q->parseDqlQuery('DELETE FROM Entity LIMIT 10 OFFSET 20');
$this->assertEqual($q->getSqlQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20');
$q = new Doctrine_Query();
$q->delete()->from('Entity')->limit(10)->offset(20);
$this->assertEqual($q->getSqlQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20');
}
示例6: testUpdateSupportsConditions
public function testUpdateSupportsConditions()
{
$q = new Doctrine_Query();
$q->parseDqlQuery("UPDATE User u SET u.name = 'someone' WHERE u.id = 5");
$this->assertEqual($q->getSqlQuery(), "UPDATE entity SET name = 'someone' WHERE (id = 5 AND (type = 0))");
}
示例7: testAggregateFunctionsInHavingReturnValidSql
public function testAggregateFunctionsInHavingReturnValidSql()
{
$q = new Doctrine_Query();
$q->parseDqlQuery('SELECT u.name, COUNT(p.id) count FROM User u LEFT JOIN u.Phonenumber p GROUP BY count');
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(p.id) AS p__0 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) GROUP BY p__0');
}
示例8: testConcatInSelectClauseSupportsMoreThanTwoArgs
public function testConcatInSelectClauseSupportsMoreThanTwoArgs()
{
$q = new Doctrine_Query();
$q->parseDqlQuery("SELECT u.id, CONCAT(u.name, 'The Man', u.loginname) FROM User u");
$this->assertEqual($q->getSqlQuery(), "SELECT e.id AS e__id, CONCAT(e.name, 'The Man', e.loginname) AS e__0 FROM entity e WHERE (e.type = 0)");
}
示例9: testParameterConversionInCount
public function testParameterConversionInCount()
{
try {
$query = new Doctrine_Query($this->connection);
$ret = $query->parseDqlQuery("FROM EnumTest WHERE EnumTest.status = 'open'")->count();
$this->assertEqual($ret, 1);
} catch (Exception $e) {
$this->fail();
}
try {
$query = new Doctrine_Query($this->connection);
$ret = $query->parseDqlQuery("FROM EnumTest WHERE EnumTest.status = ?")->count(array('open'));
$this->assertEqual($ret, 1);
} catch (Exception $e) {
$this->fail($e->getMessage());
}
}
示例10: testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords
public function testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords()
{
$this->connection->clear();
$q = new Doctrine_Query();
$q->parseDqlQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id');
$this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id, COUNT(p.id) AS p__0, MAX(p.phonenumber) AS p__1 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) GROUP BY e.id');
$users = $q->execute();
$this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY);
$this->assertEqual($users[0]->Phonenumber[0]->count, 1);
$this->assertEqual($users[1]->Phonenumber[0]->count, 3);
$this->assertEqual($users[2]->Phonenumber[0]->count, 1);
$this->assertEqual($users[3]->Phonenumber[0]->count, 1);
$this->assertEqual($users[4]->Phonenumber[0]->count, 3);
$this->assertEqual($users[0]->Phonenumber[0]->max, '123 123');
$this->assertEqual($users[1]->Phonenumber[0]->max, '789 789');
$this->assertEqual($users[2]->Phonenumber[0]->max, '123 123');
$this->assertEqual($users[3]->Phonenumber[0]->max, '111 222 333');
$this->assertEqual($users[4]->Phonenumber[0]->max, '444 555');
}
示例11: testUpdateQuerySupportsIdentifierQuoting
public function testUpdateQuerySupportsIdentifierQuoting()
{
$q = new Doctrine_Query();
$q->parseDqlQuery('UPDATE User u SET u.name = ? WHERE u.id = ?');
$this->assertEqual($q->getSqlQuery(), 'UPDATE "entity" SET "name" = ? WHERE ("id" = ? AND ("type" = 0))');
}
示例12: testAggregateFunctionsInHavingSupportMultipleParameters
public function testAggregateFunctionsInHavingSupportMultipleParameters()
{
$q = new Doctrine_Query();
$q->parseDqlQuery("SELECT CONCAT(u.name, u.loginname) name FROM User u LEFT JOIN u.Phonenumber p HAVING name = 'xx'");
}
示例13: updateRoleData
/**
* Updates the simple role data
* @param NsmRole $role
* @param AgaviRequestDataHolder $rd
* @return boolean
* @author Marius Hein
*/
public function updateRoleData(NsmRole &$role, AgaviRequestDataHolder &$rd)
{
AppKitDoctrineUtil::updateRecordsetFromArray($role, $rd->getParameters(), self::$editableAttributes);
// Checking the principal
if (!$role->NsmPrincipal->principal_id) {
$role->NsmPrincipal->principal_type = NsmPrincipal::TYPE_ROLE;
}
if ($role->role_id === null) {
// insert a new role
$role->save();
} else {
// update role
$parts = array();
$params = array();
foreach ($role as $property => $value) {
if ($property == "role_id" || !in_array($property, self::$editableAttributes)) {
continue;
}
if ($value === null) {
$parts[] = "{$property} = NULL";
} else {
$parts[] = "{$property} = ? ";
$params[] = $value;
}
}
$params[] = $role->role_id;
$dql = "UPDATE NsmRole SET " . implode(",", $parts) . " WHERE role_id = ?";
AppKitLogger::warn("Test: %s - %s", $dql, var_export($params, true));
$query = new Doctrine_Query();
$query->setConnection(AppKitDoctrineUtil::getConnection());
$query->parseDqlQuery($dql);
$query->execute($params);
}
return true;
}