网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站设计 > PHP
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 153.99.77.173
Old 2016-05-12, 10:26 PM
Wabasha Wabasha is offline
初级会员
 
Join Date: 2005-04-03
Posts: 1
Wabasha 现在声名狼藉
Default 浅析ThinkPHP中execute和query方法的区别

初学ThinkPHP的时候,很多人都对execute()和query()方法的区别搞不懂,本文就此浅析二者的区别。
大家都知道,ThinkPHP中execute()和query()方法都可以在参数里直接输入SQL语句。但是不同的是execute()通常用来执行insert或update等SQL语句,而query常用来执行select等语句。
execute()方法将返回影响的记录数,如果执行SQL的select语句的话,返回的结果将是表的总记录数:
Code:
$model = M( "MyTable" );
$result = $model ->execute( 'update MyTable set name=aaa where id=11'); //将返回总行数
query()方法将返回数据集:
Code:
$model = M( "MyTable" );
$result = $model ->query( 'select * from  MyTable' ); //将返回array()
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 12:23 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.