1. thinkPHP中数据库的配置:
conf/config.php 中“DB_PREFIX” 项必须配置
eg: 'DB_TYPE' => 'mysql',
'DB_HOST'=>'localhost',
'DB_NAME'=>'test',
'DB_USER'=>'root',
'DB_PWD' =>'123456',
'DB_PORT'=>'3306',
'DB_PREFIX'=>''
2. 跨模块调用:
eg1: //跨模块调用
$index = A("Index"); //实例化IndexAction的实例对象
$index -> query(); //调用IndexAction的函数
eg2 : import("@.Action.IndexAction");
$index = new IndexAction();
$index -> query(); //调用IndexAction的函数
eg3: R("Index","query"); //parm1 模块名称,param2 函数名称
3. 跨项目调用
eg1: //跨模块调用
$index = A("Index","App2"); //实例化IndexAction的实例对象
$index -> query(); //调用IndexAction的函数
eg2: R("Index","query","App2"); //parm1 模块名称,param2 函数名称,param3 项目名称
4. php 执行doc命令函数:system("doc");
5. 分页查询时保存查询调价:
1》 $smap = "/samp/".urlencode(serialize($map)); //序列化查询条件($map保存查询条件的集合)
2》 设置分页类的参数:
//查询参数保存至url中
if(count($map) > 0){
$Page->parameter = "/smap/".urlencode(serialize($map));
}
6.Model的find方法和select方法的区别
1>find 查询一天数据,返回一个一维数组
2>select 查询多条数据,返回一个二维数组
7.自动完成jquery
<load href="./Public/mediaatcms/css/jquery.autocomplete.css"/>
<load href="./Public/mediaatcms/js/jquery-1.3.2.min.js"/>
<load href="./Public/mediaatcms/js/jquery.autocomplete.min.js"/>
html(js):
$().ready(function() { $("#tex_queKeyWord").autocomplete("__URL__/complete", {
width: 153,
requestType:'post',
postVar: 'keyWord',
matchContains: true,
selectFirst: false });});
php: $keyWord = trim($_GET['q']); //通过“q”获取关键字
$qa = D("Qa");
$keys = $qa ->query("select distinct(question) as s from mad_qa where question like '%$keyWord%' limit 0,8");
foreach($keys as &$key){
echo $key['s']."\n";
}
http://localhost/mediaatCMS/index.php?s=QA/index //前台访问路径
conf/config.php 中“DB_PREFIX” 项必须配置
eg: 'DB_TYPE' => 'mysql',
'DB_HOST'=>'localhost',
'DB_NAME'=>'test',
'DB_USER'=>'root',
'DB_PWD' =>'123456',
'DB_PORT'=>'3306',
'DB_PREFIX'=>''
2. 跨模块调用:
eg1: //跨模块调用
$index = A("Index"); //实例化IndexAction的实例对象
$index -> query(); //调用IndexAction的函数
eg2 : import("@.Action.IndexAction");
$index = new IndexAction();
$index -> query(); //调用IndexAction的函数
eg3: R("Index","query"); //parm1 模块名称,param2 函数名称
3. 跨项目调用
eg1: //跨模块调用
$index = A("Index","App2"); //实例化IndexAction的实例对象
$index -> query(); //调用IndexAction的函数
eg2: R("Index","query","App2"); //parm1 模块名称,param2 函数名称,param3 项目名称
4. php 执行doc命令函数:system("doc");
5. 分页查询时保存查询调价:
1》 $smap = "/samp/".urlencode(serialize($map)); //序列化查询条件($map保存查询条件的集合)
2》 设置分页类的参数:
//查询参数保存至url中
if(count($map) > 0){
$Page->parameter = "/smap/".urlencode(serialize($map));
}
6.Model的find方法和select方法的区别
1>find 查询一天数据,返回一个一维数组
2>select 查询多条数据,返回一个二维数组
7.自动完成jquery
<load href="./Public/mediaatcms/css/jquery.autocomplete.css"/>
<load href="./Public/mediaatcms/js/jquery-1.3.2.min.js"/>
<load href="./Public/mediaatcms/js/jquery.autocomplete.min.js"/>
html(js):
$().ready(function() { $("#tex_queKeyWord").autocomplete("__URL__/complete", {
width: 153,
requestType:'post',
postVar: 'keyWord',
matchContains: true,
selectFirst: false });});
php: $keyWord = trim($_GET['q']); //通过“q”获取关键字
$qa = D("Qa");
$keys = $qa ->query("select distinct(question) as s from mad_qa where question like '%$keyWord%' limit 0,8");
foreach($keys as &$key){
echo $key['s']."\n";
}
http://localhost/mediaatCMS/index.php?s=QA/index //前台访问路径