首页 >后端开发 >php教程 >ThinkPHP的数据库访问的简单操作,thinkphp数据库访问_PHP教程

ThinkPHP的数据库访问的简单操作,thinkphp数据库访问_PHP教程

WBOY
WBOY原创
2016-07-13 09:46:56768浏览

ThinkPHP的数据库访问的简单操作,thinkphp数据库访问

              传统的sql与ThinkPHP中的sql相比较   以user表为例

     

<span>$user</span>=M('user'<span>);
</span>1: SELECT * FROM user----------<span>$user</span>-><span>select();
</span>2: SELECT* FORM user WHERE id=2---------<span>$user</span>->find(2<span>);
</span>3: SELECT username FORMuser-----<span>$user</span>->field('username')-><span>select();<br />4: DELETE FORM username WHEREid=2------$user->delete(2);<br />5: UPDATE user SET username='newUsername' WHERE id=2-------$data['username']='newUsername' $user->save($data);<br />6: INSERT INTO user (name,password)VALUES('php','phpPwd')------$data['name']='php' $data['password']='phpPwd'  $user->add($data);                               </span>

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1029945.htmlTechArticleThinkPHP的数据库访问的简单操作,thinkphp数据库访问 传统的sql与ThinkPHP中的sql相比较 以user表为例 $user =M('user' ); 1: SELECT * FROM user---------- $u...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn