WudimeiPHP框架2016.5版

wudimei_com 2016-06-28 05:00:32
WudimeiPHP框架是一个php7框架。主要目的是模仿laravel,使之轻量级,但又不想照抄,要有自己的风格。
网址:
https://github.com/wudimeicom/WudimeiPHP/tree/master/test
如果想了解更多请查看test里面的示例。

分页:
<?php
require_once __DIR__ .'/../autoload.php';
use Wudimei\DB;
$config = include __DIR__ . "/db_config.php";
DB::addConnection($config);
$select = DB::connection( );
$pg = $select->table("blog")->where('id','>',1)->where('id','<',10)->paginate(2);
echo "<pre>";
print_r( $pg->data );
echo "</pre>";
echo $pg->render("db_paginate.php?page={page}");


更新:

<?php

require_once __DIR__ .'/../autoload.php';
use Wudimei\DB;
$config = include __DIR__ . "/db_config.php";
DB::addConnection($config);
$select = DB::connection( );
$data = array(
'title' => 'ha ha 2',
'content' => 'abc2',
'created_at' => date("Y-m-d H:i:s")
);
$intAffectedRows = $select->table("blog")->where('id',1 )->update( $data );
echo $intAffectedRows;


插入:

<?php

require_once __DIR__ .'/../autoload.php';
use Wudimei\DB;
$config = include __DIR__ . "/db_config.php";
DB::addConnection($config);
$select = DB::connection( );
$data = array(
'title' => 'ha ha ',
'content' => 'abc',
'created_at' => date("Y-m-d H:i:s")
);
$lastInsertId = $select->table("blog")->insert( $data );
echo $lastInsertId;

删除

<?php

require_once __DIR__ .'/../autoload.php';
use Wudimei\DB;
$config = include __DIR__ . "/db_config.php";
DB::addConnection($config);
$select = DB::connection( );

$intAffectedRows = $select->table("blog")->where('id',12)->orWhere('id',11)->orWhere('id',10)->delete( );
echo $intAffectedRows;


视图:

<?php
require_once __DIR__ .'/../autoload.php';
use Wudimei\View;
View::loadConfig( __DIR__ . '/view_config.php' );
$vars = [
'students' => [
['name' => 'jim','age'=>14 ],
['name' => 'lily','age'=>15 ],
['name' => 'lucy','age'=>13 ]
]
];
echo View::make("default.index.foreach",$vars );

模版
<table border="1">
<tr>
<td>name</td>
<td>age</td>
</tr>

@foreach( $students as $stu)
<tr>
<td>{{$stu['name']}}</td>
<td>{{$stu['age']}}</td>
</tr>
@endforeach

</table>

<br /> <br />

@foreach( $students_empty_val as $stu)
{{$stu['name']}} ,
{{$stu['age']}} <br />
@foreachelse
no data
@endforeach
...全文
1529 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudimei_com 2016-08-16
  • 打赏
  • 举报
回复
wudimei php 已经支持 html 注释标记。在编辑器中不会看到乱码了。因为<!-- -->会把代码注释掉,当然,有把"<!--"和"-->"两个标记删除的功能。 https://github.com/wudimeicom/WudimeiPHP/blob/master/test/view_comment_tags.php https://github.com/wudimeicom/WudimeiPHP/blob/master/test/views/default/index/comment_tags.view.phtml
<?php
require_once __DIR__ .'/../autoload.php';
//use Wudimei\View;
use Wudimei\StaticProxies\View;


View::loadConfig( __DIR__ . '/view_config.php' );
View::setForceCompile(true);
View::setSkipCommentTags( true ); // skip <!-- and -->

$vars = [
		'success' => true		,
		'role' => 'admin'	,
		'years' => [2016,2017,2018,2019]
];

echo View::make("default.index.comment_tags",$vars );
comment_tags.view.phtml

<!-- @if( $role == 'admin') -->
hello,{{$role}}
<!-- @else -->
hello,guest
<!-- @endif -->

<!-- @foreach($years as $year) -->
<!-- {{$year}} --><br />
<!-- @foreachelse -->
sorry,years arrary is empty
<!-- @endforeach -->

@if( count( $years) == 4 )
4 years
@else
not 4 years
@endif

<!-- @section('body') -->
this is the body
<!-- @endsection -->
xuzuning 2016-06-29
  • 打赏
  • 举报
回复
并不是说要你提供可视化编程 现在编辑 html 工具很多,你的模板在这些工具里就是乱七八糟的一坨 而手写 html 是比手写 php 更痛苦的事情
wudimei_com 2016-06-29
  • 打赏
  • 举报
回复
可视化编辑,还没有这功能。是我自己写的,以前还写过一个叫rong framework 的框架。
qq_22218553 2016-06-28
  • 打赏
  • 举报
回复
你自己写的吗?
xuzuning 2016-06-28
  • 打赏
  • 举报
回复
你的模版不能可视化编辑

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