本文整理汇总了PHP中Doctrine_Query类的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query类的具体用法?PHP Doctrine_Query怎么用?PHP Doctrine_Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Doctrine_Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexDirectory
public function indexDirectory($dir)
{
if (!file_exists($dir)) {
throw new Doctrine_Search_Indexer_Exception('Unknown directory ' . $dir);
}
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
$files = array();
foreach ($it as $file) {
$name = $file->getPathName();
if (strpos($name, '.svn') === false) {
$files[] = $name;
}
}
$q = new Doctrine_Query();
$q->delete()->from('Doctrine_File f')->where('f.url LIKE ?', array($dir . '%'))->execute();
// clear the index
$q = new Doctrine_Query();
$q->delete()->from('Doctrine_File_Index i')->where('i.file_id = ?')->execute();
$conn = Doctrine_Manager::connection();
$coll = new Doctrine_Collection('Doctrine_File');
foreach ($files as $file) {
$coll[]->url = $file;
}
$coll->save();
}
示例2: addSymplistIndexColumnQuery
public function addSymplistIndexColumnQuery(Doctrine_Query $query, $field, $value)
{
if ($value) {
$query->andWhere('symplist_index IS NOT NULL');
}
return $query;
}
示例3: saveRelatedAttributeSelections
private function saveRelatedAttributeSelections($embed_token)
{
// Get the relevant form
$forms = $this->embeddedForms;
if (isset($forms[$embed_token])) {
$stock_forms = $forms[$embed_token]->getEmbeddedForms();
// Get the stock values from request
$request_data = $this->getValue($embed_token);
foreach ($request_data as $name => $form) {
// Save form object
if (!isset($stock_forms[$name])) {
continue;
}
$stock_object = $stock_forms[$name]->getObject();
$stock_object->save();
$query = new Doctrine_Query();
// $stock_object->unlink('rtShopVariations', array(), true);
$query->delete('rtShopStockToVariation s2v')->where('s2v.stock_id = ?', $stock_object->getId())->execute();
$values = array();
foreach ($this->getAttributes() as $attribute) {
$tmp_val = $form['rt_shop_variations_list_' . $attribute->getId()];
$values[$tmp_val[0]] = $tmp_val[0];
}
$stock_object->link('rtShopVariations', array_values($values), true);
}
}
}
示例4: testCreateView
public function testCreateView()
{
$query = new Doctrine_Query($this->connection);
$query->from('User');
$view = new Doctrine_View($query, 'MyView');
$this->assertEqual($view->getName(), 'MyView');
$this->assertTrue($view->getQuery() === $query);
$this->assertTrue($view === $query->getView());
$this->assertTrue($view->getConnection() instanceof Doctrine_Connection);
$success = true;
try {
$view->create();
} catch (Exception $e) {
$success = false;
}
$this->assertTrue($success);
$users = $view->execute();
$count = $this->conn->count();
$this->assertTrue($users instanceof Doctrine_Collection);
$this->assertEqual($users->count(), 8);
$this->assertEqual($users[0]->name, 'zYne');
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($count, $this->conn->count());
$success = true;
try {
$view->drop();
} catch (Exception $e) {
$success = false;
}
$this->assertTrue($success);
}
示例5: 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();
}
示例6: buildQuery
function buildQuery(Doctrine_Query $query)
{
if ($this->getValue('name')) {
$query->andWhere('name LIKE ?', '%' . $this->getValue('name') . '%');
}
return $query;
}
示例7: testTicket
public function testTicket()
{
$q = new Doctrine_Query();
// simple query with deep relations
$q->addSelect('Resume.id, Level.id, Level.label')->from('ticket384_Resume Resume')->leftJoin('Resume.KnownLanguages KnownLanguages')->leftJoin('KnownLanguages.Level Level')->leftJoin('KnownLanguages.Language Language');
try {
// get the wrong resultset
$aResult = $q->fetchArray();
$this->fail();
} catch (Doctrine_Query_Exception $e) {
$this->pass();
}
$q->free();
// now correct
// we have to select at least KnownLanguages.id in order to get the Levels,
// which are only reachable through the KnownLanguages, hydrated properly.
$q = new Doctrine_Query();
$q->addSelect('Resume.id, Level.id, Level.label, KnownLanguages.id')->from('ticket384_Resume Resume')->leftJoin('Resume.KnownLanguages KnownLanguages')->leftJoin('KnownLanguages.Level Level')->leftJoin('KnownLanguages.Language Language');
$aResult = $q->fetchArray();
// should be setted
$bSuccess = isset($aResult[0]['KnownLanguages'][0]['Level']);
$this->assertTrue($bSuccess);
if (!$bSuccess) {
$this->fail('fetchArray doesnt hydrate nested child relations, if parent doesnt have a column selected');
}
}
示例8: _setProgramFilterCallback
public function _setProgramFilterCallback(Doctrine_Query $query, $value)
{
if (!empty($value)) {
$query->andWhere('pI.program_id = ?', $value);
}
return $query;
}
示例9: addClassificationColumnQuery
public function addClassificationColumnQuery(Doctrine_Query $query, $field, $values)
{
if ($values != "") {
$query->andWhere(" classification = ? ", $values);
}
return $query;
}
示例10: retrieveFolderList
public function retrieveFolderList(Doctrine_Query $q)
{
$alias = $q->getRootAlias();
$q->leftJoin($alias . '.Assets a');
$q->orderBy($alias . '.lft');
return $q;
}
示例11: listPeriodeFiliereRegion
public function listPeriodeFiliereRegion(Doctrine_Query $q)
{
$rootAlias = $q->getRootAlias();
$q->leftJoin($rootAlias . '.CopisimFiliere c');
$q->leftJoin($rootAlias . '.CopisimRegion d');
return $q;
}
示例12: 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)");
}
示例13: testZeroValuesMaintained3
public function testZeroValuesMaintained3()
{
$q = new Doctrine_Query();
$q->from('ZeroValueTest');
$users = $q->execute();
$this->assertIdentical($users[0]['is_super_admin'], false);
}
示例14: load
public function load($condition)
{
$condition = trim($condition);
$e = Doctrine_Tokenizer::sqlExplode($condition);
if (count($e) > 2) {
$a = explode('.', $e[0]);
$field = array_pop($a);
$reference = implode('.', $a);
$operator = $e[1];
$value = $e[2];
$alias = $this->query->getTableAlias($reference);
$map = $this->query->getAliasDeclaration($reference);
$table = $map['table'];
// check if value is enumerated value
$enumIndex = $table->enumIndex($field, trim($value, "'"));
if (substr($value, 0, 1) == '(') {
// trim brackets
$trimmed = Doctrine_Tokenizer::bracketTrim($value);
if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') {
// subquery found
$q = new Doctrine_Query();
$value = '(' . $q->parseQuery($trimmed)->getQuery() . ')';
} elseif (substr($trimmed, 0, 4) == 'SQL:') {
$value = '(' . substr($trimmed, 4) . ')';
} else {
// simple in expression found
$e = Doctrine_Tokenizer::sqlExplode($trimmed, ',');
$value = array();
foreach ($e as $part) {
$index = $table->enumIndex($field, trim($part, "'"));
if ($index !== false) {
$value[] = $index;
} else {
$value[] = $this->parseLiteralValue($part);
}
}
$value = '(' . implode(', ', $value) . ')';
}
} else {
if ($enumIndex !== false) {
$value = $enumIndex;
} else {
$value = $this->parseLiteralValue($value);
}
}
switch ($operator) {
case '<':
case '>':
case '=':
case '!=':
if ($enumIndex !== false) {
$value = $enumIndex;
}
default:
$condition = $alias . '.' . $field . ' ' . $operator . ' ' . $value;
}
}
return $condition;
}
示例15: testAggregateFunctionsInHavingReturnValidSql
public function testAggregateFunctionsInHavingReturnValidSql()
{
$q = new Doctrine_Query();
$q->parseQuery('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');
}