/** * Gets an issue list based on the given parameters. * * @param array $p_parameters * An array of ComparisonOperation objects * @param string $p_order * An array of columns and directions to order by * @param integer $p_count * The count of answers. * * @return array $issuesList * An array of Issue objects */ public static function GetList(array $p_parameters, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count) { global $g_ado_db; $hasPollNr = false; $hasLanguageId = fase; $selectClauseObj = new SQLSelectClause(); if (!is_array($p_parameters)) { return null; } // adodb::selectLimit() interpretes -1 as unlimited if ($p_limit == 0) { $p_limit = -1; } // sets the where conditions foreach ($p_parameters as $param) { $comparisonOperation = self::ProcessListParameters($param); if (empty($comparisonOperation)) { continue; } if (strpos($comparisonOperation['left'], 'poll_nr') !== false) { $hasPollNr = true; } if (strpos($comparisonOperation['left'], 'language_id') !== false) { $hasLanguageId = true; } $whereCondition = $comparisonOperation['left'] . ' ' . $comparisonOperation['symbol'] . " '" . $g_ado_db->escape($comparisonOperation['right']) . "' "; $selectClauseObj->addWhere($whereCondition); } // validates whether publication identifier was given if ($hasPollNr == false) { CampTemplate::singleton()->trigger_error('missed parameter Poll Number in statement list_pollanswers'); return; } // validates whether language identifier was given if ($hasLanguageId == false) { CampTemplate::singleton()->trigger_error('missed parameter Language Identifier in statement list_pollanswers'); return; } // sets the columns to be fetched $tmpPollAnswer = new PollAnswer(); $columnNames = $tmpPollAnswer->getColumnNames(true); foreach ($columnNames as $columnName) { $selectClauseObj->addColumn($columnName); } // sets the main table for the query $mainTblName = $tmpPollAnswer->getDbTableName(); $selectClauseObj->setTable($mainTblName); unset($tmpPollAnswer); if (!is_array($p_order)) { $p_order = array(); } // sets the ORDER BY condition $p_order = count($p_order) > 0 ? $p_order : PollAnswer::$s_defaultOrder; $order = PollAnswer::ProcessListOrder($p_order); foreach ($order as $orderColumn => $orderDirection) { $selectClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection); } $sqlQuery = $selectClauseObj->buildQuery(); // count all available results $countRes = $g_ado_db->Execute($sqlQuery); $p_count = $countRes->recordCount(); //get the wanted rows $pollAnswerRes = $g_ado_db->Execute($sqlQuery); // builds the array of poll objects $pollAnswersList = array(); while ($pollAnswer = $pollAnswerRes->FetchRow()) { $pollAnswerObj = new PollAnswer($pollAnswer['fk_language_id'], $pollAnswer['fk_poll_nr'], $pollAnswer['nr_answer']); if ($pollAnswerObj->exists()) { $pollAnswersList[] = $pollAnswerObj; } } return $pollAnswersList; } // fn GetList