本文整理汇总了PHP中table_sql::query_db方法的典型用法代码示例。如果您正苦于以下问题:PHP table_sql::query_db方法的具体用法?PHP table_sql::query_db怎么用?PHP table_sql::query_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table_sql
的用法示例。
在下文中一共展示了table_sql::query_db方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query_db
public function query_db($pagesize, $useinitialsbar = true) {
$doneslots = array();
foreach ($this->get_sort_columns() as $column => $notused) {
$slot = $this->is_latest_step_column($column);
if ($slot && !in_array($slot, $doneslots)) {
$this->add_latest_state_join($slot);
$doneslots[] = $slot;
}
}
parent::query_db($pagesize, $useinitialsbar);
if ($this->requires_latest_steps_loaded()) {
$qubaids = $this->get_qubaids_condition();
$this->lateststeps = $this->load_question_latest_steps($qubaids);
}
}
示例2: explode
function query_db($pagesize, $useinitialsbar = true)
{
// Add table joins so we can sort by question answer
// unfortunately can't join all tables necessary to fetch all answers
// to get the state for one question per attempt row we must join two tables
// and there is a limit to how many joins you can have in one query. In MySQL it
// is 61. This means that when having more than 29 questions the query will fail.
// So we join just the tables needed to sort the attempts.
if ($sort = $this->get_sql_sort()) {
$this->sql->from .= ' ';
$sortparts = explode(',', $sort);
$matches = array();
foreach ($sortparts as $sortpart) {
$sortpart = trim($sortpart);
if (preg_match('/^qsanswer([0-9]+)/', $sortpart, $matches)) {
$qid = intval($matches[1]);
$this->sql->fields .= ", qs{$qid}.grade AS qsgrade{$qid}, qs{$qid}.answer AS qsanswer{$qid}, qs{$qid}.event AS qsevent{$qid}, qs{$qid}.id AS qsid{$qid}";
$this->sql->from .= "LEFT JOIN {question_sessions} qns{$qid} ON qns{$qid}.attemptid = qa.uniqueid AND qns{$qid}.questionid = :qid{$qid} ";
$this->sql->from .= "LEFT JOIN {question_states} qs{$qid} ON qs{$qid}.id = qns{$qid}.newgraded ";
$this->sql->params['qid' . $qid] = $qid;
}
}
}
parent::query_db($pagesize, $useinitialsbar);
$qsfields = 'qs.id, qs.grade, qs.event, qs.question, qs.answer, qs.attempt';
if (!$this->is_downloading()) {
$attemptids = array();
foreach ($this->rawdata as $attempt) {
if ($attempt->uniqueid > 0) {
$attemptids[] = $attempt->uniqueid;
}
}
$this->gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, $qsfields);
} else {
$this->gradedstatesbyattempt = quiz_get_newgraded_states($this->sql, true, $qsfields);
}
}
示例3: explode
function query_db($pagesize, $useinitialsbar = true)
{
// Add table joins so we can sort by question grade
// unfortunately can't join all tables necessary to fetch all grades
// to get the state for one question per attempt row we must join two tables
// and there is a limit to how many joins you can have in one query. In MySQL it
// is 61. This means that when having more than 29 questions the query will fail.
// So we join just the tables needed to sort the attempts.
if ($sort = $this->get_sql_sort()) {
if ($this->detailedmarks) {
$this->sql->from .= ' ';
$sortparts = explode(',', $sort);
$matches = array();
foreach ($sortparts as $sortpart) {
$sortpart = trim($sortpart);
if (preg_match('/^qsgrade([0-9]+)/', $sortpart, $matches)) {
$qid = intval($matches[1]);
$this->sql->fields .= ", qs{$qid}.grade AS qsgrade{$qid}, qs{$qid}.event AS qsevent{$qid}, qs{$qid}.id AS qsid{$qid}";
$this->sql->from .= "LEFT JOIN {question_sessions} qns{$qid} ON qns{$qid}.attemptid = qa.uniqueid AND qns{$qid}.questionid = :qid{$qid} ";
$this->sql->from .= "LEFT JOIN {question_states} qs{$qid} ON qs{$qid}.id = qns{$qid}.newgraded ";
$this->sql->params['qid' . $qid] = $qid;
}
}
} else {
//unset any sort columns that sort on question grade as the
//grades are not being fetched as fields
$sess =& $this->sess;
foreach ($sess->sortby as $column => $order) {
if (preg_match('/^qsgrade([0-9]+)/', trim($column))) {
unset($sess->sortby[$column]);
}
}
}
}
parent::query_db($pagesize, $useinitialsbar);
//get all the attempt ids we want to display on this page
//or to export for download.
if (!$this->is_downloading()) {
$attemptids = array();
foreach ($this->rawdata as $attempt) {
if ($attempt->attemptuniqueid > 0) {
$attemptids[] = $attempt->attemptuniqueid;
}
}
$this->gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, 'qs.id, qs.grade, qs.event, qs.question, qs.attempt');
if (has_capability('mod/quiz:regrade', $this->context)) {
$this->regradedqs = quiz_get_regraded_qs($attemptids);
}
} else {
$this->gradedstatesbyattempt = quiz_get_newgraded_states($this->sql, true, 'qs.id, qs.grade, qs.event, qs.question, qs.attempt');
if (has_capability('mod/quiz:regrade', $this->context)) {
$this->regradedqs = quiz_get_regraded_qs($this->sql);
}
}
}