2016-08-04 2 views
1

мне нужно, чтобы отобразить всю информацию из 5 таблицКак получить значения из возвращаемого запроса в twig?

samochody_konfiguracja, model, wersja, wyposazenie_standardowe, silnik

enter image description here

Вот мой пользовательский репозиторий KonfiguracjaRepository.php:

<?php 

namespace Engineer\ConfiguratorBundle\Repository; 

use Doctrine\ORM\EntityRepository; 

class KonfiguracjaRepository extends EntityRepository { 

public function getQueryBuilder() { 
    $qb = $this->createQueryBuilder('c') 
        ->leftJoin('c.model', 'm') 
        ->leftJoin('c.lakiery', 'l') 
        ->leftJoin('c.tapicerki', 't') 
        ->leftJoin('c.obreczeKol', 'o') 
        ->leftJoin('m.wersja', 'w') 
        ->leftJoin('w.wyposazenieStandardowe', 'ws') 
        ->leftJoin('ws.silnik', 's') 
        ->addSelect('m, w, ws, s') 
        ->getQuery()->getResult(); 
    return $qb; 
} 

}

My Controller ConfiguratorController.php:

<?php 

namespace Engineer\ConfiguratorBundle\Controller; 

use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; 

class ConfiguratorController extends Controller { 

/** 
* @Route("/configurator", 
*  name="site_configurator" 
*) 
* @Template() 
*/ 
public function configuratorAction() { 

    $ConfRepo= $this->getDoctrine()->getRepository('EngineerConfiguratorBundle:SamochodyKonfiguracja');  
    $qb= $ConfRepo->getQueryBuilder(); 

    return array(
     'allConf'=> $qb 
    );  
} 
} 

А вот мой прутик файл:

{% for conf in allConf %} 
       <h3>Id konfiguracji:{{ conf.idSamochodyKonfiguracja }}</h3> 
       <p>Cena: {{ conf.cena }} zł</p> 
       <p>Nazwa modelu: {{ conf.model.nazwa }}</p> 
       <p>Cena modelu: {{ conf.model.cena }}</p>     
       {% for wersja in conf.model.wersja %} 
        <p>Id wersji: {{ wersja.idWersja }}</p> 
        <p>Nazwa wersji: {{ wersja.nazwa }}</p> 
        <p>Cena wersji: {{ wersja.cena }}</p> 
        {% for ws in conf.model.wersja.wyposazenieStandardowe %} 
         <p>Nazwa wyposażenia standardowego: {{ ws.nazwaWyposazenia }}</p> 
         <p>Cena wyposażenia standardowego: {{ ws.cena }}</p> 
        {% endfor %} 
       {% endfor %}  
      {% endfor %} 

Запрос в Symfony Profiler выглядит отлично:

SELECT s0_.id_samochody_konfiguracja AS id_samochody_konfiguracja_0, s0_.cena AS cena_1, m1_.id_model AS id_model_2, m1_.nazwa AS nazwa_3, m1_.cena AS cena_4, w2_.id_wersja AS id_wersja_5, w2_.nazwa AS nazwa_6, w2_.cena AS cena_7, w3_.id_wyposazenie_standardowe AS id_wyposazenie_standardowe_8, w3_.nazwa_wyposazenia AS nazwa_wyposazenia_9, w3_.cena AS cena_10, s4_.id_silnik AS id_silnik_11, s4_.rodzaj_silnika AS rodzaj_silnika_12, s4_.cena AS cena_13, s4_.kM AS kM_14, s4_.skrzynia_biegow AS skrzynia_biegow_15, s4_.rodzaj_napedu AS rodzaj_napedu_16, s0_.id_model AS id_model_17, s0_.id_lakiery AS id_lakiery_18, s0_.id_obrecze_kol AS id_obrecze_kol_19, s0_.id_tapicerki AS id_tapicerki_20, s0_.id AS id_21, w2_.id_model AS id_model_22, w3_.id_wersja AS id_wersja_23, s4_.id_wyposazenie_standardowe AS id_wyposazenie_standardowe_24 FROM samochody_konfiguracja s0_ LEFT JOIN model m1_ ON s0_.id_model = m1_.id_model LEFT JOIN lakiery l5_ ON s0_.id_lakiery = l5_.id_lakiery LEFT JOIN tapicerki t6_ ON s0_.id_tapicerki = t6_.id_tapicerki LEFT JOIN obrecze_kol o7_ ON s0_.id_obrecze_kol = o7_.id_obrecze_kol LEFT JOIN wersja w2_ ON m1_.id_model = w2_.id_model LEFT JOIN wyposazenie_standardowe w3_ ON w2_.id_wersja = w3_.id_wersja LEFT JOIN silnik s4_ ON w3_.id_wyposazenie_standardowe = s4_.id_wyposazenie_standardowe 

