Heim  >  Artikel  >  Backend-Entwicklung  >  tp框架怎么根据传的参数查询数据?

tp框架怎么根据传的参数查询数据?

WBOY
WBOYOriginal
2016-06-20 12:25:441004Durchsuche

比如一个搜索表单根据用户输入的值搜索name字段下的对应的名字 这个应该怎么查询呢?我只会写这么一点 tp里面传值不知道该怎么弄 怎么传值怎么接收?
比如这里的这个action值应该写什么?  我看手册只有在后台接收数据的  用的是I函数   接收完了怎么使用呢?

<form method="post">    <input type="text" name="name" />    <button type="submit">Submit</button></form>

后台也不会写  只写了一点
class FirstController extends Controller {    public function qq(){    	$qq=new \Model\qqModel();        $qq->field('name');        $info=$qq->select();    	$this->assign('info',$info);        $this->display();    }}


我问了问别人他们说应该这样改
<form action="{:U('Index/qq')}" method="post">   //不懂这里的action后面的意思 我把里面Index/qq换成first/qq试了一下还是报错    <input type="text" name="name" />    <button type="submit">Submit</button></form>

public function search(){    $name=I("post.name");    $info=M("qq")->where('name like %'.$name.'%')->select();    var_dump($info);}

这样试了一下   提示报错了:1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%% )' at line 1 [ SQL语句 ] : SELECT * FROM `qq` WHERE ( name like %% )




回复讨论(解决方案)

fffffffffffffffffffffffffffffffffffffffff

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn