How to display statements executed by thinkphp

Source: Internet
Author: User
The control area is written like this.
function Checklogin () {$condition [' employeeno '] = $_request[' Employeeno ']; $condition [' password '] = $_request[' Password ']; $model = M ("EmployeeInfo"); $results = $model->where ($condition)->select (); SQL ($model), if ($results) {if (Trim ($results [0][' Password]) = = $condition [' Password ']) {echo ' {success:true,msg: ' OK ' }"; Session::set (' Employeeno ', ' Employeeno '); Session::set (' UserInfo ', $results [0]); return;}} echo "{success:true,msg: ' There is no mutual or password error in login account! '}";


I logged in 38 times, did not succeed (prompt login account does not have mutual or password error), log also did not prompt the error.
To help me check the data, I'm going to put SQL statements, printers out, such as: Select Employeeno,password from
I use VAMP ($model)
Also not show up.


Reply to discussion (solution)

Turn on debug, check SQL statements, copy SQL statements in the database to see if there are any results

$model = M ("EmployeeInfo");
$results = $model->where ($condition)->select ();
echo $results->getlastsql ();

Plus

$condition [' _logic '] = ' and ';
$model = M ("EmployeeInfo");
$results = $model->where ($condition)->select ();
$model->getlastsql ();

Look at that.

Plus

$condition [' _logic '] = ' and ';
$model = M ("EmployeeInfo");
$results = $model->where ($condition)->select ();
$model->getlastsql ();

Look at that.



This brother is the right one!

It would be nice to add a false to your Select method. He will not execute the SQL statement. Instead, print out the SQL statement.
$model = M ("EmployeeInfo")->select (false);

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.