moodle mysql,Moodle: 查询任意数据库

代码:

if (!file_exists('../../config.php')) {

header('Location: ../../install.php');

die;

}

require_once('../../config.php');

require_once("../../mod/feedback/lib.php");

// 课程ID

$course_id = 22; //课程ID

/*

$sql = "select

m.id as m_id,

m.name as m_name,

cm.id as cm_id,

cm.course as cm_course,

cm.module as cm_module,

cm.instance as cm_instance,

cm.instance as cm_instance,

cm.section as cm_section

from {modules} m, {course_modules} cm where cm.module=m.id and cm.course = '$course_id' and cm.id in (SELECT cs.sequence FROM {course_sections} cs where cs.course = '$course_id')";

*/

// 显示所有tables

//$sql = "SHOW TABLES";

// 显示某一表的所有字段

//$sql = "SHOW COLUMNS FROM {quiz_feedback}";

// 自定义查询

$sql = "select * FROM {course_modules} cm where cm.course = '$course_id' and cm.module=7";

//$sql = "select cm.*, m.* from {modules} m, {course_modules} cm where cm.module=m.id and cm.course = '$course_id' and cm.id in (SELECT cs.sequence FROM {course_sections} cs where cs.course = '$course_id')";

$res = $DB->get_records_sql($sql);

echo '

';  echo '$cm===>'; print_r($res);  echo '
'; die;

cbd5a61765aed016a56103b68dcc8d51.gif

相关

Related Posts

MySQL 查询时强制区分大小写

让MySQL搜索区分大小写或排序时分大小写方法如下:   1.在SQL中强制 SELECT `field` FROM `table` WHERE BINARY `colunm` = 'xxxxxx' SELECT `field`…

Magento 数据库配置文件 Magento where is database configuration file?

Find the local.xml in local \magentoappetclocal.xml

  … …

Moodle: 开启错误提示

config.php file: $CFG->debug = 38911; $CFG->debugdisplay = true; For Moodle 2.0 the possible settings…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值