Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试 Moodle 的数据操作 API 的示例查询。到目前为止,我已经尝试了以下查询
<?php require './config.php'; global $DB; $user= $DB->get_record_sql('SELECT * FROM {mdl_user} WHERE id=?', array(1)); echo mysql_num_rows($user); ?>
我收到“从数据库读取错误”。我在本地安装上使用moodle。我在这里做错了什么?
get_records_sql()
在这种情况下,您只得到一个记录,因此它是一个对象。
通过适当的更正,这段代码对我有用:
<?php require './config.php'; global $DB; $user= $DB->get_record_sql('SELECT * FROM {user} WHERE id=?', array(1)); var_dump($user); ?>