duanlu1279 2018-08-13 07:44
浏览 539
已采纳

SQLSTATE [42601]:语法错误:7内部连接错误

I have a problem with a line on my SQL/Zend query, but I didn't understand about this.

public function getByDemande($idDemande, $typeTiers) {

        $select = $this -> newSelect(true);
        $select -> from(array('d' => 'Demande'));
        $select -> join(array('s' => 'Suivi'), 'd."idDemande" = s."idDemande"');
        $select -> join(array('t' => $typeTiers),'d."idContact" = t."idTiers"');
        $select -> joinLeft(array('tet' => 'TelephoneTiers'), 't."idTiers" = tet."idTiers"');
        $select -> joinLeft(array('mt' => 'MailTiers'), 't."idTiers" = mt."idTiers"');
        $select -> join(array('at' => 'AdresseTiers'), 't."idTiers" = at."idTiers"');
        $select -> where('d."idDemande" = s."idDemande"', $idDemande);
        $select -> where('d.actif is true');
        $select -> order('s.dateHeure DESC');

        $resultat = $select->__toString();
        echo "$resultat
";

        return $this->fetchAll($select);
    }

I launch my SQL/Zend query, but this throws an error (SQLSTATE[42601]: Syntax error: 7 ERREUR: identifiant délimité de longueur nulle sur ou près de « "" »↵LINE 3: INNER JOIN "" AS "t" ON d."idContact" = t."idTiers")

On the other file, I coded to recover data from this SQL query.

$data = $this->_getPostData();
        $idDemande = $data['idDemande'];
        $idTypeTiers = $data['idTypeTiers'];
        $typeTiers = null;

        $gtwDemande = new LogisCom_Model_Gateway_Demande();
        $resultatDemande = $gtwDemande->getByDemande($idDemande, $typeTiers);
        $resultatDemande = $resultatDemande->toArray();

        switch ($idTypeTiers) {

            case TypeTiers::BENEFICIAIRE :
                $typeTiers = "Beneficiaire";
                break;
            case TypeTiers::SALARIE :
                $typeTiers = "Salarie";
                break;
            case TypeTiers::PROSPECT :
                $typeTiers = "Prospect";
                break;
            case TypeTiers::CANDIDAT :
                $typeTiers = "Candidat";
                break;
            case TypeTiers::ENTOURAGE :
                $typeTiers = "Entourage";
                break;
            case TypeTiers::FINANCEUR :
                $typeTiers = "Financeur";
                break;
            case TypeTiers::AUTRE :
                $typeTiers = "StructureExterne";
                break;
        }

Thanks for help.

  • 写回答

1条回答 默认 最新

  • duanan5940 2018-08-13 08:17
    关注

    It seems the variable $typeTiers is either not defined or an empty string. Please try to place a var_dump($typeTiers) at the beginning of your method to see what the variable in question contains. If it is empty, just don't call your method with an emtpy string by just checking beforehand.

    In your switch/case you don't have a default fallback. So it is possible that your $idTypeTiers has a value not in your cases, and $typeTiers keeps being null. But your call to getByDemande is done even before this switch, so even with the fallback your variable would always be null.

    Addendum:

    You might want to translate the error messages to English, because not everyone speaks french (this also applies to other languages). This way, it will be easier for people to understand your error message without the use of a translator etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题