news.xml
<?xml version="1.0" encoding="utf-8"?>
<class>
<func>
<name>getLogList</name>
<sql><![CDATA[
select * from onethink_action
]]>
</sql>
<description>获取全部的操作日志</description>
<resultType>array</resultType>
</func>
<func>
<name>getNewsDetail</name>
<sql><![CDATA[
select * from onethink_addons
]]>
</sql>
<description>获取某条新闻的详细内容</description>
<resultType>array</resultType>
</func>
<func>
<name>getNewsSchema</name>
<sql><![CDATA[
select * from information_schema.`COLUMNS` WHERE TABLE_SCHEMA='onethink' and TABLE_NAME='onethink_member' and EXTRA!='auto_increment' and COLUMN_COMMENT!=''
]]>
</sql>
<description>获取新闻表的架构信息,需要相应的账号权限</description>
<resultType>int</resultType>
</func>
</class>
Controller/index.inc
<?php
class index extends _Master{
function addnews()
{
$this->_isadmin=true;
$news_schema=$this->news->getNewsSchema();
//特别注意这里我们无法获取到数据是因为没有权限
$this->setVar("tbSet", $news_schema);
$this->setView("addnews");
}
function admintree()
{
$tree=array();
$prod_add=array("id"=>2,"text"=>"添加新闻","state"=>"open","attributes"=>array('url'=>"/lkphp/index/addnews/"));//添加新闻
$prod_list=array("id"=>3,"text"=>"新闻列表","state"=>"open");
$prod=array("id"=>1,"text"=>"商品管理","state"=>"open","children"=>array($prod_add,$prod_list));
$tree[]=$prod;//array_push($var)
exit(json_encode($tree));
}
/**
*permission{"role":"admin"}
*/
function adminindex(){
$this->_isadmin = true;
$this->setView('index');
}
function showindex(){
$this->setVar('title','测试一下大家的灵活性!');
$this->setView('index');
if(is_login()){
$this->setVar('username',the_user()->user_name);
}
}
}
?>
特别注意如果mysql数据库用户权限不够的话那么下面这句sql无法执行
select * from information_schema.`COLUMNS` WHERE TABLE_SCHEMA='onethink' and TABLE_NAME='onethink_member' and EXTRA!='auto_increment' and COLUMN_COMMENT!=''
将只会返回一个空的数组