- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的一个用户从我们自己的 magento 网站向我发送了这个链接。我们有这个异常(exception),知道我该如何解决这个问题吗?
http://www.theprinterdepox.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0
There has been an error processing your request
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous
Trace:
#0 /home/theprint/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/theprint/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/theprint/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/theprint/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT DISTINCT...', Array)
#4 /home/theprint/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('SELECT DISTINCT...', Array)
#5 /home/theprint/public_html/lib/Zend/Db/Adapter/Abstract.php(791): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /home/theprint/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php(878): Zend_Db_Adapter_Abstract->fetchCol(Object(Varien_Db_Select))
#7 /home/theprint/public_html/app/code/core/Mage/Catalog/Model/Layer.php(291): Mage_Catalog_Model_Resource_Product_Collection->getSetIds()
#8 /home/theprint/public_html/app/code/core/Mage/Catalog/Model/Layer.php(221): Mage_Catalog_Model_Layer->_getSetIds()
#9 /home/theprint/public_html/app/code/core/Mage/Catalog/Block/Layer/View.php(163): Mage_Catalog_Model_Layer->getFilterableAttributes()
#10 /home/theprint/public_html/app/code/core/Mage/Catalog/Block/Layer/View.php(122): Mage_Catalog_Block_Layer_View->_getFilterableAttributes()
#11 /home/theprint/public_html/app/code/core/Mage/Core/Block/Abstract.php(238): Mage_Catalog_Block_Layer_View->_prepareLayout()
#12 /home/theprint/public_html/app/code/core/Mage/Core/Model/Layout.php(430): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#13 /home/theprint/public_html/app/code/core/Mage/Core/Model/Layout.php(446): Mage_Core_Model_Layout->createBlock('catalogsearch/l...', 'catalogsearch.l...')
#14 /home/theprint/public_html/app/code/core/Mage/Core/Model/Layout.php(238): Mage_Core_Model_Layout->addBlock('catalogsearch/l...', 'catalogsearch.l...')
#15 /home/theprint/public_html/app/code/core/Mage/Core/Model/Layout.php(204): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#16 /home/theprint/public_html/app/code/core/Mage/Core/Model/Layout.php(209): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#17 /home/theprint/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(345): Mage_Core_Model_Layout->generateBlocks()
#18 /home/theprint/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(270): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#19 /home/theprint/public_html/app/code/core/Mage/CatalogSearch/controllers/ResultController.php(77): Mage_Core_Controller_Varien_Action->loadLayout()
#20 /home/theprint/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_CatalogSearch_ResultController->indexAction()
#21 /home/theprint/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#22 /home/theprint/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#23 /home/theprint/public_html/app/code/core/Mage/Core/Model/App.php(347): Mage_Core_Controller_Varien_Front->dispatch()
#24 /home/theprint/public_html/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#25 /home/theprint/public_html/www.theprinterdepo.com/index.php(55): Mage::run('printerdepo', 'website')
#26 {main}
Data.php
<?php
class Mage_CatalogSearch_Helper_Data extends Mage_Core_Helper_Abstract
{
const QUERY_VAR_NAME = 'q';
const MAX_QUERY_LEN = 200;
/**
* Query object
*
* @var Mage_CatalogSearch_Model_Query
*/
protected $_query;
/**
* Query string
*
* @var string
*/
protected $_queryText;
/**
* Note messages
*
* @var array
*/
protected $_messages = array();
/**
* Is a maximum length cut
*
* @var bool
*/
protected $_isMaxLength = false;
/**
* Search engine model
*
* @var Mage_CatalogSearch_Model_Resource_Fulltext_Engine
*/
protected $_engine;
/**
* Retrieve search query parameter name
*
* @return string
*/
public function getQueryParamName()
{
return self::QUERY_VAR_NAME;
}
/**
* Retrieve query model object
*
* @return Mage_CatalogSearch_Model_Query
*/
public function getQuery()
{
if (!$this->_query) {
$this->_query = Mage::getModel('catalogsearch/query')
->loadByQuery($this->getQueryText());
if (!$this->_query->getId()) {
$this->_query->setQueryText($this->getQueryText());
}
}
return $this->_query;
}
/**
* Is a minimum query length
*
* @return bool
*/
public function isMinQueryLength()
{
if (Mage::helper('core/string')->strlen($this->getQueryText()) < $this->getMinQueryLength()) {
return true;
}
return false;
}
/**
* Retrieve search query text
*
* @return string
*/
public function getQueryText()
{
if (is_null($this->_queryText)) {
$this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName());
if ($this->_queryText === null) {
$this->_queryText = '';
} else {
if (is_array($this->_queryText)) {
$this->_queryText = null;
}
$this->_queryText = trim($this->_queryText);
$this->_queryText = Mage::helper('core/string')->cleanString($this->_queryText);
if (Mage::helper('core/string')->strlen($this->_queryText) > $this->getMaxQueryLength()) {
$this->_queryText = Mage::helper('core/string')->substr(
$this->_queryText,
0,
$this->getMaxQueryLength()
);
$this->_isMaxLength = true;
}
}
}
return $this->_queryText;
}
/**
* Retrieve HTML escaped search query
*
* @return string
*/
public function getEscapedQueryText()
{
return $this->htmlEscape($this->getQueryText());
}
/**
* Retrieve suggest collection for query
*
* @return Mage_CatalogSearch_Model_Resource_Query_Collection
*/
public function getSuggestCollection()
{
return $this->getQuery()->getSuggestCollection();
}
/**
* Retrieve result page url and set "secure" param to avoid confirm
* message when we submit form from secure page to unsecure
*
* @param string $query
* @return string
*/
public function getResultUrl($query = null)
{
return $this->_getUrl('catalogsearch/result', array(
'_query' => array(self::QUERY_VAR_NAME => $query),
'_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()
));
}
/**
* Retrieve suggest url
*
* @return string
*/
public function getSuggestUrl()
{
return $this->_getUrl('catalogsearch/ajax/suggest', array(
'_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()
));
}
/**
* Retrieve search term url
*
* @return string
*/
public function getSearchTermUrl()
{
return $this->_getUrl('catalogsearch/term/popular');
}
/**
* Retrieve advanced search URL
*
* @return string
*/
public function getAdvancedSearchUrl()
{
return $this->_getUrl('catalogsearch/advanced');
}
/**
* Retrieve minimum query length
*
* @param mixed $store
* @return int
*/
public function getMinQueryLength($store = null)
{
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MIN_QUERY_LENGTH, $store);
}
/**
* Retrieve maximum query length
*
* @param mixed $store
* @return int
*/
public function getMaxQueryLength($store = null)
{
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MAX_QUERY_LENGTH, $store);
}
/**
* Retrieve maximum query words count for like search
*
* @param mixed $store
* @return int
*/
public function getMaxQueryWords($store = null)
{
return Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MAX_QUERY_WORDS, $store);
}
/**
* Add Note message
*
* @param string $message
* @return Mage_CatalogSearch_Helper_Data
*/
public function addNoteMessage($message)
{
$this->_messages[] = $message;
return $this;
}
/**
* Set Note messages
*
* @param array $messages
* @return Mage_CatalogSearch_Helper_Data
*/
public function setNoteMessages(array $messages)
{
$this->_messages = $messages;
return $this;
}
/**
* Retrieve Current Note messages
*
* @return array
*/
public function getNoteMessages()
{
return $this->_messages;
}
/**
* Check query of a warnings
*
* @param mixed $store
* @return Mage_CatalogSearch_Helper_Data
*/
public function checkNotes($store = null)
{
if ($this->_isMaxLength) {
$this->addNoteMessage($this->__('Maximum Search query length is %s. Your query was cut.', $this->getMaxQueryLength()));
}
$stringHelper = Mage::helper('core/string');
/* @var $stringHelper Mage_Core_Helper_String */
$searchType = Mage::getStoreConfig(Mage_CatalogSearch_Model_Fulltext::XML_PATH_CATALOG_SEARCH_TYPE);
if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE ||
$searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) {
$wordsFull = $stringHelper->splitWords($this->getQueryText(), true);
$wordsLike = $stringHelper->splitWords($this->getQueryText(), true, $this->getMaxQueryWords());
if (count($wordsFull) > count($wordsLike)) {
$wordsCut = array_diff($wordsFull, $wordsLike);
$wordsCut = array_map(array($this, 'htmlEscape'), $wordsCut);
$this->addNoteMessage(
$this->__('Maximum words count is %1$s. In your search query was cut next part: %2$s.',
$this->getMaxQueryWords(),
join(' ', $wordsCut)
)
);
}
}
}
/**
* Join index array to string by separator
* Support 2 level array gluing
*
* @param array $index
* @param string $separator
* @return string
*/
public function prepareIndexdata($index, $separator = ' ')
{
$_index = array();
foreach ($index as $key => $value) {
if (!is_array($value)) {
$_index[] = $value;
}
else {
$_index = array_merge($_index, $value);
}
}
return join($separator, $_index);
}
/**
* Get current search engine resource model
*
* @return object
*/
public function getEngine()
{
if (!$this->_engine) {
$engine = Mage::getStoreConfig('catalog/search/engine');
/**
* This needed if there already was saved in configuration some none-default engine
* and module of that engine was disabled after that.
* Problem is in this engine in database configuration still set.
*/
if ($engine && Mage::getConfig()->getResourceModelClassName($engine)) {
$model = Mage::getResourceSingleton($engine);
if ($model && $model->test()) {
$this->_engine = $model;
}
}
if (!$this->_engine) {
$this->_engine = Mage::getResourceSingleton('catalogsearch/fulltext_engine');
}
}
return $this->_engine;
}
}
ResultController.php
<?php
class Mage_CatalogSearch_ResultController extends Mage_Core_Controller_Front_Action
{
/**
* Retrieve catalog session
*
* @return Mage_Catalog_Model_Session
*/
protected function _getSession()
{
return Mage::getSingleton('catalog/session');
}
/**
* Display search result
*/
public function indexAction()
{
$query = Mage::helper('catalogsearch')->getQuery();
/* @var $query Mage_CatalogSearch_Model_Query */
$query->setStoreId(Mage::app()->getStore()->getId());
if ($query->getQueryText()) {
if (Mage::helper('catalogsearch')->isMinQueryLength()) {
$query->setId(0)
->setIsActive(1)
->setIsProcessed(1);
}
else {
if ($query->getId()) {
$query->setPopularity($query->getPopularity()+1);
}
else {
$query->setPopularity(1);
}
if ($query->getRedirect()){
$query->save();
$this->getResponse()->setRedirect($query->getRedirect());
return;
}
else {
$query->prepare();
}
}
Mage::helper('catalogsearch')->checkNotes();
$this->loadLayout();
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();
if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
$query->save();
}
}
else {
$this->_redirectReferer();
}
}
}
最佳答案
错误表明在您的搜索查询中有多个表将“position”作为列名。
您应该做的是打印出查询和分析。
1- 打开文件:/home/theprint/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php(第 878 行)
2- 在 return 语句之前的方法 getAllIds($limit = null, $offset = null) 中。
/* remember to make this output to you only */echo $idsSelect; /* print out the query string */var_dump($this->_bindParams); /* query parameters values */die;
3- 然后将查询发布到您的问题中。
关于php - 违反完整性约束 : 1052 Column 'position' in order clause is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13298533/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!