微擎开发--基础讲解

应用目录

应用存放在/addons目录下
应用下的模板存放在/template目录下,其中前端存放于/template/mobile目录,后端直接放在/template/ 下;

URL:

前台:http://www.aa.com/app/index.php?i=1&c=entry&eid=2
后台:http://www.aa.com/web/index.php?c=site&a=entry&eid=3&version_id=0

MVC形式的URL:
前台:http://www.aa.com/app/index.php?i=1&c=entry&do=index&m=edu_2018
后台:http://www.aa.com/web/index.php?c=site&a=entry&do=company&m=edu_2018 

/app/:表示为前台页面
/web/:表示为后台页面
i=1:表示平台中公众号位置,第一个公众号
c=entry:前端c表示入口,默认entry
c=site:后端c表示site.php入口文件
a=entry:后端a表示入口,默认entry
eid=2:应用安装到数据库后多个菜单的id标识
do:类方法名称
m:表示应用模块名称

创建URL

$this->createMobileUrl('index');
$this->createWebUrl('company'); 

类:

前端名称必须以doMobile开头:function doMobileIndex() {…}
后端名称必须以doWeb开头:function doWebHt() {…}

全局变量

$_W是系统中最为重要的全局变量
用法: $_W[‘siteroot’]
$_GPC全局请求变量, 获取 $_GET, $_POST, $_COOKIES 中的变量 用法:$_GPC[‘eid’] 

数据库

增加: pdo_insert($tablename, $data = array(), $replace = false);  int | boolean
删除: pdo_delete($tablename, $condition = array(), $glue = 'AND') int | boolean 更新: pdo_update($tablename, $data = array(), $condition, $glue = 'AND') array | boolean 查询: pdo_get($tablename, $condition = array(), $fields = array()); array | boolean 查询所有:pdo_getall($tablename, $condition = array(), $fields = array(), $keyfield = ''); array | boolean 

模板:

类方法中的变量、数组等不需要引入或赋予前端模板,可以直接调用

public function doWebOrder() { global $_GPC,$_W; $name='1-8课'; $array=['哥','姐','弟','妹']; include $this->template('index'); } 输出变量:{$name}<br/> 循环数组: <ul> <!-- 循环数组$index指针不是必须 --> {loop $array $index $item} {php $num=$index+1} <!-- PHP语句 --> <li> {$index}-{$num}- <!-- if else判断 --> {if $item=='哥' || $item=='弟'} {$item}-男 {else} {$item}-女 {/if} </li> {/loop} </ul> 跳转:<a href="{php echo $this->createMobileUrl('index')}">点击</a><br/> 引入模板: {template 'footer'}



转载于:https://www.cnblogs.com/xinhan/p/11205329.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值