无效的文本表示symfony

时间:2017-03-22 19:56:37

标签: php symfony parameters converter

我正在尝试在symfony2中使用ParamConverter。但我有这个错误:

An exception occurred while executing 'SELECT t0.logo AS logo_1, t0.interest AS interest_2, t0.period AS period_3, t0.amount AS amount_4, t0.created_at AS created_at_5, t0.updated_at AS updated_at_6, t0.url_pattern AS url_pattern_7, t0.annotation AS annotation_8, t0.first_loan_free AS first_loan_free_9, t0.max_value AS max_value_10, t0.rrso AS rrso_11, t0.id AS id_12, t0.advertisement_status_id AS advertisement_status_id_13, t0.advertiser_id AS advertiser_id_14 FROM advertisement t0 WHERE t0.id = ?' with params ["go"]:

我不知道为什么我的控制器尝试使用params SELECT从我的实体"go"。我试图解决这个问题,但我不知道我做错了什么。 任何sugestions?

这是我的实体:

/**
 * Advertisement
 *
 * @ORM\Table(name="advertisement", indexes={@ORM\Index(name="IDX_C95F6AEEBA2FCBC2", columns={"advertiser_id"}), @ORM\Index(name="IDX_C95F6AEE138EAC6A", columns={"advertisement_status_id"})})
 * @ORM\Entity
 */
class Advertisement extends BaseEntity
{
    /**
     * @var integer
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="SEQUENCE")
     * @ORM\SequenceGenerator(sequenceName="advertisement_id_seq", allocationSize=1, initialValue=1)
     */
    protected $id; 

/**
 * @var string
 *
 * @ORM\Column(name="logo", type="blob", nullable=true)
 */
protected $logo;

/**
 * @var string
 *
 * @ORM\Column(name="interest", type="decimal", precision=10, scale=0, nullable=false)
 */
protected $interest = '0';

/**
 * @var integer
 *
 * @ORM\Column(name="period", type="integer", nullable=false)
 */
protected $period;

/**
 * @var string
 *
 * @ORM\Column(name="amount", type="decimal", precision=10, scale=0, nullable=false)
 */
protected $amount;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="created_at", type="datetime", nullable=false)
 */
protected $createdAt;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="updated_at", type="datetime", nullable=false)
 */
protected $updatedAt;

/**
 * @var string
 *
 * @ORM\Column(name="url_pattern", type="string", nullable=true)
 */
protected $urlPattern;

/**
 * @var string
 *
 * @ORM\Column(name="annotation", type="string", nullable=true)
 */
protected $annotation;
.
.
.

这是我的控制者:

<?php

namespace AffiliateBundle\Controller;


use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use AffiliateBundle\Entity\Lead;
use AffiliateBundle\Entity\Advertisement;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Cookie;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;



/**
 * Catch controller.
 *
 * @Route("catch")
 */
class CatchController extends Controller
{

    /**
     * @Route("/{id}")
     * @Method({"GET"})
     * @ParamConverter("advertisement", class="AffiliateBundle:Advertisement")
     */
    public function goAction(Advertisement $advertisement)
    {

        //Creating new Lead      
        $lead = new Lead();
        $lead ->setCreatedAt(new \DateTime());
        $lead ->setUpdatedAt(new \DateTime());
        $add = $this->getDoctrine()->getManager();
        $add->persist($lead);
        $add->flush();            
        //Taking id of the created lead
        $leadId = $lead->getId();
        //Saving cookie in user's browser
        $cookieValue = array(
            'name' => 'leadcookie',
            'value' => $leadId
        );
        $cookieLead = new Cookie($cookieValue['name'], $cookieValue['value']);
        $response = new Response();
        $response->headers->setCookie($cookieLead);
        return $this->redirect('http://xyz.pl');

    }

}

有人可以告诉我我做错了吗?

0 个答案:

没有答案