草庐IT

php - 准备好的语句绑定(bind)参数错误

coder 2023-10-13 原文

在执行以下查询时出现此错误

Fatal error: 
    Uncaught exception 'Zend_Db_Statement_Exception' with message 'Invalid bind-variable position ':individualSexConstantsFirst'' 
    in C:\xampp\htdocs\magento\app\code\core\Zend\Db\Statement.php:258  
Stack trace: 
#0 C:\xampp\htdocs\magento\app\code\local\Customer\Userprofile\Model\Customersettings.php(1201): Zend_Db_Statement->bindParam(':individualSexC...', 36) 
#1 C:\xampp\htdocs\magento\UserProfile\SearchUserFilters.php(33): Customer_Userprofile_Model_Customersettings->getUserFilterData('1992-07-16', '1', '', '', '', '', 'es') 
#2 C:\xampp\htdocs\magento\UserProfile\SearchUserFilters.php(55): SearchFilterData->userFilterData('1992-07-16', '1', '', '', '', '', 'es') 
#3 {main} thrown in C:\xampp\htdocs\magento\app\code\core\Zend\Db\Statement.php on line 258

这里是查询

 $userFilterDataQuery=$magentoDatabaseConnection->prepare("SELECT var.value AS product_name,var.entity_type_id as id
            FROM magento_catalog_product_entity e, magento_eav_attribute eav, magento_catalog_product_entity_varchar var
            WHERE
            e.entity_type_id = eav.entity_type_id
            AND eav.attribute_code = 'name'
            AND eav.attribute_id = var.attribute_id
            AND var.entity_id = e.entity_id AND e.entity_id IN ( SELECT DISTINCT pt.product_id FROM sohyper_product_detailtab_details_int pdti,sohyper_product_detailtab pdt,sohyper_product_tab pt WHERE pdt.details_name = :individualSexConstantsFirst AND pt.tab_id = pdti.tab_id AND pdt.details_id= pdti.details_id AND ( pdti.details_value = :identitySexFirst OR pdti.details_value = :eventTypeConstantsFirst )) AND e.entity_id IN ( SELECT DISTINCT eb.product_id FROM sohyper_product_detailtab_details_dateonly e ,sohyper_product_detailtab ea ,sohyper_product_tab eb, sohyper_product_detailtab_details_dateonly de ,sohyper_product_detailtab dea ,sohyper_product_tab deb WHERE ea.details_name = :individualBornFromConstantsFirst AND eb.tab_id = e.tab_id AND ea.details_id= e.details_id AND e.tab_id  = de.tab_id AND dea.details_name = :individualBornToConstantsFirst AND deb.tab_id = de.tab_id AND dea.details_id= de.details_id AND (:birthFilterFirst BETWEEN e.details_value AND de.details_value) )
            AND var.value LIKE :searchQueryFirst
            UNION ALL
            SELECT value AS product_name, entity_type_id as id
            FROM magento_catalog_category_entity_varchar
            WHERE
            attribute_id = (SELECT ea.attribute_id FROM magento_eav_attribute ea, magento_eav_entity_type et
            WHERE
            et.entity_type_code = 'catalog_category'
            AND ea.attribute_code = 'name'
            AND et.entity_type_id = ea.entity_type_id)
            AND entity_id
            IN (SELECT DISTINCT pdti.details_value
            FROM sohyper_product_tab pt, sohyper_product_detailtab pdt, sohyper_product_detailtab_details_int pdti
            WHERE
            pdti.tab_id=pdt.tab_id AND pdt.tab_id IN ( SELECT DISTINCT pt.tab_id FROM sohyper_product_detailtab_details_int pdti,sohyper_product_detailtab pdt,sohyper_product_tab pt WHERE pdt.details_name = :individualSexConstantsSecond AND pt.tab_id = pdti.tab_id AND pdt.details_id= pdti.details_id AND ( pdti.details_value = :identitySexSecond OR pdti.details_value = :eventTypeConstantsSecond )) AND pdt.tab_id IN ( SELECT DISTINCT e.tab_id FROM sohyper_product_detailtab_details_dateonly e ,sohyper_product_detailtab ea ,sohyper_product_tab eb, sohyper_product_detailtab_details_dateonly de ,sohyper_product_detailtab dea ,sohyper_product_tab deb WHERE ea.details_name = :individualBornFromConstantsSecond AND eb.tab_id = e.tab_id AND ea.details_id= e.details_id AND e.tab_id  = de.tab_id AND dea.details_name = :individualBornToConstantsSecond AND deb.tab_id = de.tab_id AND dea.details_id= de.details_id AND (:birthFilterSecond BETWEEN e.details_value AND de.details_value) )
            AND pdti.details_id=pdt.details_id
            AND pdt.details_name=:distActivityConstants)
            AND value LIKE :searchQuerySecond");
        $userFilterDataQuery->bindParam(':individualSexConstantsFirst', $individualSexConstants);
        $userFilterDataQuery->bindParam(':identitySexFirst', $identitySex);
        $userFilterDataQuery->bindParam(':eventTypeConstantsFirst', $eventTypeConstants);
        $userFilterDataQuery->bindParam(':individualBornFromConstantsFirst', $individualBornFromConstants);
        $userFilterDataQuery->bindParam(':individualBornToConstantsFirst', $individualBornToConstants);
        $userFilterDataQuery->bindParam(':birthFilterFirst', $birthFilter);
        $userFilterDataQuery->bindParam(':searchQueryFirst', $searchQuery);
        $userFilterDataQuery->bindParam(':individualSexConstantsSecond', $individualSexConstants);
        $userFilterDataQuery->bindParam(':identitySexSecond', $identitySex);
        $userFilterDataQuery->bindParam(':eventTypeConstantsSecond', $eventTypeConstants);
        $userFilterDataQuery->bindParam(':individualBornFromConstantsSecond', $individualBornFromConstants);
        $userFilterDataQuery->bindParam(':individualBornToConstantsSecond', $individualBornToConstants);
        $userFilterDataQuery->bindParam(':birthFilterSecond', $birthFilter);
        $userFilterDataQuery->bindParam(':distActivityConstants', $distActivityConstants);
        $userFilterDataQuery->bindParam(':searchQuerySecond', $searchQuery);
        $userFilterDataQuery->execute();
        $userFilterData=$userFilterDataQuery->fetchAll();

最佳答案

尝试使用相同的参数值

 $userFilterDataQuery=$magentoDatabaseConnection->prepare("SELECT var.value AS product_name,var.entity_type_id as id
            FROM magento_catalog_product_entity e, magento_eav_attribute eav, magento_catalog_product_entity_varchar var
            WHERE
            e.entity_type_id = eav.entity_type_id
            AND eav.attribute_code = 'name'
            AND eav.attribute_id = var.attribute_id
            AND var.entity_id = e.entity_id AND e.entity_id IN ( SELECT DISTINCT pt.product_id FROM sohyper_product_detailtab_details_int pdti,sohyper_product_detailtab pdt,sohyper_product_tab pt WHERE pdt.details_name = :individualSexConstants AND pt.tab_id = pdti.tab_id AND pdt.details_id= pdti.details_id AND ( pdti.details_value = :identitySex OR pdti.details_value = :eventTypeConstants )) AND e.entity_id IN ( SELECT DISTINCT eb.product_id FROM sohyper_product_detailtab_details_dateonly e ,sohyper_product_detailtab ea ,sohyper_product_tab eb, sohyper_product_detailtab_details_dateonly de ,sohyper_product_detailtab dea ,sohyper_product_tab deb WHERE ea.details_name = :individualBornFromConstants AND eb.tab_id = e.tab_id AND ea.details_id= e.details_id AND e.tab_id  = de.tab_id AND dea.details_name = :individualBornToConstants AND deb.tab_id = de.tab_id AND dea.details_id= de.details_id AND (:birthFilterSecond BETWEEN e.details_value AND de.details_value) )
            AND var.value LIKE :searchQuery
            UNION ALL
            SELECT value AS product_name, entity_type_id as id
            FROM magento_catalog_category_entity_varchar
            WHERE
            attribute_id = (SELECT ea.attribute_id FROM magento_eav_attribute ea, magento_eav_entity_type et
            WHERE
            et.entity_type_code = 'catalog_category'
            AND ea.attribute_code = 'name'
            AND et.entity_type_id = ea.entity_type_id)
            AND entity_id
            IN (SELECT DISTINCT pdti.details_value
            FROM sohyper_product_tab pt, sohyper_product_detailtab pdt, sohyper_product_detailtab_details_int pdti
            WHERE
            pdti.tab_id=pdt.tab_id AND pdt.tab_id IN ( SELECT DISTINCT pt.tab_id FROM sohyper_product_detailtab_details_int pdti,sohyper_product_detailtab pdt,sohyper_product_tab pt WHERE pdt.details_name = :individualSexConstants AND pt.tab_id = pdti.tab_id AND pdt.details_id= pdti.details_id AND ( pdti.details_value = :identitySex OR pdti.details_value = :eventTypeConstants )) AND pdt.tab_id IN ( SELECT DISTINCT e.tab_id FROM sohyper_product_detailtab_details_dateonly e ,sohyper_product_detailtab ea ,sohyper_product_tab eb, sohyper_product_detailtab_details_dateonly de ,sohyper_product_detailtab dea ,sohyper_product_tab deb WHERE ea.details_name = :individualBornFromConstants AND eb.tab_id = e.tab_id AND ea.details_id= e.details_id AND e.tab_id  = de.tab_id AND dea.details_name = :individualBornToConstants AND deb.tab_id = de.tab_id AND dea.details_id= de.details_id AND (:birthFilterSecond BETWEEN e.details_value AND de.details_value) )
            AND pdti.details_id=pdt.details_id
            AND pdt.details_name=:distActivityConstants)
            AND value LIKE :searchQuery");

        $userFilterDataQuery->bindParam(':individualSexConstants', $individualSexConstants);
        $userFilterDataQuery->bindParam(':eventTypeConstants', $eventTypeConstants);
        $userFilterDataQuery->bindParam(':individualBornFromConstants', $individualBornFromConstants);
        $userFilterDataQuery->bindParam(':individualBornToConstants', $individualBornToConstants);
        $userFilterDataQuery->bindParam(':birthFilterSecond', $birthFilter);
        $userFilterDataQuery->bindParam(':distActivityConstants', $distActivityConstants);
        $userFilterDataQuery->bindParam(':identitySex', $identitySex);
        $userFilterDataQuery->bindParam(':searchQuery', $searchQuery);
        $userFilterDataQuery->execute();
        $userFilterData=$userFilterDataQuery->fetchAll();

关于php - 准备好的语句绑定(bind)参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27655499/

有关php - 准备好的语句绑定(bind)参数错误的更多相关文章

  1. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  2. ruby-on-rails - 如何在 ruby​​ 中使用两个参数异步运行 exe? - 2

    exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby​​中使用两个参数异步运行exe吗?我已经尝试过ruby​​命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何ruby​​gems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除

  3. ruby - RSpec - 使用测试替身作为 block 参数 - 2

    我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere

  4. ruby - ruby 中的 TOPLEVEL_BINDING 是什么? - 2

    它不等于主线程的binding,这个toplevel作用域是什么?此作用域与主线程中的binding有何不同?>ruby-e'putsTOPLEVEL_BINDING===binding'false 最佳答案 事实是,TOPLEVEL_BINDING始终引用Binding的预定义全局实例,而Kernel#binding创建的新实例>Binding每次封装当前执行上下文。在顶层,它们都包含相同的绑定(bind),但它们不是同一个对象,您无法使用==或===测试它们的绑定(bind)相等性。putsTOPLEVEL_BINDINGput

  5. ruby - 如何在 Ruby 中拆分参数字符串 Bash 样式? - 2

    我正在为一个项目制作一个简单的shell,我希望像在Bash中一样解析参数字符串。foobar"helloworld"fooz应该变成:["foo","bar","helloworld","fooz"]等等。到目前为止,我一直在使用CSV::parse_line,将列分隔符设置为""和.compact输出。问题是我现在必须选择是要支持单引号还是双引号。CSV不支持超过一个分隔符。Python有一个名为shlex的模块:>>>shlex.split("Test'helloworld'foo")['Test','helloworld','foo']>>>shlex.split('Test"

  6. ruby - 检查方法参数的类型 - 2

    我不确定传递给方法的对象的类型是否正确。我可能会将一个字符串传递给一个只能处理整数的函数。某种运行时保证怎么样?我看不到比以下更好的选择:defsomeFixNumMangler(input)raise"wrongtype:integerrequired"unlessinput.class==FixNumother_stuffend有更好的选择吗? 最佳答案 使用Kernel#Integer在使用之前转换输入的方法。当无法以任何合理的方式将输入转换为整数时,它将引发ArgumentError。defmy_method(number)

  7. ruby-on-rails - 在默认方法参数中使用 .reverse_merge 或 .merge - 2

    两者都可以defsetup(options={})options.reverse_merge:size=>25,:velocity=>10end和defsetup(options={}){:size=>25,:velocity=>10}.merge(options)end在方法的参数中分配默认值。问题是:哪个更好?您更愿意使用哪一个?在性能、代码可读性或其他方面有什么不同吗?编辑:我无意中添加了bang(!)...并不是要询问nobang方法与bang方法之间的区别 最佳答案 我倾向于使用reverse_merge方法:option

  8. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  9. ruby-on-rails - 如何在 Rails View 上显示错误消息? - 2

    我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c

  10. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

随机推荐