从此不求人:自主研发一套PHP前端开发框架(33)之插件化架构实现中

18 篇文章 0 订阅
15 篇文章 0 订阅

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!=''

将只会返回一个空的数组

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值