本文整理汇总了PHP中DataAccessObject::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP DataAccessObject::retrieve方法的具体用法?PHP DataAccessObject::retrieve怎么用?PHP DataAccessObject::retrieve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccessObject
的用法示例。
在下文中一共展示了DataAccessObject::retrieve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDao
function testDao()
{
$da = new MockDataAccess($this);
$dar = new MockDataAccessResult($this);
$da->setReturnReference('query', $dar);
$dao = new DataAccessObject($da);
$result = $dao->retrieve("SELECT *");
$this->assertIsA($result, 'MockDataAccessResult');
}
示例2: getChangesetValues
protected function getChangesetValues($changeset_id)
{
if (!isset($this->artifact_links_by_changeset[$changeset_id])) {
$this->artifact_links_by_changeset[$changeset_id] = array();
$da = CodendiDataAccess::instance();
$field_id = $da->escapeInt($this->id);
$changeset_id = $da->escapeInt($changeset_id);
$sql = "SELECT cv.changeset_id, cv.has_changed, val.*, a.tracker_id, a.last_changeset_id \n FROM tracker_changeset_value_artifactlink AS val\n INNER JOIN tracker_artifact AS a ON(a.id = val.artifact_id)\n INNER JOIN tracker_changeset_value AS cv\n ON ( val.changeset_value_id = cv.id\n AND cv.field_id = {$field_id}\n AND cv.changeset_id = {$changeset_id}\n )\n ORDER BY val.artifact_id";
$dao = new DataAccessObject();
foreach ($dao->retrieve($sql) as $row) {
$this->artifact_links_by_changeset[$row['changeset_id']][] = new Tracker_ArtifactLinkInfo($row['artifact_id'], $row['keyword'], $row['group_id'], $row['tracker_id'], $row['last_changeset_id']);
}
}
return $this->artifact_links_by_changeset[$changeset_id];
}
示例3: exportToCSV
/**
* Export results to csv
*
* @param bool $only_columns True if we need to export only the displayed columns. False for all the fields.
*
* @return void
*/
protected function exportToCSV($only_columns)
{
$matching_ids = $this->report->getMatchingIds();
$total_rows = $matching_ids['id'] ? substr_count($matching_ids['id'], ',') + 1 : 0;
if ($only_columns) {
$fields = $this->extractFieldsFromColumns($this->reorderColumnsByRank($this->getColumns()));
} else {
$fields = Tracker_FormElementFactory::instance()->getUsedFields($this->report->getTracker());
}
$lines = array();
$head = array('aid');
foreach ($fields as $field) {
if ($this->canFieldBeExportedToCSV($field)) {
$head[] = $field->getName();
}
}
$lines[] = $head;
$queries = $this->buildOrderedQuery($matching_ids, $fields);
$dao = new DataAccessObject();
$results = array();
foreach ($queries as $sql) {
$results[] = $dao->retrieve($sql);
}
if (!empty($results[0])) {
$i = 0;
//extract the first results
$first_result = array_shift($results);
//loop through it
foreach ($first_result as $row) {
//id, f1, f2
//merge the row with the other results
foreach ($results as $result) {
//[id, f1, f2] + [id, f3, f4]
$row = array_merge($row, $result->getRow());
//row == id, f1, f2, f3, f4...
}
//build the csv line
$line = array();
$line[] = $row['id'];
foreach ($fields as $field) {
if ($this->canFieldBeExportedToCSV($field)) {
$value = isset($row[$field->getName()]) ? $row[$field->getName()] : null;
$line[] = $field->fetchCSVChangesetValue($row['id'], $row['changeset_id'], $value, $this->report);
}
}
$lines[] = $line;
}
$separator = ",";
// by default, comma.
$user = UserManager::instance()->getCurrentUser();
$separator_csv_export_pref = $user->getPreference('user_csv_separator');
switch ($separator_csv_export_pref) {
case "comma":
$separator = ',';
break;
case "semicolon":
$separator = ';';
break;
case "tab":
$separator = chr(9);
break;
}
$http = Codendi_HTTPPurifier::instance();
$file_name = str_replace(' ', '_', 'artifact_' . $this->report->getTracker()->getItemName());
header('Content-Disposition: filename=' . $http->purify($file_name) . '_' . $this->report->getTracker()->getProject()->getUnixName() . '.csv');
header('Content-type: text/csv');
foreach ($lines as $line) {
fputcsv(fopen("php://output", "a"), $line, $separator, '"');
}
die;
} else {
$GLOBALS['Response']->addFeedback('error', 'Unable to export (too many fields?)');
}
}
示例4: getChangesetValues
/**
* @return array
*/
protected function getChangesetValues($changeset_id)
{
$da = CodendiDataAccess::instance();
if (!$this->file_values_by_changeset) {
$this->file_values_by_changeset = array();
$field_id = $da->escapeInt($this->id);
$sql = "SELECT c.changeset_id, c.has_changed, f.*\n FROM tracker_fileinfo as f\n INNER JOIN tracker_changeset_value_file AS vf on (f.id = vf.fileinfo_id)\n INNER JOIN tracker_changeset_value AS c\n ON ( vf.changeset_value_id = c.id\n AND c.field_id = {$field_id}\n )\n ORDER BY f.id";
$dao = new DataAccessObject();
$values = array();
foreach ($dao->retrieve($sql) as $row) {
$this->file_values_by_changeset[$row['changeset_id']][] = $this->getFileInfo($row['id'], $row);
}
}
return isset($this->file_values_by_changeset[$changeset_id]) ? $this->file_values_by_changeset[$changeset_id] : array();
}
示例5: getAllValues
/**
* @param string $keyword
*
* @return array
*/
public function getAllValues($keyword = null)
{
$sql = array();
$da = CodendiDataAccess::instance();
if (!$this->values) {
$this->values = array();
if (count($this->value_function) > 0) {
$sql = array();
$uh = UserHelper::instance();
$tracker = $this->field->getTracker();
foreach ($this->value_function as $function) {
if ($function) {
switch ($function) {
case 'group_members':
$sql[] = ugroup_db_get_dynamic_members($GLOBALS['UGROUP_PROJECT_MEMBERS'], $tracker->id, $tracker->group_id, true, $keyword);
break;
case 'group_admins':
$sql[] = ugroup_db_get_dynamic_members($GLOBALS['UGROUP_PROJECT_ADMIN'], $tracker->id, $tracker->group_id, true, $keyword);
break;
case 'artifact_submitters':
$da = CodendiDataAccess::instance();
$field_id = $da->escapeInt($this->field->id);
$tracker_id = $da->escapeInt($tracker->id);
if ($keyword) {
$keyword = $da->quoteSmart('%' . $keyword . '%');
}
$sql[] = "(SELECT DISTINCT user.user_id, user.user_name, " . $uh->getDisplayNameSQLQuery() . "\n FROM tracker_artifact AS a\n INNER JOIN user\n ON ( user.user_id = a.submitted_by AND a.tracker_id = {$tracker->id} )\n " . ($keyword ? "HAVING full_name LIKE {$keyword}" : "") . "\n ORDER BY " . $uh->getDisplayNameSQLOrder() . "\n )";
break;
default:
if (preg_match('/ugroup_([0-9]+)/', $function, $matches)) {
if (strlen($matches[1]) > 2) {
$sql[] = ugroup_db_get_members($matches[1], true, $keyword);
} else {
$sql[] = ugroup_db_get_dynamic_members($matches[1], $tracker->id, $tracker->group_id, true, $keyword);
}
}
break;
}
}
}
if ($sql) {
$dao = new DataAccessObject();
$this->values = array();
foreach ($dao->retrieve(implode(' UNION ', $sql)) as $row) {
$this->values[$row['user_id']] = new Tracker_FormElement_Field_List_Bind_UsersValue($row['user_id'], $row['user_name'], $row['full_name']);
}
}
}
}
return $this->values;
}