本文整理汇总了PHP中Query::select_object方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::select_object方法的具体用法?PHP Query::select_object怎么用?PHP Query::select_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::select_object方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
static function fetch($id)
{
$q = new Query('CourseOffering');
$q->select_object('CourseOffering')->where_eq(CourseOffering::id, $id);
return $q->executeFetchScalar();
}
示例2: Query
$q = new Query('course_offerings');
$q->select_object('CourseOffering');
$q->where("term=? \n\t\t\t\t\t\tAND year=?\n\t\t\t\t\t\tAND course_code = ?\n\t\t\t\t\t\tAND section = ?", [$term, $year, $course_code, $section_id]);
$result = $q->executeFetchAll();
if (count($result) < 1) {
echo '<p style="color:red">Could not find section ' . $sectioncode . '</p>';
continue;
}
if ($result[0][0]->getcapacity() - $result[0][0]->getenrolled() > 0 or $result[0][0]->getcapacity() == 0) {
$sql = "UPDATE course_offerings\n\t\t\t\t\t\tSET enrolled=enrolled+1\n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\tterm=?\n\t\t\t\t\t\tAND year=?\n\t\t\t\t\t\tAND course_code=?\n\t\t\t\t\t\tAND section=?\n\t\t\t\t\t\tAND (enrolled < capacity OR capacity=0)";
$result = db_exec($sql, [$term, $year, $course_code, $section_id]);
if ($result->rowCount() == 0) {
echo '<p style="color:red">Section ' . $sectioncode . ' is now full. Continued registration in remaining courses</p>';
} else {
$q = new Query('course_offerings');
$q->select_object('CourseOffering');
$q->where("term=? \n\t\t\t\t\t\tAND year=?\n\t\t\t\t\t\tAND course_code = ?\n\t\t\t\t\t\tAND section = ?", [$term, $year, $course_code, $section_id]);
$result = $q->executeFetchAll();
if (isset($result[0])) {
if ($result[0][0]->getcapacity() != 0) {
echo '<p>Registered in ' . $sectioncode . ' Seats remaining:' . ($result[0][0]->getcapacity() - $result[0][0]->getenrolled()) . '</p>';
} else {
echo '<p>Registered in ' . $sectioncode . '</p>';
}
}
}
} else {
echo '<p style="color:red">Section ' . $sectioncode . ' is now full. Continued registration in remaining courses</p>';
}
}
echo '<h2>Registration completed</h2>';
示例3: fetch
static function fetch($code)
{
$q = new Query('Course');
$q->select_object('Course')->where_eq(Course::code, $code);
return $q->executeFetchScalar();
}
示例4: getOfferingInfo
function getOfferingInfo($course_code)
{
$offerings = array();
//Get all the lecture sections for a particular course
$q = new Query("course_offerings");
$q->select_object("CourseOffering");
$q->where('course_code=?
AND term=?
AND year=?
AND (capacity - enrolled) > 0
AND type=0', [$course_code, $this->term, $this->year]);
$rows = $q->executeFetchAll();
//For each lecture section get the available lab/tutorial sections
foreach ($rows as $row) {
$sub = new Query("course_offerings");
$sub->select_object('CourseOffering');
$sub->where("course_code=?\n\t\t\t\t\t\t\t\t AND (section LIKE CONCAT(?,'%')\n\t\t\t\t\t\t\t\t OR section LIKE ('L%'))\n\t\t\t\t\t\t\t\t AND (((capacity-enrolled) > 0) OR (capacity=0))\n\t\t\t\t\t\t\t\t AND term=?\n\t\t\t\t\t\t\t\t AND year=?\n\t\t\t\t\t\t\t\t AND type <> 0", [$course_code, $row[0]->getsection(), $term, $year]);
array_push($offerings, ['labs' => $sub->executeFetchAll(), 'lecture' => $row[0]]);
}
return $offerings;
}
示例5: Query
* /api/courses.php?qualified&completed[]=SYSC1005&completed[]=ECOR1010&taking[]=SYSC2006
* - completed: An array of completed courses. Ignored if
* `qualified` not set
* - taking: An array of courses that are being taken in the same
* term. Ignored if `qualified` not set.
*
* Returns:
* <response e="0">
* <courses>
* <!-- One course element per course in the result. -->
* <course>...</course>
* </courses>
* </response>
*/
$q = new Query('Course');
$q->select_object('Course');
// Filter based on course code (or prefix thereof)
if (isset($_GET['code'])) {
$q->where_startswith(Course::code, strtoupper($_GET['code']));
}
// Filter where dependancies are satisfied.
if (isset($_GET['qualified'])) {
$completed = isset($_GET['completed']) ? $_GET['completed'] : [];
$taking = isset($_GET['taking']) ? $_GET['taking'] : [];
foreach ($completed as &$c) {
$c = strtoupper($c);
}
foreach ($taking as &$c) {
$c = strtoupper($c);
}
$preqquery = Course::query_prerequisites(Course::code, $completed, $taking);
示例6: fetch
static function fetch($code)
{
$q = new Query('Program');
$q->select_object('Program')->where_eq(Program::id, $code);
return $q->executeFetchScalar();
}