flagflag  
1: 2021-07-29 (Thu) 13:35:08 iseki source Cur: 2021-07-29 (Thu) 14:37:32 iseki source
Line 1: Line 1:
-*** DataBase [#v4abf387] +** DataBase API [#v4abf387] 
-- lib/dmllib.php+- lib/dml/moodle_database.php 
 +- $strictness: MUST_EXIST, IGNORE_MISSING
#br #br
-**** count_records [#rc2a2d4a+*** API [#g39f06be
- $count = count_records('autoattend_sessions', 'courseid', $course->id, 'sessdate', $sdate, 'starttime', $starttime);+#br
-**** get_record(s) [#z3e3f469+**** $DB->count_records [#rc2a2d4a
-- get_record($table, $field1, $value1, $field2="", $value2="", $field3="", $value3="", $fields='*') + $count = $DB->count_records('autoattend_sessions', array('courseid'=>$course->id, 'sessdate'=>$sdate, 'starttime'=>$starttime));
- if ($user = get_record('user', 'id', $USER->id)) { +
-   $firstname = $user->firstname; +
- } +
-- get_records($table, $field="", $value="", $sort="", $fields='*', $limitfrom="", $limitnum="") +
- if (!$vars = get_records('autoattend_settings', 'courseid', $courseid, 'id')) { +
-    $vars = get_records('autoattend_settings', 'courseid', 0);     // use default +
- }+
-**** get_records_sql [#r096c770] +#br
- $qey = "SELECT * FROM ......."; +
- if ($users = get_records_sql($qry)) { +
-   foreach($users as $key => $user) { +
-       $return['id']      = $user->id; +
-       $return['attsid'] = $user->attsid; +
-       ............................. +
-   } +
- }+
-**** update_record, insert_record [#bfdf5685+**** $DB->insert_record [#ua6949a2
- $update = false; +- record_id insert_record($table, $dataobject, $returnid=true, $bulk=false); 
- if ($rec = get_record('autoattend_settings', 'courseid', $course->id, 'status', $status[$i])) { + $apply_id = $DB->insert_record('apply', $apply);
-   $update = true; +
- } +
- $rec->courseid = $course->id; +
- ............................ +
- if ($update) { +
-     $result = update_record('autoattend_settings', $rec); +
- } +
- else { +
-     $result = insert_record('autoattend_settings', $rec); +
- } +
- unset($rec);+
-**** delete_records [#u570f164+**** $DB->update_record [#h3d4dcda] 
- delete_records('autoattend_settings', 'courseid', $course->id);+- bool update_record($table, $dataobject, $bulk=false); 
 + update_record('apply', $apply);
-**** XMLDB [#yaa09041+**** $DB->delete_records [#kbebef5f
-- http://dev.moodle.org/mod/resource/view.php?id=48 +- bool delete_records($table, array $conditions=null) 
-- block にディレクトリを作成し,その中に dbディレクトリを作る. + $ret = $DB->delete_records('event', array('modulename'=>'apply', 'instance'=>$apply_id)); 
-- 「サイト管理」→「その他」→「XMLDBエディタ」 でデータベース定義用の db/install.xml を作成する.+ 
 +**** $DB->get_record [#ddb2fca9] 
 +- object get_record($table, array $conditions, $fields='*', $strictness=IGNORE_MISSING) 
 + $item = $DB->get_record('apply_item', array('id'=>$apply_id)); 
 + $name = $item->name; 
 + 
 +**** $DB->get_records [#d0deebeb] 
 +- array(object) get_records($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) 
 + $params = array('apply_id'=>$item->apply_id); 
 + $items = $DB->get_records('apply_item', $params, 'position'); 
 + foreach ($items as $item) { 
 +     $name = $item->name; 
 +     ...... 
 + 
 +**** $DB->get_records_select [#w11aa7e9] 
 +- array(object) get_records_select($table, $select, array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) 
 +- $select の ''?'' に 配列 $params の要素が対応(並び順) 
 +- $select 中の '':変数名'' に $params の各要素が対応 
 +- name が結果の配列のキーになる(重複があるとワーニング) 
 + $templates = $DB->get_records_select('apply_template'​, 'course=? OR ispublic=1', array($course->id), 'name'); 
 + 
 +**** $DB->get_records_sql [#kb220662] 
 +- array(object) get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) 
 +- $sql の ''?'' に 配列 $params の要素が対応(並び順) 
 +- $sql 中の '':変数名'' に $params の各要素が対応 
 + $where = 'WHERE as.id=av.submit_id AND av.version=0 AND as.apply_id=:apply_id AND ai.id=av.item_id '; 
 + $sql  = 'SELECT MAX(ai.position) FROM {apply_submit} as, {apply_value} av, {apply_item} ai '.$where; 
 + $params = array(); 
 + $params['apply_id'] = $apply_id; 
 + $lastpos = $DB->get_field_sql($sql, $params); 
 +#br 
 +**** $DB->execute [#lb197e37] 
 +- array(object) execute($sql, array $params=null) 
 +- $sql の ''?'' に 配列 $params の要素が対応(並び順) 
 +- $sql 中の '':変数名'' に $params の各要素が対応
#br #br


Front page   New List of Pages Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)

Site Search

Login

Username:

Password:


Lost Password?
Register now!!

Sub Menu

mini Calendar

Last MonthAug 2025Next Month
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Today

Access Counter

Today : 2507250725072507
Yesterday : 7039703970397039
Total : 2826949728269497282694972826949728269497282694972826949728269497
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com