- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为 prestashop 编写一个选项卡,其中列出了客户的原籍国。到目前为止还可以,但我想按国家/地区过滤查询或表,因此我想添加以下内容:其中 iso_code = 'IT'显然prestashop不让我,我该怎么办?这是我的代码:
<?php
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminCustomersCountries extends AdminTab
{
public function __construct()
{
$this->table = 'customer';
$this->className = 'Customer';
$this->lang = false;
$this->edit = false;
$this->view = true;
$this->delete = false;
$this->deleted = false;
$this->requiredDatabase = true;
$this->_select = '(SELECT cy.iso_code FROM ps_address AS addr, ps_country AS cy WHERE addr.id_customer=a.id_customer AND addr.id_country=cy.id_country) AS iso_code';
$this->fieldsDisplay = array(
'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'lastname' => array('title' => $this->l('Last Name'), 'width' => 80),
'firstname' => array('title' => $this->l('First name'), 'width' => 60),
'email' => array('title' => $this->l('E-mail address'), 'width' => 120, 'maxlength' => 19),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
'newsletter' => array('title' => $this->l('News.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'callback' => 'printNewsIcon', 'orderby' => false),
'iso_code' => array('title' => "Nazione", 'width' => 60, 'orderby'=>false, 'search'=>false));
$this->optionTitle = "Prova";
parent::__construct();
}
public function postProcess()
{
// This function is executed when the Submit button is clicked
// Use it to store the value of text fields in the database
parent::postProcess();
}
public function displayForm($token=NULL)
{
// This function can be used to create a form with text fields
}
}
?>
但是,我在这里尝试添加 WHERE 子句,但没有结果:
<?php
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminCustomersCountries extends AdminTab
{
public function __construct()
{
$this->table = 'customer';
$this->className = 'Customer';
$this->lang = false;
$this->edit = false;
$this->view = true;
$this->delete = false;
$this->deleted = false;
$this->requiredDatabase = true;
$this->_select = '(SELECT cy.iso_code FROM ps_address AS addr, ps_country AS cy WHERE addr.id_customer=a.id_customer AND addr.id_country=cy.id_country AND cy.iso_code='IT') AS iso_code';
$this->fieldsDisplay = array(
'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'lastname' => array('title' => $this->l('Last Name'), 'width' => 80),
'firstname' => array('title' => $this->l('First name'), 'width' => 60),
'email' => array('title' => $this->l('E-mail address'), 'width' => 120, 'maxlength' => 19),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
'newsletter' => array('title' => $this->l('News.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'callback' => 'printNewsIcon', 'orderby' => false),
'iso_code' => array('title' => "Nazione", 'width' => 60, 'orderby'=>false, 'search'=>false));
$this->optionTitle = "Prova";
parent::__construct();
}
public function postProcess()
{
// This function is executed when the Submit button is clicked
// Use it to store the value of text fields in the database
parent::postProcess();
}
public function displayForm($token=NULL)
{
// This function can be used to create a form with text fields
}
}
?>
最佳答案
我不确定您为什么在那里使用子查询,但 PS AdminTab 类还提供了两个其他选项。
1)Where:每当你需要添加where子句时,你可以像下面这样写
$this->_where = 'your condition here';
2)连接:PS还为您提供了额外的连接功能,您可以像这样编写它们
$this->_join = 'write down all your joins here like normal queries';
现在,如果您想通过附加检查(wheres)从其他表中获取附加信息,那么您可以按如下方式执行。 :
**注意:对于表,PS 给出以“a”开头的别名,如果它有其他表(例如语言表),则它以 b 等开头。所以你应该知道,在 join、_select 和 _where 中你应该使用正确的别名。 **
$this->_select = 'all your additional fields from the tables you need. Those tables should be joined in the _join query.';
$this->_join = 'All your joins here with correct aliases, as these aliases are used in _select query and in _where';
$this->_where = 'your where clauses here.';
我希望这能帮助您纠正您的疑问。
谢谢
关于php - Prestashop 管理选项卡 - clausole 不起作用的地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16873273/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!