Symfony - Orocommerce:缺少表“t0"的 FROM 子句条目; [英] Symfony - Orocommerce: missing FROM-clause entry for table "t0"

查看:33
本文介绍了Symfony - Orocommerce:缺少表“t0"的 FROM 子句条目;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自定义 symfony - orocommerce 的updateAction"客户,经过多次尝试后,它在日志文件中抛出此错误消息:

<块引用>

未捕获的 PHP 异常 Doctrine\DBAL\Exception\TableNotFoundException:执行时发生异常:

'SELECT t1.serialized_data ASserialized_data_2, t1.id AS id_3, t1.confirmed ASconfirmed_4,t1.email AS email_5, t1.email_lowercase AS email_lowercase_6,t1.name_prefix AS name_prefix_7, t1.first_name AS first_name_8,t1.middle_name AS middle_name_9, t1.last_name AS last_name_10,t1.name_suffix AS name_suffix_11,t1.birthday ASbirthday_12,t1.created_at AS created_at_13, t1.updated_at AS updated_at_14,t1.enabled AS enabled_15, t1.login_count AS login_count_16,t1.username AS username_17, t1.is_guest AS is_guest_18, t1.password AS密码_19,t1.salt AS salt_20,t1.last_login AS last_login_21,t1.confirmation_token ASconfirmation_token_22, t1.password_requestedAS password_requested_23, t1.password_changed AS password_changed_24,t1.pharmacy_name AS pharmacy_name_25, t1.pharmacy_address ASpharmacy_address_26, t1.pbs_approval_number AS pbs_approval_number_27,t1.business_name AS business_name_28, t1.australian_business_number ASaustralian_business_number_29, t1.business_phone_number ASbusiness_phone_number_30, t1.fax_number AS fax_number_31,t1.pharmacy_owner_full_name AS pharmacy_owner_full_name_32,t1.ahpra_no AS ahpra_no_33, t1.group_name AS group_name_34,t1.group_contact_name AS group_contact_name_35, t1.group_contact_emailAS group_contact_email_36, t1.group_contact_phone_number ASgroup_contact_phone_number_37, t1.customer_id AS customer_id_38,t1.owner_id AS owner_id_39, t1.website_id AS website_id_40,t1.organization_id AS organization_id_41 FROM oro_customer_user t1哪里 t0.id = ?使用参数 ["94"]:

SQLSTATE[42P01]:未定义表:7 错误:缺少表t0"第 1 行的 FROM 子句条目:...rganization_id_41 FROM oro_customer_user t1 WHERE t0.id = '9


可以这样写:

SELECT * FROM oro_customer_user t1 WHERE t0.id = 94

在搜索之后,似乎我没有以正确的方式扩展实体,所以我可以知道如何做到这一点吗?



这是我的代码:

<块引用>

MyCode\Bundle\CustomerBundle\Controller\CustomerUserController

MyCodeUpdate($customerUser, $request);}/*** @param MyCodeCustomerUser $customerUser* @param 请求 $request* @return 数组|重定向响应*/受保护的功能 MyCodeUpdate(MyCodeCustomerUser $customerUser, Request $request){$form = $this->createForm(MyCodeCustomerUserType::class, $customerUser);$handler = new CustomerUserHandler($形式,$请求,$this->get('oro_customer_user.manager'),$this->get('oro_security.token_accessor'),$this->get('translator'),$this->get('logger'));$result = $this->get('oro_form.model.update_handler')->handleUpdate($客户用户,$形式,函数 (MyCodeCustomerUser $customerUser) {返回 ['路线' =>'mycode_customer_customer_user_update','参数' =>['id' =>$customerUser->getId()]];},函数 (MyCodeCustomerUser $customerUser) {返回 ['路线' =>'oro_customer_customer_user_view','参数' =>['id' =>$customerUser->getId()]];},$this->get('translator')->trans('oro.customer.controller.customeruser.saved.message'),$handler);返回 $result;}

<块引用>

MyCode\Bundle\CustomerBundle\Entity\CustomerUser

请帮忙,谢谢.

解决方案

