本文整理汇总了PHP中grade_object::fetch_all_helper方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_object::fetch_all_helper方法的具体用法?PHP grade_object::fetch_all_helper怎么用?PHP grade_object::fetch_all_helper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_object
的用法示例。
在下文中一共展示了grade_object::fetch_all_helper方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_fetch_all_helper
public function test_fetch_all_helper()
{
// Simple ID lookup.
$params = array('id' => $this->grade_items[0]->id);
$items = grade_object::fetch_all_helper('grade_items', 'grade_item', $params);
$this->assertCount(1, $items);
$item = array_shift($items);
$this->assertInstanceOf('grade_item', $item);
$this->assertEquals($item->id, $this->grade_items[0]->id);
// Various parameters lookup, multiple results.
$params = array('courseid' => $this->course->id, 'categoryid' => $this->grade_categories[1]->id);
$items = grade_object::fetch_all_helper('grade_items', 'grade_item', $params);
$this->assertCount(2, $items);
$expecteditems = array($this->grade_items[0]->id => true, $this->grade_items[1]->id => true);
foreach ($items as $item) {
$this->assertInstanceOf('grade_item', $item);
$this->assertArrayHasKey($item->id, $expecteditems);
unset($expecteditems[$item->id]);
}
// Text column lookup.
$params = array('iteminfo' => $this->grade_items[2]->iteminfo);
$items = grade_object::fetch_all_helper('grade_items', 'grade_item', $params);
$this->assertCount(1, $items);
$item = array_shift($items);
$this->assertInstanceOf('grade_item', $item);
$this->assertEquals($item->id, $this->grade_items[2]->id);
// Lookup using non-existing columns.
$params = array('doesnotexist' => 'ignoreme', 'id' => $this->grade_items[0]->id);
$items = grade_object::fetch_all_helper('grade_items', 'grade_item', $params);
$this->assertCount(1, $items);
$item = array_shift($items);
$this->assertInstanceOf('grade_item', $item);
$this->assertEquals($item->id, $this->grade_items[0]->id);
}
示例2: fetch_helper
/**
* Factory method - uses the parameters to retrieve matching instance from the DB.
* @static final protected
* @return mixed object instance or false if not found
*/
protected static function fetch_helper($table, $classname, $params)
{
if ($instances = grade_object::fetch_all_helper($table, $classname, $params)) {
if (count($instances) > 1) {
// we should not tolerate any errors here - problems might appear later
print_error('morethanonerecordinfetch', 'debug');
}
return reset($instances);
} else {
return false;
}
}
示例3: fetch_all
/**
* Finds and returns all grade_category instances based on params.
*
* @param array $params associative arrays varname=>value
* @return array array of grade_category insatnces or false if none found.
*/
public static function fetch_all($params)
{
return grade_object::fetch_all_helper('grade_categories', 'grade_category', $params);
}
示例4: fetch_all
/**
* Finds and returns all grade_scale instances based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return array array of grade_scale insatnces or false if none found.
*/
function fetch_all($params)
{
return grade_object::fetch_all_helper('scale', 'grade_scale', $params);
}
示例5: fetch_all
/**
* Finds and returns all grade_outcome instances based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return array array of grade_outcome insatnces or false if none found.
*/
function fetch_all($params)
{
return grade_object::fetch_all_helper('grade_outcomes', 'grade_outcome', $params);
}
示例6: fetch_all
/**
* Finds and returns all grade_item instances based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return array array of grade_item insatnces or false if none found.
*/
function fetch_all($params)
{
return grade_object::fetch_all_helper('grade_items', 'grade_item', $params);
}
示例7: fetch_all
/**
* Finds and returns all grade_category instances based on params.
*
* @param array $params associative arrays varname=>value
* @return array array of grade_category insatnces or false if none found.
*/
public static function fetch_all($params)
{
if ($records = self::retrieve_record_set($params)) {
return $records;
}
$records = grade_object::fetch_all_helper('grade_categories', 'grade_category', $params);
self::set_record_set($params, $records);
return $records;
}
示例8: fetch_helper
/**
* Factory method - uses the parameters to retrieve matching instance from the DB.
* @static final protected
* @return mixed object insatnce or false if not found
*/
function fetch_helper($table, $classname, $params)
{
// we have to do use this hack because of the incomplete OOP implementation in PHP4 :-(
// in PHP5 we could do it much better
if ($instances = grade_object::fetch_all_helper($table, $classname, $params)) {
if (count($instances) > 1) {
// we should not tolerate any errors here - problems might appear later
error('Found more than one record in fetch() !');
}
return reset($instances);
} else {
return false;
}
}