php 里一个sql语句太长,调式时发现sql语句变得不完整了
PHP高手们,帮我解决一个问题吧:
在php里定义了一条sql如下:
$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)) AND ((ifnull(pi.standard_40_ft_container, 0) - ifnull(j.standard_40_ft_container, 0)) AND ((ifnull(pi.high_cube_40_ft_container, 0) - ifnull(j.high_cube_40_ft_container, 0)) AND ((ifnull(pi.capacity_head_of_cattle, 0) - ifnull(j.capacity_head_of_cattle, 0)) AND ((ifnull(pi.capacity_head_of_sheep, 0) - ifnull(j.capacity_head_of_sheep, 0)) AND ((ifnull(pi.capacity_other_livestock, 0) - ifnull(j.capacity_other_livestock, 0)) AND ((ifnull(pi.capacity_number_of_horses, 0) - ifnull(j.capacity_number_of_horses, 0)) AND ((ifnull(pi.grain_feed_kg, 0) - ifnull(j.carrying_capacity_kg, 0)) AND ((ifnull(pi.length_cm, 0) - ifnull(j.tray_length_cm, 0)) AND ((ifnull(pi.width_cm, 0) - ifnull(j.tray_width_cm, 0)) AND ((ifnull(pi.height_cm, 0) - ifnull(j.max_load_height_cm, 0)) AND ((ifnull(pi.weight_kg, 0) - ifnull(j.carrying_capacity_kg, 0)) AND to_days(j.home_day1) AND to_days(str_to_date(pi.date2, '%d/%m/%Y')) 但是查询出的数据为空,调式时发现,传到$query = mysql_query ( $sql );这里的sql语句变成这样了:
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)) AND ((ifnull(pi.standard_40_ft_container, 0) - ifnull(j.standard_40_ft_container, 0)) AND ((ifnull(pi.high_cube_40_ft_container, 0) - ifnull(j.high_cube_40_ft_container, 0)) AND ((ifnull(pi.capacity_head_of_cattle, 0) - ifnull(j.capacity_head_of_cattle, 0)) AND ((ifnull(pi.capacity_head_of_sheep, 0) - ifnull(j.capacity_head_of_sheep, 0)) AND ((ifnull(pi.capacity_other_livestock, 0) - ifnull(j.capacity_other_livestock, 0)) AND ((ifnull(pi.capacity_number_of_horses, 0) - ifnull(j.capacity_number_of_horses, 0)) AND ((ifnull(pi.grain_feed_kg, 0) - ifnull(j.carrying_capacity_kg, 0)) AND ((ifnull(pi.length_cm, 0) - ifnull(j.tray_length_cm, 0)) AND ((ifnull(pi.width_cm, 0) - ifnull(j.tray_width_cm, 0)) AND ((ifnull(pi.height_cm, 0) - ifnull(
貌似后面的就被截断了,数据库里运行这个sql是没问题的。但是在这里就有问题,怎么办呢?大家有遇到这样问题吗?
回复讨论(解决方案)
额。。。没见这么长的 sql 你牛 。。。
不就一千多点,应该不会有问题的,可能是你粘错了
建议:
1、数值字段不要 NULL 而是 NOT NULL
2、用这个查询创建一个视图
额。。。没见这么长的 sql 你牛 。。。
这个不是长啊,你看都是废话,因为数据库不合理,所以我得这么写啊。
不就一千多点,应该不会有问题的,可能是你粘错了
建议:
1、数值字段不要 NULL 而是 NOT NULL
2、用这个查询创建一个视图
我可是在调试时发现穿进去的字符串不完整啊。这是什么原因呢。是该设置成not null, 但是我是修bug,不能改数据库啊。等我试试视图吧。
不会无缘无故的被截断的,自己仔细调试一下。
额。。。没见这么长的 sql 你牛 。。。
这个不是长啊,你看都是废话,因为数据库不合理,所以我得这么写啊。
好吧,var_dump输出的字符是有限的,你是echo出来的吧,检查哈是不是这两个符号 " ‘ 拼接没对
不就一千多点,应该不会有问题的,可能是你粘错了
建议:
1、数值字段不要 NULL 而是 NOT NULL
2、用这个查询创建一个视图
我可是在调试时发现穿进去的字符串不完整啊。这是什么原因呢。是该设置成not null, 但是我是修bug,不能改数据库啊。等我试试视图吧。
我定义个一字符串变量,赋了一个 sql语句,长度超过1024了。取不全值。哪里可以改进是这个问题,你看看这个链接,有人跟我同样的问题:
http://bbs.phpchina.com/thread-163748-1-1.html
不会无缘无故的被截断的,自己仔细调试一下。
这个就是调试的结果啊。前面是定义一个sql语句,结果传到query()里面就变成后面这样,被截取了,只剩1024个字符。
额。。。没见这么长的 sql 你牛 。。。
这个不是长啊,你看都是废话,因为数据库不合理,所以我得这么写啊。
好吧,var_dump输出的字符是有限的,你是echo出来的吧,检查哈是不是这两个符号 " ‘ 拼接没对
不是,不是,那里就是定义了一个sql语句,然后拼接了一个ID,后面是调试时发现那个sql被截取了只剩1024了。
扫第一眼的时候居然没发现中间插了一句中文...
有人跟我同样的问题:http://bbs.phpchina.com/thread-163748-1-1.html
但那个人不是已经说了: 已解决。xdeubg的bug。不影响程序。吗?
你是否也是这样呢?
扫第一眼的时候居然没发现中间插了一句中文...
好吧,是我排版不给力,导致你没看到。
有人跟我同样的问题:http://bbs.phpchina.com/thread-163748-1-1.html
但那个人不是已经说了: 已解决。xdeubg的bug。不影响程序。吗?
你是否也是这样呢?
我把xdebug的配置在php.ini里注释了之后还是不行哎。
就是说,你还是曾使用了 xdebug 的对吧?
php 并不会限制查询串的长度,这一点可从:将一篇文章通过 insert 指令插入到表中,来映证
额。。。没见这么长的 sql 你牛 。。。
这个不是长啊,你看都是废话,因为数据库不合理,所以我得这么写啊。
好吧,var_dump输出的字符是有限的,你是echo出来的吧,检查哈是不是这两个符号 " ‘ 拼接没对
不是,不是,那里就是定义了一个sql语句,然后拼接了一个ID,后面是调试时发现那个sql被截取了只剩1024了。
xdubug var_dump 会自动截断 ,不知道echo会不会 ,关了xdebug试试
就是说,你还是曾使用了 xdebug 的对吧?
php 并不会限制查询串的长度,这一点可从:将一篇文章通过 insert 指令插入到表中,来映证
是的哎,曾使用debug调试,但是在php.ini里把调试的配置注释了之后还是不行。
你是查询出来为空还是返回SQL语句错误?你前面说是查出来为空,但截断的SQL应该会报错的,不是应该先确定这一点吗?
LZ是不是 echo 的时候,就剩下这点了??
如果是的话,建议你把这条语句,写到一个表里面。
你是查询出来为空还是返回SQL语句错误?你前面说是查出来为空,但截断的SQL应该会报错的,不是应该先确定这一点吗?
嗨,谢谢啊。这里是查出来为空。但是同样的查询语句查出来是有结果集的。我也觉得它应该会报错。但是我对php不太了解。而且先前的SQL语句在程序里查询是有结果的。可是到navicat下面查询就报错了。所有这也让我很疑惑。
LZ是不是 echo 的时候,就剩下这点了??
如果是的话,建议你把这条语句,写到一个表里面。
你的意思是什么呢?怎么写到一个表里呢?
我知道了,这里是xdebug的bug,调式时只能显示1024字节,但是你把那个sql语句输出的话是全部都有的。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Interpretation of MyBatis dynamic SQL tags: Detailed explanation of Set tag usage MyBatis is an excellent persistence layer framework. It provides a wealth of dynamic SQL tags and can flexibly construct database operation statements. Among them, the Set tag is used to generate the SET clause in the UPDATE statement, which is very commonly used in update operations. This article will explain in detail the usage of the Set tag in MyBatis and demonstrate its functionality through specific code examples. What is Set tag Set tag is used in MyBati

What is Identity in SQL? Specific code examples are needed. In SQL, Identity is a special data type used to generate auto-incrementing numbers. It is often used to uniquely identify each row of data in a table. The Identity column is often used in conjunction with the primary key column to ensure that each record has a unique identifier. This article will detail how to use Identity and some practical code examples. The basic way to use Identity is to use Identit when creating a table.

Solution: 1. Check whether the logged-in user has sufficient permissions to access or operate the database, and ensure that the user has the correct permissions; 2. Check whether the account of the SQL Server service has permission to access the specified file or folder, and ensure that the account Have sufficient permissions to read and write the file or folder; 3. Check whether the specified database file has been opened or locked by other processes, try to close or release the file, and rerun the query; 4. Try as administrator Run Management Studio as etc.

Database technology competition: What are the differences between Oracle and SQL? In the database field, Oracle and SQL Server are two highly respected relational database management systems. Although they both belong to the category of relational databases, there are many differences between them. In this article, we will delve into the differences between Oracle and SQL Server, as well as their features and advantages in practical applications. First of all, there are differences in syntax between Oracle and SQL Server.

How to use SQL statements for data aggregation and statistics in MySQL? Data aggregation and statistics are very important steps when performing data analysis and statistics. As a powerful relational database management system, MySQL provides a wealth of aggregation and statistical functions, which can easily perform data aggregation and statistical operations. This article will introduce the method of using SQL statements to perform data aggregation and statistics in MySQL, and provide specific code examples. 1. Use the COUNT function for counting. The COUNT function is the most commonly used