я могу получить и отображать значения из таблиц: samochody_konfiguracja, модель и Wersja, но Я не могу получить его от wyposazenie_dodatkowe. я получил ошибку:

Neither the property "wyposazenieStandardowe" nor one of the methods "wyposazenieStandardowe()", "getwyposazenieStandardowe()"/"iswyposazenieStandardowe()" or "__call()" exist and have public access in class "Doctrine\ORM\PersistentCollection" in src\Engineer\ConfiguratorBundle\Resources\views\Configurator\configurator.html.twig at line 58

Так я думаю, моя проблема заключается в веточке файл. Как я могу получить результат, который я ищу?

Я думаю, что мои лица и assiociations правильны:

SamochodyKonfiguracja.php:

<?php 

namespace Engineer\ConfiguratorBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 

/** 
* @ORM\Entity(repositoryClass="Engineer\ConfiguratorBundle\Repository\KonfiguracjaRepository") 
* @ORM\Table(name="samochody_konfiguracja") 
* 
*/ 
class SamochodyKonfiguracja { 

/** 
* @ORM\Column(
*  type="integer", 
*  name="id_samochody_konfiguracja"  
*) 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $idSamochodyKonfiguracja; 

/** 
* @ORM\Column(
*  type="decimal", 
*  precision=9, 
*  scale=2 
*) 
*/ 
private $cena; 

/** 
* @ORM\ManyToOne(
*  targetEntity="Model", 
*  inversedBy="samochodyKonfiguracja" 
*) 
* @ORM\JoinColumn(
*  name="id_model", 
*  referencedColumnName="id_model", 
*  onDelete= "SET NULL" 
*) 
*/ 
private $model; 

/** 
* @ORM\ManyToOne(
*  targetEntity="Lakiery", 
*  inversedBy="samochodyKonfiguracja" 
*) 
* @ORM\JoinColumn(
*  name="id_lakiery", 
*  referencedColumnName="id_lakiery", 
*  onDelete= "SET NULL" 
*) 
*/ 
private $lakiery; 