在论坛上回答.https://forum.oroinc.com/orocommerce/topic/missing-from-clause-entry-for-table-t0请不要在不同频道发布相同的问题.这通常不会加快答案的速度,而是为我们做更多的工作.谢谢

I'm trying to custom the "updateAction" customer of symfony - orocommerce, and after trying a lot, it throw this error message in log file:

Uncaught PHP Exception Doctrine\DBAL\Exception\TableNotFoundException: "An exception occurred while executing:

'SELECT t1.serialized_data AS serialized_data_2, t1.id AS id_3, t1.confirmed AS confirmed_4, t1.email AS email_5, t1.email_lowercase AS email_lowercase_6, t1.name_prefix AS name_prefix_7, t1.first_name AS first_name_8, t1.middle_name AS middle_name_9, t1.last_name AS last_name_10, t1.name_suffix AS name_suffix_11, t1.birthday AS birthday_12, t1.created_at AS created_at_13, t1.updated_at AS updated_at_14, t1.enabled AS enabled_15, t1.login_count AS login_count_16, t1.username AS username_17, t1.is_guest AS is_guest_18, t1.password AS password_19, t1.salt AS salt_20, t1.last_login AS last_login_21, t1.confirmation_token AS confirmation_token_22, t1.password_requested AS password_requested_23, t1.password_changed AS password_changed_24, t1.pharmacy_name AS pharmacy_name_25, t1.pharmacy_address AS pharmacy_address_26, t1.pbs_approval_number AS pbs_approval_number_27, t1.business_name AS business_name_28, t1.australian_business_number AS australian_business_number_29, t1.business_phone_number AS business_phone_number_30, t1.fax_number AS fax_number_31, t1.pharmacy_owner_full_name AS pharmacy_owner_full_name_32, t1.ahpra_no AS ahpra_no_33, t1.group_name AS group_name_34, t1.group_contact_name AS group_contact_name_35, t1.group_contact_email AS group_contact_email_36, t1.group_contact_phone_number AS group_contact_phone_number_37, t1.customer_id AS customer_id_38, t1.owner_id AS owner_id_39, t1.website_id AS website_id_40, t1.organization_id AS organization_id_41 FROM oro_customer_user t1 WHERE t0.id = ?' with params ["94"]:

SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "t0" LINE 1: ...rganization_id_41 FROM oro_customer_user t1 WHERE t0.id = '9


Which can be short write like this:

SELECT * FROM oro_customer_user t1 WHERE t0.id = 94

After searching about this, seem like i've not extends the entity the right way, so may i know how to do this?



Here is my code:

MyCode\Bundle\CustomerBundle\Controller\CustomerUserController

<?php

namespace MyCode\Bundle\CustomerBundle\Controller;

use Oro\Bundle\CustomerBundle\Entity\CustomerUser;
use MyCode\Bundle\CustomerBundle\Entity\CustomerUser as MyCodeCustomerUser;
use Oro\Bundle\CustomerBundle\Form\Handler\CustomerUserHandler;
use Oro\Bundle\CustomerBundle\Form\Type\CustomerUserType;
use MyCode\Bundle\CustomerBundle\Form\Type\CustomerUserType as MyCodeCustomerUserType;
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
use Oro\Bundle\SecurityBundle\Annotation\Acl;
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Oro\Bundle\CustomerBundle\Controller\CustomerUserController as OroCustomerUserController;
use Doctrine\ORM\EntityManager;
use Psr\Log\LoggerInterface;

class CustomerUserController extends Controller
{
/**
     * Edit customer user form
     *
     * @Route("/update/{id}", name="oro_customer_customer_user_update", requirements={"id"="\d+"})
     * @Template
     * @Acl(
     *      id="oro_customer_customer_user_update",
     *      type="entity",
     *      class="MyCodeCustomerBundle:CustomerUser",
     *      permission="EDIT"
     * )
     * @param MyCodeCustomerUser $customerUser
     * @param Request     $request
     * @return array|RedirectResponse
     */
    public function updateAction(MyCodeCustomerUser $customerUser, Request $request)
    {
        die('1');
        return $this->MyCodeUpdate($customerUser, $request);
    }

