One SQL statement in PHP is too long, and the SQL statement becomes incomplete when the mode is found

Source: Internet
Author: User
Tags truncated
PHP experts, help me solve a problem:
A SQL is defined in PHP as follows:
$sql = "SELECT * from P_info Pi left JOIN job J on j.id =". $id.
"WHERE Pi.requestid = 0
and ((Ifnull (pi.standard_20_ft_container, 0)-ifnull (J.standard_20_ft_container, 0)) <= 0)
and ((Ifnull (pi.standard_40_ft_container, 0)-ifnull (J.standard_40_ft_container, 0)) <= 0)
and ((Ifnull (pi.high_cube_40_ft_container, 0)-ifnull (J.high_cube_40_ft_container, 0)) <= 0)
and ((Ifnull (pi.capacity_head_of_cattle, 0)-ifnull (j.capacity_head_of_cattle, 0)) <= 0)
and ((Ifnull (pi.capacity_head_of_sheep, 0)-ifnull (j.capacity_head_of_sheep, 0)) <= 0)
and ((Ifnull (pi.capacity_other_livestock, 0)-ifnull (j.capacity_other_livestock, 0)) <= 0)
and ((Ifnull (pi.capacity_number_of_horses, 0)-ifnull (j.capacity_number_of_horses, 0)) <= 0)
and ((Ifnull (pi.grain_feed_kg, 0)-ifnull (j.carrying_capacity_kg, 0)) <= 0)
and ((Ifnull (pi.length_cm, 0)-ifnull (j.tray_length_cm, 0)) <= 0)
and ((Ifnull (pi.width_cm, 0)-ifnull (j.tray_width_cm, 0)) <= 0)
and ((Ifnull (pi.height_cm, 0)-ifnull (j.max_load_height_cm, 0)) <= 0)
and ((Ifnull (pi.weight_kg, 0)-ifnull (j.carrying_capacity_kg, 0)) <= 0)
and To_days (j.home_day1) <= to_days (str_to_date (pi.date1, '%d/%m/%y '))
and To_days (Str_to_date (pi.date2, '%d/%m/%y ')) <= to_days (j.home_day2)
But the queried data is empty, when the mode is found, passed to $query = mysql_query ($sql); here's the SQL statement:
SELECT * from P_info Pi left JOIN job J on j.id = 734WHERE Pi.requestid = 0
and ((Ifnull (pi.standard_20_ft_container, 0)-ifnull (J.standard_20_ft_container, 0)) <= 0)
and ((Ifnull (pi.standard_40_ft_container, 0)-ifnull (J.standard_40_ft_container, 0)) <= 0)
and ((Ifnull (pi.high_cube_40_ft_container, 0)-ifnull (J.high_cube_40_ft_container, 0)) <= 0)
and ((Ifnull (pi.capacity_head_of_cattle, 0)-ifnull (j.capacity_head_of_cattle, 0)) <= 0)
and ((Ifnull (pi.capacity_head_of_sheep, 0)-ifnull (j.capacity_head_of_sheep, 0)) <= 0)
and ((Ifnull (pi.capacity_other_livestock, 0)-ifnull (j.capacity_other_livestock, 0)) <= 0)
and ((Ifnull (pi.capacity_number_of_horses, 0)-ifnull (j.capacity_number_of_horses, 0)) <= 0)
and ((Ifnull (pi.grain_feed_kg, 0)-ifnull (j.carrying_capacity_kg, 0)) <= 0)
and ((Ifnull (pi.length_cm, 0)-ifnull (j.tray_length_cm, 0)) <= 0)
and ((Ifnull (pi.width_cm, 0)-ifnull (j.tray_width_cm, 0)) <= 0)
and ((Ifnull (pi.height_cm, 0)-Ifnull (
Looks like the back of the truncated, the database to run this SQL is no problem. But there is a problem here, how to do? Do you have any questions like this?


Reply to discussion (solution)

The amount ... Haven't seen such a long sql you cow ...

No, 1000, it's not going to be a problem, maybe you're sticking it wrong.

Suggestions:
1. Numeric fields do NOT NULL but NOT NULL
2. Create a view with this query

The amount ... Haven't seen such a long sql you cow ...


This is not long ah, you see is nonsense, because the database is unreasonable, so I have to write AH.

No, 1000, it's not going to be a problem, maybe you're sticking it wrong.

Suggestions:
1. Numeric fields do NOT NULL but NOT NULL
2. Create a view with this query


I found that the string I wore was incomplete when I was debugging. What is the reason for this? is set to NOT NULL, but I fix the bug, can not change the database AH. Let me try the view.

It will not be truncated for no reason, and carefully debugged by yourself.


The amount ... Haven't seen such a long sql you cow ...


This is not long ah, you see is nonsense, because the database is unreasonable, so I have to write AH.


OK, var_dump output character is limited, you are echo out of it, check ha is not the two symbols "' stitching not on


No, 1000, it's not going to be a problem, maybe you're sticking it wrong.

Suggestions:
1. Numeric fields do NOT NULL but NOT NULL
2. Create a view with this query


I found that the string I wore was incomplete when I was debugging. What is the reason for this? is set to NOT NULL, but I fix the bug, can not change the database AH. Let me try the view.



I define a string variable and assign an SQL statement that is longer than 1024. Not full value. Where can improve is this problem, you look at this link, someone with me the same question:
Http://bbs.phpchina.com/thread-163748-1-1.html

It will not be truncated for no reason, and carefully debugged by yourself.


This is the result of debugging. The preceding is the definition of an SQL statement, and the result is passed into query () and is then truncated, with only 1024 characters left.



The amount ... Haven't seen such a long sql you cow ...


This is not long ah, you see is nonsense, because the database is unreasonable, so I have to write AH.


OK, var_dump output character is limited, you are echo out of it, check ha is not the two symbols "' stitching not on


No, no, there is the definition of an SQL statement, and then splicing an ID, followed by debugging found that SQL was intercepted only 1024 left.

Sweep the first eye when unexpectedly did not find the middle inserted a sentence Chinese ...

I have the same problem: http://bbs.phpchina.com/thread-163748-1-1.html

But that person has not already said: has been resolved. The XDEUBG bug. Does not affect the program. it?
Is that what you do?

Sweep the first eye when unexpectedly did not find the middle inserted a sentence Chinese ...


Well, it's my typography that doesn't give you the power to see.

I have the same problem: http://bbs.phpchina.com/thread-163748-1-1.html

But that person has not already said: has been resolved. The XDEUBG bug. Does not affect the program. it?
Is that what you do?


I put the xdebug configuration in the php.ini, after the comment is still not ah.

That means you've still used Xdebug, right?

PHP does not limit the length of the query string from: Inserting an article into a table with an insert directive to map




The amount ... Haven't seen such a long sql you cow ...


This is not long ah, you see is nonsense, because the database is unreasonable, so I have to write AH.


OK, var_dump output character is limited, you are echo out of it, check ha is not the two symbols "' stitching not on


No, no, there is the definition of an SQL statement, and then splicing an ID, followed by debugging found that SQL was intercepted only 1024 left.



Xdubug Var_dump will be automatically truncated, do not know if Echo will, close the Xdebug try

That means you've still used Xdebug, right?

PHP does not limit the length of the query string from: Inserting an article into a table with an insert directive to map


Yes, I used debug debugging, but after commenting on the debug configuration in php.ini, it still doesn't work.

Are you querying for empty or returning SQL statement errors? You said before that is empty, but the truncated SQL should be error, should not be determined first?

LZ is not echo when, the rest of this??

If so, it is recommended that you write this statement into a table.

Are you querying for empty or returning SQL statement errors? You said before that is empty, but the truncated SQL should be error, should not be determined first?


Hi, thank you. Here is found to be empty. But the same query statement is found to have a result set. I also think it should be an error. But I don't know much about PHP. and the previous SQL statements in the program query results. But to navicat below query on the error. All this also makes me very puzzled.

LZ is not echo when, the rest of this??

If so, it is recommended that you write this statement into a table.


What do you mean by that? How do you write it into a table?

I know, here is Xdebug bug, the mode can only display 1024 bytes, but you put that SQL statement output is all.

  • 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.