    /** 
* @ORM\ManyToOne(
*  targetEntity="ObreczeKol", 
*  inversedBy="samochodyKonfiguracja" 
*) 
* @ORM\JoinColumn(
*  name="id_obrecze_kol", 
*  referencedColumnName="id_obrecze_kol", 
*  onDelete= "SET NULL" 
*) 
*/ 
private $obreczeKol; 

/** 
* @ORM\ManyToOne(
*  targetEntity="Tapicerki", 
*  inversedBy="samochodyKonfiguracja" 
* 
*) 
* @ORM\JoinColumn(
*  name="id_tapicerki", 
*  referencedColumnName="id_tapicerki", 
*  onDelete= "SET NULL" 
*) 
*/ 
private $tapicerki; 

/** 
* @ORM\ManyToMany(
*  targetEntity="WyposazeniaDodatkowe", 
*  inversedBy="samochodyKonfiguracja" 
*) 
* @ORM\JoinTable(name="samochody_konfiguracja_wyposazenia_dodatkowe", 
*  joinColumns={ 
*   @ORM\JoinColumn(
*    name="id_samochody_konfiguracja", 
*    referencedColumnName="id_samochody_konfiguracja" 
*   ) 
*  }, 
*  inverseJoinColumns={ 
*   @ORM\JoinColumn(
*    name="id_wyposazenia_dodatkowe", 
*    referencedColumnName="id_wyposazenia_dodatkowe" 
*   ) 
*  } 
*) 
*/ 
private $wyposazeniaDodatkowe; 

/** 
* @ORM\ManyToOne(
*  targetEntity = "Common\UserBundle\Entity\User" 
*) 
* 
* @ORM\JoinColumn(
*  name = "id", 
*  referencedColumnName = "id", 
*) 
*/ 
private $user; 



/** 
* Constructor 
*/ 
public function __construct() 
{ 
    $this->wyposazeniaDodatkowe = new \Doctrine\Common\Collections\ArrayCollection(); 
} 

/** 
* Get idSamochodyKonfiguracja 
* 
* @return integer 
*/ 
public function getIdSamochodyKonfiguracja() 
{ 
    return $this->idSamochodyKonfiguracja; 
} 

/** 
* Set cena 
* 
* @param string $cena 
* 
* @return SamochodyKonfiguracja 
*/ 
public function setCena($cena) 
{ 
    $this->cena = $cena; 

    return $this; 
} 

/** 
* Get cena 
* 
* @return string 
*/ 
public function getCena() 
{ 
    return $this->cena; 
} 

/** 
* Set model 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Model $model 
* 
* @return SamochodyKonfiguracja 
*/ 
public function setModel(\Engineer\ConfiguratorBundle\Entity\Model $model = null) 
{ 
    $this->model = $model; 

    return $this; 
} 

/** 
* Get model 
* 
* @return \Engineer\ConfiguratorBundle\Entity\Model 
*/ 
public function getModel() 
{ 
    return $this->model; 
} 

/** 
* Set lakiery 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Lakiery $lakiery 
* 
* @return SamochodyKonfiguracja 
*/ 
public function setLakiery(\Engineer\ConfiguratorBundle\Entity\Lakiery $lakiery = null) 
{ 
    $this->lakiery = $lakiery; 

    return $this; 
} 

/** 
* Get lakiery 
* 
* @return \Engineer\ConfiguratorBundle\Entity\Lakiery 
*/ 
public function getLakiery() 
{ 
    return $this->lakiery; 
} 

/** 
* Set obreczeKol 
* 
* @param \Engineer\ConfiguratorBundle\Entity\ObreczeKol $obreczeKol 
* 
* @return SamochodyKonfiguracja 
*/ 
public function setObreczeKol(\Engineer\ConfiguratorBundle\Entity\ObreczeKol $obreczeKol = null) 
{ 
    $this->obreczeKol = $obreczeKol; 

    return $this; 
} 

/** 
* Get obreczeKol 
* 
* @return \Engineer\ConfiguratorBundle\Entity\ObreczeKol 
*/ 
public function getObreczeKol() 
{ 
    return $this->obreczeKol; 
} 

/** 
* Set tapicerki 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Tapicerki $tapicerki 
* 
* @return SamochodyKonfiguracja 
*/ 
public function setTapicerki(\Engineer\ConfiguratorBundle\Entity\Tapicerki $tapicerki = null) 
{ 
    $this->tapicerki = $tapicerki; 

    return $this; 
} 

/** 
* Get tapicerki 
* 
* @return \Engineer\ConfiguratorBundle\Entity\Tapicerki 
*/ 
public function getTapicerki() 
{ 
    return $this->tapicerki; 
} 

/** 
* Add wyposazeniaDodatkowe 
* 
* @param \Engineer\ConfiguratorBundle\Entity\WyposazeniaDodatkowe $wyposazeniaDodatkowe 
* 
* @return SamochodyKonfiguracja 
*/ 
public function addWyposazeniaDodatkowe(\Engineer\ConfiguratorBundle\Entity\WyposazeniaDodatkowe $wyposazeniaDodatkowe) 
{ 
    $this->wyposazeniaDodatkowe[] = $wyposazeniaDodatkowe; 

    return $this; 
} 

/** 
* Remove wyposazeniaDodatkowe 
* 
* @param \Engineer\ConfiguratorBundle\Entity\WyposazeniaDodatkowe $wyposazeniaDodatkowe 
*/ 
public function removeWyposazeniaDodatkowe(\Engineer\ConfiguratorBundle\Entity\WyposazeniaDodatkowe $wyposazeniaDodatkowe) 
{ 
    $this->wyposazeniaDodatkowe->removeElement($wyposazeniaDodatkowe); 
} 

/** 
* Get wyposazeniaDodatkowe 
* 
* @return \Doctrine\Common\Collections\Collection 
*/ 
public function getWyposazeniaDodatkowe() 
{ 
    return $this->wyposazeniaDodatkowe; 
} 

/** 
* Set user 
* 
* @param \Common\UserBundle\Entity\User $user 
* 
* @return SamochodyKonfiguracja 
*/ 
public function setUser(\Common\UserBundle\Entity\User $user = null) 
{ 
    $this->user = $user; 

    return $this; 
} 

/** 
* Get user 
* 
* @return \Common\UserBundle\Entity\User 
*/ 
public function getUser() 
{ 
    return $this->user; 
} 

}

Model.php:

<?php 

namespace Engineer\ConfiguratorBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 

/** 
* @ORM\Entity 
* @ORM\Table(name="model") 
* 
*/ 
class Model { 

/** 
* @ORM\Column(
*  type="integer", 
*  name="id_model" 
* ) 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $idModel; 

/** 
* @ORM\Column(type="string", 
*  length=20, 
*  unique=true 
*) 
* @Assert\Length(
*  max = 20 
*) 
*/ 
private $nazwa; 

/** 
* @ORM\Column(
*  type="decimal", 
*  precision=9, 
*  scale=2 
*) 
*/ 
private $cena; 

/** 
* @ORM\OneToMany(
*  targetEntity="SamochodyKonfiguracja", 
*  mappedBy="model" 
* ) 
*/ 
private $samochodyKonfiguracja; 

/** 
* @ORM\OneToMany(
*  targetEntity="Wersja", 
*  mappedBy="model" 
* ) 
*/ 
private $wersja; 


/** 
* Constructor 
*/ 
public function __construct() 
{ 
    $this->samochodyKonfiguracja = new \Doctrine\Common\Collections\ArrayCollection(); 
    $this->wersja = new \Doctrine\Common\Collections\ArrayCollection(); 
} 

/** 
* Get idModel 
* 
* @return integer 
*/ 
public function getIdModel() 
{ 
    return $this->idModel; 
} 

/** 
* Set nazwa 
* 
* @param string $nazwa 
* 
* @return Model 
*/ 
public function setNazwa($nazwa) 
{ 
    $this->nazwa = $nazwa; 

    return $this; 
} 

/** 
* Get nazwa 
* 
* @return string 
*/ 
public function getNazwa() 
{ 
    return $this->nazwa; 
} 

/** 
* Set cena 
* 
* @param string $cena 
* 
* @return Model 
*/ 
public function setCena($cena) 
{ 
    $this->cena = $cena; 

    return $this; 
} 

/** 
* Get cena 
* 
* @return string 
*/ 
public function getCena() 
{ 
    return $this->cena; 
} 

/** 
* Add samochodyKonfiguracja 
* 
* @param \Engineer\ConfiguratorBundle\Entity\SamochodyKonfiguracja $samochodyKonfiguracja 
* 
* @return Model 
*/ 
public function addSamochodyKonfiguracja(\Engineer\ConfiguratorBundle\Entity\SamochodyKonfiguracja $samochodyKonfiguracja) 
{ 
    $this->samochodyKonfiguracja[] = $samochodyKonfiguracja; 

    return $this; 
} 

/** 
* Remove samochodyKonfiguracja 
* 
* @param \Engineer\ConfiguratorBundle\Entity\SamochodyKonfiguracja $samochodyKonfiguracja 
*/ 
public function removeSamochodyKonfiguracja(\Engineer\ConfiguratorBundle\Entity\SamochodyKonfiguracja $samochodyKonfiguracja) 
{ 
    $this->samochodyKonfiguracja->removeElement($samochodyKonfiguracja); 
} 

/** 
* Get samochodyKonfiguracja 
* 
* @return \Doctrine\Common\Collections\Collection 
*/ 
public function getSamochodyKonfiguracja() 
{ 
    return $this->samochodyKonfiguracja; 
} 

/** 
* Add wersja 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Wersja $wersja 
* 
* @return Model 
*/ 
public function addWersja(\Engineer\ConfiguratorBundle\Entity\Wersja $wersja) 
{ 
    $this->wersja[] = $wersja; 

    return $this; 
} 

/** 
* Remove wersja 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Wersja $wersja 
*/ 
public function removeWersja(\Engineer\ConfiguratorBundle\Entity\Wersja $wersja) 
{ 
    $this->wersja->removeElement($wersja); 
} 

/** 
* Get wersja 
* 
* @return \Doctrine\Common\Collections\Collection 
*/ 
public function getWersja() 
{ 
    return $this->wersja; 
} 

}

Wersja.php:

<?php 

namespace Engineer\ConfiguratorBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 

/** 
* @ORM\Entity 
* @ORM\Table(name="wersja") 
* 
*/ 
class Wersja { 

/** 
* @ORM\Column(
*  type="integer", 
*  name="id_wersja" 
*) 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $idWersja; 


/** 
* @ORM\Column(type="string", 
*  length=20, 
*  unique=true 
*) 
* @Assert\Length(
*  max = 20 
*) 
*/ 
private $nazwa; 

/** 
* @ORM\Column(
*  type="decimal", 
*  precision=9, 
*  scale=2 
*) 
*/ 
private $cena; 

/** 
* @ORM\ManyToOne(
*  targetEntity="Model", 
*  inversedBy="wersja" 
* 
*) 
* @ORM\JoinColumn(
*  name="id_model", 
*  referencedColumnName="id_model", 
*  onDelete= "SET NULL" 
*) 
*/ 
private $model; 

/** 
* @ORM\OneToMany(
*  targetEntity="WyposazenieStandardowe", 
*  mappedBy="wersja" 
* ) 
*/ 
private $wyposazenieStandardowe; 



/** 
* Constructor 
*/ 
public function __construct() 
{ 
    $this->wyposazenieStandardowe = new \Doctrine\Common\Collections\ArrayCollection(); 
} 

/** 
* Get idWersja 
* 
* @return integer 
*/ 
public function getIdWersja() 
{ 
    return $this->idWersja; 
} 

/** 
* Set nazwa 
* 
* @param string $nazwa 
* 
* @return Wersja 
*/ 
public function setNazwa($nazwa) 
{ 
    $this->nazwa = $nazwa; 

    return $this; 
} 

/** 
* Get nazwa 
* 
* @return string 
*/ 
public function getNazwa() 
{ 
    return $this->nazwa; 
} 

/** 
* Set cena 
* 
* @param string $cena 
* 
* @return Wersja 
*/ 
public function setCena($cena) 
{ 
    $this->cena = $cena; 

    return $this; 
} 

/** 
* Get cena 
* 
* @return string 
*/ 
public function getCena() 
{ 
    return $this->cena; 
} 

/** 
* Set model 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Model $model 
* 
* @return Wersja 
*/ 
public function setModel(\Engineer\ConfiguratorBundle\Entity\Model $model = null) 
{ 
    $this->model = $model; 

    return $this; 
} 

/** 
* Get model 
* 
* @return \Engineer\ConfiguratorBundle\Entity\Model 
*/ 
public function getModel() 
{ 
    return $this->model; 
} 

/** 
* Add wyposazenieStandardowe 
* 
* @param \Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe $wyposazenieStandardowe 
* 
* @return Wersja 
*/ 
public function addWyposazenieStandardowe(\Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe $wyposazenieStandardowe) 
{ 
    $this->wyposazenieStandardowe[] = $wyposazenieStandardowe; 

    return $this; 
} 

/** 
* Remove wyposazenieStandardowe 
* 
* @param \Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe $wyposazenieStandardowe 
*/ 
public function removeWyposazenieStandardowe(\Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe $wyposazenieStandardowe) 
{ 
    $this->wyposazenieStandardowe->removeElement($wyposazenieStandardowe); 
} 

/** 
* Get wyposazenieStandardowe 
* 
* @return \Doctrine\Common\Collections\Collection 
*/ 
public function getWyposazenieStandardowe() 
{ 
    return $this->wyposazenieStandardowe; 
} 

}

WyposazenieStandardowe.php:

<?php 

namespace Engineer\ConfiguratorBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 

/** 
* @ORM\Entity 
* @ORM\Table(name="wyposazenie_standardowe") 
* 
*/ 
class WyposazenieStandardowe { 

/** 
* @ORM\Column(
*  type="integer", 
*  name="id_wyposazenie_standardowe" 
*) 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $idWyposazenieStandardowe; 

/** 
* @ORM\Column(type="string", 
*  length=45 
*) 
* @Assert\Length(
*  max = 45 
*) 
*/ 
private $nazwa; 

/** 
* @ORM\Column(
*  type="decimal", 
*  precision=9, 
*  scale=2 
*) 
*/ 
private $cena; 

/** 
* @ORM\ManyToOne(
*  targetEntity="Wersja", 
*  inversedBy="wyposazenieStandardowe" 
* 
*) 
* @ORM\JoinColumn(
*  name="id_wersja", 
*  referencedColumnName="id_wersja", 
*  onDelete= "SET NULL" 
*) 
*/ 
private $wersja; 

/** 
*@ORM\OneToMany(
*  targetEntity="Silnik", 
*  mappedBy="wyposazenieStandardowe" 
*) 
*/ 
private $silnik; 


/** 
* Constructor 
*/ 
public function __construct() 
{ 
    $this->silnik = new \Doctrine\Common\Collections\ArrayCollection(); 
} 

/** 
* Get idWyposazenie 
* 
* @return integer 
*/ 
public function getIdWyposazenie() 
{ 
    return $this->idWyposazenie; 
} 

/** 
* Set nazwaWyposazenia 
* 
* @param string $nazwaWyposazenia 
* 
* @return Wyposazenie 
*/ 
public function setNazwaWyposazenia($nazwaWyposazenia) 
{ 
    $this->nazwaWyposazenia = $nazwaWyposazenia; 

    return $this; 
} 

/** 
* Get nazwaWyposazenia 
* 
* @return string 
*/ 
public function getNazwaWyposazenia() 
{ 
    return $this->nazwaWyposazenia; 
} 

/** 
* Set cenaWyposazenia 
* 
* @param string $cenaWyposazenia 
* 
* @return Wyposazenie 
*/ 
public function setCenaWyposazenia($cenaWyposazenia) 
{ 
    $this->cenaWyposazenia = $cenaWyposazenia; 

    return $this; 
} 

/** 
* Get cenaWyposazenia 
* 
* @return string 
*/ 
public function getCenaWyposazenia() 
{ 
    return $this->cenaWyposazenia; 
} 

/** 
* Set wersja 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Wersja $wersja 
* 
* @return Wyposazenie 
*/ 
public function setWersja(\Engineer\ConfiguratorBundle\Entity\Wersja $wersja = null) 
{ 
    $this->wersja = $wersja; 

    return $this; 
} 

/** 
* Get wersja 
* 
* @return \Engineer\ConfiguratorBundle\Entity\Wersja 
*/ 
public function getWersja() 
{ 
    return $this->wersja; 
} 

/** 
* Add silnik 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Silnik $silnik 
* 
* @return Wyposazenie 
*/ 
public function addSilnik(\Engineer\ConfiguratorBundle\Entity\Silnik $silnik) 
{ 
    $this->silnik[] = $silnik; 

    return $this; 
} 

/** 
* Remove silnik 
* 
* @param \Engineer\ConfiguratorBundle\Entity\Silnik $silnik 
*/ 
public function removeSilnik(\Engineer\ConfiguratorBundle\Entity\Silnik $silnik) 
{ 
    $this->silnik->removeElement($silnik); 
} 

/** 
* Get silnik 
* 
* @return \Doctrine\Common\Collections\Collection 
*/ 
public function getSilnik() 
{ 
    return $this->silnik; 
} 

/** 
* Get idWyposazenieStandardowe 
* 
* @return integer 
*/ 
public function getIdWyposazenieStandardowe() 
{ 
    return $this->idWyposazenieStandardowe; 
} 

/** 
* Set nazwa 
* 
* @param string $nazwa 
* 
* @return WyposazenieStandardowe 
*/ 
public function setNazwa($nazwa) 
{ 
    $this->nazwa = $nazwa; 

    return $this; 
} 

/** 
* Get nazwa 
* 
* @return string 
*/ 
public function getNazwa() 
{ 
    return $this->nazwa; 
} 

/** 
* Set cena 
* 
* @param string $cena 
* 
* @return WyposazenieStandardowe 
*/ 
public function setCena($cena) 
{ 
    $this->cena = $cena; 

    return $this; 
} 

/** 
* Get cena 
* 
* @return string 
*/ 
public function getCena() 
{ 
    return $this->cena; 
} 

}

