本文整理汇总了PHP中Doctrine_Query::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::copy方法的具体用法?PHP Doctrine_Query::copy怎么用?PHP Doctrine_Query::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::copy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testQueryCopy
public function testQueryCopy()
{
$q = new Doctrine_Query();
$q->from('User u');
$q2 = $q->copy();
$this->assertEqual($q->getSqlQuery(), $q2->getSqlQuery());
$this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)');
}
示例2: search
/**
* Searchable keyword search
*
* @param string $string Keyword string to search for
* @param Doctrine_Query $query Query object to alter. Adds where condition to limit the results using the search index
* @return mixed The Doctrine_Collection or array of ids and relevancy
*/
public function search($string, $query = null)
{
$q = new Doctrine_Search_Query($this->_table);
if ($query instanceof Doctrine_Query) {
$q->query($string, false);
$newQuery = $query->copy();
$query->getSql();
$newQuery->addWhere($query->getRootAlias() . '.id IN(' . $q->getSql() . ')', $q->getParams());
return $newQuery;
} else {
$q->query($string);
return $this->_options['connection']->fetchAll($q->getSql(), $q->getParams());
}
}
示例3: search
/**
* Searchable keyword search
*
* @param string $string Keyword string to search for
* @param Doctrine_Query $query Query object to alter. Adds where condition to limit the results using the search index
* @return mixed The Doctrine_Collection or array of ids and relevancy
*/
public function search($string, $query = null)
{
$q = new Doctrine_Search_Query($this->_table);
if ($query instanceof Doctrine_Query) {
$q->query($string, false);
$newQuery = $query->copy();
$query->getSql();
$key = (array) $this->getOption('table')->getIdentifier();
$newQuery->addWhere($query->getRootAlias() . '.' . current($key) . ' IN (SQL:' . $q->getSql() . ')', $q->getParams());
return $newQuery;
} else {
$q->query($string);
return $this->_options['connection']->fetchAll($q->getSql(), $q->getParams());
}
}
示例4: format_query_radix
/**
* Format the value returned from rec_query() into an array radix.
*
* @param Doctrine_Query $q
* @return array $radix
*/
protected function format_query_radix(Doctrine_Query $q)
{
$q2 = $q->copy()->select('org_id');
$rs = $q2->fetchArray();
// also select all parent orgs
$ids = array();
foreach ($rs as $org) {
$parent_ids = Organization::get_org_parents($org['org_id']);
$ids = array_merge($ids, $parent_ids);
$ids[] = $org['org_id'];
}
$q->orWhereIn('o.org_id', $ids);
$q->removeDqlQueryPart('limit');
// now get the radix
$this->_fields['org_parent_id'] = 1;
$this->_fields['org_id'] = 1;
$radix = parent::format_query_radix($q);
// display organizations as a tree
return $this->get_tree_data($radix);
}
示例5: testQueryCopyClone
public function testQueryCopyClone()
{
$query = new Doctrine_Query();
$query->select('u.*')->from('User u');
$sql = $query->getSqlQuery();
$data = $query->execute();
$query2 = $query->copy();
$this->assertTrue($sql, $query2->getSqlQuery());
$query2->limit(0);
$query2->offset(0);
$query2->select('COUNT(u.id) as nb');
$this->assertTrue($query2->getSqlQuery(), 'SELECT COUNT(e.id) AS e__0 FROM entity e WHERE (e.type = 0)');
}
示例6: writeCsv
public static function writeCsv($filename, Doctrine_Query $query, $subscribers, $page = 0)
{
$out = fopen($filename, 'a+');
$formfields = array_keys(Petition::$FIELD_SHOW);
// $petition->getFormfields();
$exclude = self::$EXCLUDE[$subscribers];
$used_fields = array('created_at' => 0, 'updated_at' => 1, 'status' => 2);
$blank = array('', '', '');
$widget_id_to_language_id = array();
ini_set('max_execution_time', 600);
set_time_limit(120);
$query_i = $query->copy();
$petition_signings = $query_i->select('ps.*, w.id, w.petition_text_id, pt.id, pt.language_id')->offset(self::PAGE_SIZE * $page)->limit(self::PAGE_SIZE)->execute();
$i = 0;
foreach ($petition_signings as $petition_signing) {
/* @var $petition_signing PetitionSigning */
$widget_id = $petition_signing->getWidgetId();
$cell = $blank;
$cell[0] = $petition_signing->getCreatedAt();
$cell[1] = $petition_signing->getUpdatedAt();
$cell[2] = $petition_signing->getStatusName();
foreach ($formfields as $formfield) {
if (!in_array($formfield, $exclude)) {
$value = $petition_signing->getField($formfield);
if ($value !== null) {
if (!array_key_exists($formfield, $used_fields)) {
$used_fields[$formfield] = count($used_fields);
$blank[] = '';
}
$cell[$used_fields[$formfield]] = $value;
}
}
}
if (!array_key_exists(Petition::FIELD_REF, $used_fields)) {
$used_fields[Petition::FIELD_REF] = count($used_fields);
$blank[] = '';
$used_fields['widget_id'] = count($used_fields);
$blank[] = '';
$used_fields['language_id'] = count($used_fields);
$blank[] = '';
if (!$subscribers) {
$used_fields['hash'] = count($used_fields);
$blank[] = '';
}
}
$cell[$used_fields[Petition::FIELD_REF]] = $petition_signing->getField(Petition::FIELD_REF);
$cell[$used_fields['widget_id']] = $widget_id;
$language_id = '';
if ($widget_id) {
if (!array_key_exists($widget_id, $widget_id_to_language_id)) {
$widget_id_to_language_id[$widget_id] = $petition_signing->getWidget()->getPetitionText()->getLanguageId();
}
$language_id = $widget_id_to_language_id[$petition_signing->getWidgetId()];
}
$cell[$used_fields['language_id']] = $language_id;
if (!$subscribers) {
$cell[$used_fields['hash']] = $petition_signing->getEmailHashAuto();
}
if ($i === 0 && $page === 0) {
fwrite($out, "");
fputcsv($out, array_keys($used_fields), ';');
}
fputcsv($out, $cell, ';');
$i++;
}
$petition_signings->free();
unset($petition_signings);
$query_i->free();
unset($query_i);
fclose($out);
}