    /**
     * @param MyCodeCustomerUser $customerUser
     * @param Request     $request
     * @return array|RedirectResponse
     */
    protected function MyCodeUpdate(MyCodeCustomerUser $customerUser, Request $request)
    {        
        $form = $this->createForm(MyCodeCustomerUserType::class, $customerUser);
        $handler = new CustomerUserHandler(
            $form,
            $request,
            $this->get('oro_customer_user.manager'),
            $this->get('oro_security.token_accessor'),
            $this->get('translator'),
            $this->get('logger')
        );

        $result = $this->get('oro_form.model.update_handler')->handleUpdate(
            $customerUser,
            $form,
            function (MyCodeCustomerUser $customerUser) {
                return [
                    'route'      => 'mycode_customer_customer_user_update',
                    'parameters' => ['id' => $customerUser->getId()]
                ];
            },
            function (MyCodeCustomerUser $customerUser) {
                return [
                    'route'      => 'oro_customer_customer_user_view',
                    'parameters' => ['id' => $customerUser->getId()]
                ];
            },
            $this->get('translator')->trans('oro.customer.controller.customeruser.saved.message'),
            $handler
        );

        return $result;
    }

MyCode\Bundle\CustomerBundle\Entity\CustomerUser

<?php

namespace MyCode\Bundle\CustomerBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Oro\Bundle\CustomerBundle\Model\ExtendCustomerUser;
use Oro\Bundle\EmailBundle\Model\EmailHolderInterface;
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField;
use Oro\Bundle\LocaleBundle\Model\FullNameInterface;
use Oro\Bundle\OrganizationBundle\Entity\Organization;
use Oro\Bundle\UserBundle\Entity\AbstractUser;
use Oro\Bundle\UserBundle\Entity\User;
use Oro\Bundle\UserBundle\Security\AdvancedApiUserInterface;
use Oro\Bundle\WebsiteBundle\Entity\Website;
use Oro\Bundle\CustomerBundle\Entity\CustomerUser as OroCustomerUser;

/**
 * The entity that represents a person who acts on behalf of the company
 * to buy products using OroCommerce store frontend.
 *
 * @ORM\Entity()
 * @ORM\Table(name="oro_customer_user")
 */
class CustomerUser extends OroCustomerUser
{
    /**
    * @ORM\Column(name="pharmacy_name", type="string", nullable=true)
    */
    private $pharmacy_name;

    /**
    * @ORM\Column(name="pharmacy_address", type="string", nullable=true)
    */
    private $pharmacy_address;

    /**
    * @ORM\Column(name="pbs_approval_number", type="string", nullable=true)
    */
    private $pbs_approval_number;

    /**
    * @ORM\Column(name="business_name", type="string", nullable=true)
    */
    private $business_name;

    /**
    * @ORM\Column(name="australian_business_number", type="string", nullable=true)
    */
    private $australian_business_number;

    /**
    * @ORM\Column(name="business_phone_number", type="string", nullable=true)
    */
    private $business_phone_number;

    /**
    * @ORM\Column(name="fax_number", type="string", nullable=true)
    */
    private $fax_number;

    /**
    * @ORM\Column(name="pharmacy_owner_full_name", type="string", nullable=true)
    */
    private $pharmacy_owner_full_name;

    /**
    * @ORM\Column(name="ahpra_no", type="string", nullable=true)
    */
    private $ahpra_no;

    /**
    * @ORM\Column(name="group_name", type="string", nullable=true)
    */
    private $group_name;

    /**
    * @ORM\Column(name="group_contact_name", type="string", nullable=true)
    */
    private $group_contact_name;

    /**
    * @ORM\Column(name="group_contact_email", type="string", nullable=true)
    */
    private $group_contact_email;

    /**
    * @ORM\Column(name="group_contact_phone_number", type="string", nullable=true)
    */
    private $group_contact_phone_number;

    /**
     * {@inheritdoc}
     */
    public function __construct()
    {
        parent::__construct();
    }

Please help, thanks.

解决方案

Answered at the forum. https://forum.oroinc.com/orocommerce/topic/missing-from-clause-entry-for-table-t0 Please don't post the same questions at different channels. This usually not speed up the answer, but make more work for us. Thank you

这篇关于Symfony - Orocommerce:缺少表“t0"的 FROM 子句条目;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