Silnik.php:

<?php 

namespace Engineer\ConfiguratorBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 

/** 
* @ORM\Entity 
* @ORM\Table(name="silnik") 
* 
*/ 
class Silnik { 

/** 
* @ORM\Column(
*  type="integer", 
*  name="id_silnik" 
* ) 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $idSilnik; 

/** 
* @ORM\Column(type="string", 
*  length=45, 
*  name="rodzaj_silnika" 
*) 
* @Assert\Length(
*  max = 45 
*) 
*/ 
private $rodzajSilnika; 

/** 
* @ORM\Column(
*  type="decimal", 
*  precision=9, 
*  scale=2 
*) 
*/ 
private $cena; 

/** 
* @ORM\Column(type="string", 
*  length=45, 
*  name="kM" 
*) 
* @Assert\Length(
*  max = 45 
*) 
*/ 
private $kM; 

/** 
* @ORM\Column(type="string", 
*  length=45, 
*  name="skrzynia_biegow" 
*) 
* @Assert\Length(
*  max = 45 
*) 
*/ 
private $skrzyniaBiegow; 

/** 
* @ORM\Column(type="string", 
*  length=45, 
*  name="rodzaj_napedu" 
*) 
* @Assert\Length(
*  max = 45 
*) 
*/ 
private $rodzajNapedu; 

/** 
* @ORM\ManyToOne(
*  targetEntity="WyposazenieStandardowe", 
*  inversedBy="silnik" 
* ) 
* 
* @ORM\JoinColumn(
*  name="id_wyposazenie_standardowe", 
*  referencedColumnName="id_wyposazenie_standardowe" 
*) 
*/ 
private $wyposazenieStandardowe; 



/** 
* Get idSilnik 
* 
* @return integer 
*/ 
public function getIdSilnik() 
{ 
    return $this->idSilnik; 
} 

/** 
* Set rodzajSilnika 
* 
* @param string $rodzajSilnika 
* 
* @return Silnik 
*/ 
public function setRodzajSilnika($rodzajSilnika) 
{ 
    $this->rodzajSilnika = $rodzajSilnika; 

    return $this; 
} 

/** 
* Get rodzajSilnika 
* 
* @return string 
*/ 
public function getRodzajSilnika() 
{ 
    return $this->rodzajSilnika; 
} 

/** 
* Set cena 
* 
* @param string $cena 
* 
* @return Silnik 
*/ 
public function setCena($cena) 
{ 
    $this->cena = $cena; 

    return $this; 
} 

/** 
* Get cena 
* 
* @return string 
*/ 
public function getCena() 
{ 
    return $this->cena; 
} 

/** 
* Set kM 
* 
* @param string $kM 
* 
* @return Silnik 
*/ 
public function setKM($kM) 
{ 
    $this->kM = $kM; 

    return $this; 
} 

/** 
* Get kM 
* 
* @return string 
*/ 
public function getKM() 
{ 
    return $this->kM; 
} 

/** 
* Set skrzyniaBiegow 
* 
* @param string $skrzyniaBiegow 
* 
* @return Silnik 
*/ 
public function setSkrzyniaBiegow($skrzyniaBiegow) 
{ 
    $this->skrzyniaBiegow = $skrzyniaBiegow; 

    return $this; 
} 

/** 
* Get skrzyniaBiegow 
* 
* @return string 
*/ 
public function getSkrzyniaBiegow() 
{ 
    return $this->skrzyniaBiegow; 
} 

/** 
* Set rodzajNapedu 
* 
* @param string $rodzajNapedu 
* 
* @return Silnik 
*/ 
public function setRodzajNapedu($rodzajNapedu) 
{ 
    $this->rodzajNapedu = $rodzajNapedu; 

    return $this; 
} 

/** 
* Get rodzajNapedu 
* 
* @return string 
*/ 
public function getRodzajNapedu() 
{ 
    return $this->rodzajNapedu; 
} 

/** 
* Set wyposazenieStandardowe 
* 
* @param \Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe $wyposazenieStandardowe 
* 
* @return Silnik 
*/ 
public function setWyposazenieStandardowe(\Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe $wyposazenieStandardowe = null) 
{ 
    $this->wyposazenieStandardowe = $wyposazenieStandardowe; 

    return $this; 
} 

/** 
* Get wyposazenieStandardowe 
* 
* @return \Engineer\ConfiguratorBundle\Entity\WyposazenieStandardowe 
*/ 
public function getWyposazenieStandardowe() 
{ 
    return $this->wyposazenieStandardowe; 
} 

}

