微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP查询可在localhost中运行,但会在实时服务器上中断

如何解决PHP查询可在localhost中运行,但会在实时服务器上中断

正如标题所示,我有一个在localhost上运行良好的查询,但是在我的实时环境中,出现500服务器错误。我的本地PHP版本是7.4,但实时服务器使用7.3。

我得到的错误

PHP Fatal error:  Uncaught PDOException: sqlSTATE[42000]: Syntax error or access violation: 
1064 You have an error in your sql Syntax; check the manual that corresponds to your MysqL 
server version for the right Syntax to use near '(partition by prop_slug order by 
  prop_client) as rn 
  FROM listing_details 
  JOI' at line 4 in /hermes/bosnaweb23a/b60/ipg.site/site/index.PHP:23 
Stack trace: 
#0 /hermes/bosnaweb23a/b60/ipg.site/site/index.PHP(23): PDOStatement->execute() 
#1 {m 

我的查询如下所示,但是正如我所说的,它在本地环境中可以正常工作。

 $get_listings = $db->prepare('SELECT *
 FROM (
 SELECT *,row_number() over(partition by prop_slug order by prop_client) as rn
 FROM listing_details
 JOIN prop_gallery
 ON prop_gallery.prop_gallery_id = listing_details.prop_slug 
 WHERE prop_slug LIKE prop_gallery_id OR prop_gallery_id LIKE prop_slug
 AND listing_details.prop_mandate = 1
 ) x
 where rn = 1');
 $get_listings->execute();
 $listings = $get_listings->fetchAll();

 if (!$listings) { 
  echo 'Error: No Listings.';
 }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。