0

我正在运行 prestashop 1.4.8.3 并且我在 AdminCustomers.php 上尝试了以下修改

     $this->_select = '(YEAR(CURRENT_DATE)-YEAR(`birthday`)) - (RIGHT(CURRENT_DATE, 5)<RIGHT(`birthday`, 5)) as age, (
            SELECT c.date_add FROM ' . _DB_PREFIX_ . 'guest g
            LEFT JOIN ' . _DB_PREFIX_ . 'connections c ON c.id_guest = g.id_guest
            WHERE g.id_customer = a.id_customer
            ORDER BY c.date_add DESC
            LIMIT 1
        ) as connect';

// This is new code
$this->_select = '(SELECT d.company FROM ' . _DB_PREFIX_ . 'address d WHERE d.id_customer = a.id_customer LIMIT 1) as company';

// LH company name
$genders = array(
    1 => $this->l('M'),
    2 => $this->l('F'),
    9 => $this->l('?'));
$this->fieldsDisplay = array(
    'id_customer' => array(
        'title' => $this->l('ID'),
        'align' => 'center',
        'width' => 25),
    'id_gender' => array(
        'title' => $this->l('Gender'),
        'width' => 25,
        'align' => 'center',
        'icon' => array(
            1 => 'male.gif',
            2 => 'female.gif',
            'default' => 'unknown.gif'),
        'orderby' => false,
        'type' => 'select',
        'select' => $genders,
        'filter_key' => 'a!id_gender'),
    '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),
    'company' => array('title' => $this->l('Company'), 'width' => 60),
    'age' => array(
        'title' => $this->l('Age'),
        'width' => 30,
        'search' => false),
    '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),
    'optin' => array(
        'title' => $this->l('Opt.'),
        'width' => 25,
        'align' => 'center',
        'type' => 'bool',
        'callback' => 'printOptinIcon',
        'orderby' => false),
    'date_add' => array(
        'title' => $this->l('Registration'),
        'width' => 30,
        'type' => 'date',
        'align' => 'right'),
    'connect' => array(
        'title' => $this->l('Connection'),
        'width' => 60,
        'type' => 'datetime',
        'search' => false));

奇怪的是,它似乎可以工作,但只有一两次浏览器刷新,然后它无法显示 SQL 失败消息。

任何能让我走上正轨的想法都将受到高度赞赏。

4

2 回答 2

0

尝试 show sql debug on open file config>config.inc.php并设置 true define('_PS_DEBUG_SQL_', false)。您会注意到错误语法 sql。不要忘记尝试修改您的代码

$temp = '(SELECT d.company FROM ' . _DB_PREFIX_ . 'address d WHERE d.id_customer = a.id_customer LIMIT 1) as company';

var_dump(Db::getInstance()->ExecuteS($sql));

最后,运行你的代码,你会发现错误是什么:)

于 2012-10-25T08:46:33.907 回答
0

你可以试试:

// This is new code
$this->_select .= ', (SELECT d.company FROM ' . _DB_PREFIX_ . 'address d WHERE d.id_customer = a.id_customer LIMIT 1) as company';

您也可以在这里看到您的 sql 查询: AdminTab::getList()在线$this->_list = Db::getInstance()->ExecuteS($sql);

于 2012-10-09T11:08:41.157 回答