+0

проверить ваш запрос sql, который не генерируется, не упоминается в таблице wyposazenie_dodatkowe, поэтому вы получаете сообщение об ошибке. –

+0

Моя ошибка в вопросе, это должно быть: Мне нужно отобразить всю информацию из 5 таблиц: samochody_konfiguracja, model, wersja, wyposazenie_standardowe, silnik. – piters3

ответ

0

Как вы пишете построитель запросов, конечный результат вывода должен быть преобразован в ваш объект доктрины.

Проверьте, есть ли у вас какая-либо ассоциация conf.model.wersja.wyposazenieStandardowe в вашей системе? Если да, попробуйте {{ dump(conf) }} в ветке, чтобы отладить, какие значения вы получите.

В этом случае не предполагайте, что проблема связана с веточкой. Если у вас нет связи и данных, Twig не может отображать данные.

Если вы нашли слишком много данных для загрузки в {{ dump() }} Возможно, вы захотите установить Xdebugger.

+0

Как я могу проверить, есть ли у меня ассоциация conf.model.wersja.wyposazenieStandardowe в моей системе? – piters3

+0

'{% if conf.model.wersja.wyposazenieStandardowe определено%}' – Jeet

+0

Я использовал его, и теперь я знаю, что у меня нет этой ассоциации. Как я могу это сделать? – piters3

 Смежные вопросы

  • Нет связанных вопросов^_^