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语句输出的话是全部都有的。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software