?php
namespace 目錄\Controller;
class TypeController extends Controller
{
public function add()
{
if(IS_POST)
{
$model = D('Type');
if($model->create())
{
if($model->add())
{
$this->success('添加成功!', U('lst'));
exit;
}
else
{
$sql = $model->getLastSql();
$this->error('插入數(shù)據(jù)庫失??!.hr />SQL:'.$sql);
}
}
else
{
$error = $model->getError();
$this->error($error);
}
}
$this->display();
}
public function lst()
{
$model = D('Type');
$data = $model->search();
$this->assign($data);
$this->display();
}
public function save($id)
{
$model = D('Type');
if(IS_POST)
{
if($model->create())
{
if($model->save() !== FALSE)
{
$this->success('修改成功!', U('lst'));
exit;
}
else
{
$sql = $model->getLastSql();
$this->error('修改數(shù)據(jù)庫失??!.hr />SQL:'.$sql);
}
}
else
{
$error = $model->getError();
$this->error($error);
}
}
$data = $model->find($id);
$this->assign('data', $data);
$this->display();
}
public function del($id)
{
$model = D('Type');
$model->delete($id);
$this->success('操作成功!', U('lst'));
}
public function bdel()
{
$delid = I('post.delid');
if($delid)
{
$delid = implode(',', $delid);
$model = D('Type');
$model->delete($delid);
}
else
$this->error('請選擇要刪除的記錄!');
$this->success('操作成功!', U('lst'));
}
}
更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend FrameWork框架入門教程》及《PHP模板技術(shù)總結(jié)》。