"Missing value for primary key" - symfony

I'd just migrated to Symfony 3.4 and had this kind of message :
request.CRITICAL: Uncaught PHP Exception Doctrine\Common\Proxy\Exception\OutOfBoundsException: "Missing value for primary key idBen on Lea\PrestaBundle\Entity\EgwContact" at /htdocs/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/OutOfBoundsException.php line 40
Thanks in advance for your help
Here is my entity code for egw_contact :
<?php
namespace Lea\PrestaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Lea\PrestaBundle\Entity\EgwContact
*
* #ORM\Table(name="egw_contact")
* #ORM\Entity(repositoryClass="Lea\PrestaBundle\Entity\EgwContactRepository")
*/
class EgwContact
{
/**
* #var integer $idBen
*
* #ORM\Column(name="id_ben", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $idBen;
/**
* #var string $idOrganisation
*
* #ORM\Column(name="id_organisation", type="string", length=64, nullable=true)
*/
private $idOrganisation;
/**
* #var integer $idOwner
*
* #ORM\Column(name="id_owner", type="bigint", nullable=false)
*/
private $idOwner;
/**
* #var integer $dateCreation
*
* #ORM\Column(name="date_creation", type="bigint", nullable=false)
*/
private $dateCreation;
/**
* #var integer $idModifier
*
* #ORM\Column(name="id_modifier", type="bigint", nullable=false)
*/
private $idModifier;
/**
* #var integer $dateLastModified
*
* #ORM\Column(name="date_last_modified", type="bigint", nullable=false)
*/
private $dateLastModified;
/**
* #var string $catId
*
* #ORM\Column(name="cat_id", type="string", length=32, nullable=false)
*/
private $catId;
/**
* #var string $civilite
*
* #ORM\Column(name="civilite", type="string", length=64, nullable=false)
*/
private $civilite;
/**
* #var string $nomComplet
*
* #ORM\Column(name="nom_complet", type="string", length=64, nullable=false)
*/
private $nomComplet;
/**
* #var string $nom
*
* #ORM\Column(name="nom", type="string", length=64, nullable=false)
*/
private $nom;
/**
* #var string $prenom
*
* #ORM\Column(name="prenom", type="string", length=64, nullable=false)
*/
private $prenom;
/**
* #var string $deuxiemePrenom
*
* #ORM\Column(name="deuxieme_prenom", type="string", length=64, nullable=false)
*/
private $deuxiemePrenom;
/**
* #var string $nomJeuneFille
*
* #ORM\Column(name="nom_jeune_fille", type="string", length=64, nullable=false)
*/
private $nomJeuneFille;
/**
* #var string $organisation
*
* #ORM\Column(name="organisation", type="string", length=64, nullable=false)
*/
private $organisation;
/**
* #var string $fonction
*
* #ORM\Column(name="fonction", type="string", length=64, nullable=false)
*/
private $fonction;
/**
* #var string $service
*
* #ORM\Column(name="Service", type="string", length=64, nullable=false)
*/
private $service;
/**
* #var string $adresseLigne1
*
* #ORM\Column(name="adresse_ligne_1", type="string", length=64, nullable=false)
*/
private $adresseLigne1;
/**
* #var string $adresseLigne2
*
* #ORM\Column(name="adresse_ligne_2", type="string", length=64, nullable=false)
*/
private $adresseLigne2;
/**
* #var string $adresseLigne3
*
* #ORM\Column(name="adresse_ligne_3", type="string", length=64, nullable=false)
*/
private $adresseLigne3;
/**
* #var string $ville
*
* #ORM\Column(name="ville", type="string", length=64, nullable=false)
*/
private $ville;
/**
* #var string $region
*
* #ORM\Column(name="region", type="string", length=64, nullable=false)
*/
private $region;
/**
* #var string $cp
*
* #ORM\Column(name="cp", type="string", length=64, nullable=false)
*/
private $cp;
/**
* #var string $pays
*
* #ORM\Column(name="pays", type="string", length=64, nullable=false)
*/
private $pays;
/**
* #var string $telPro1
*
* #ORM\Column(name="tel_pro_1", type="string", length=40, nullable=false)
*/
private $telPro1;
/**
* #var string $telPro2
*
* #ORM\Column(name="tel_pro_2", type="string", length=64, nullable=false)
*/
private $telPro2;
/**
* #var string $telDomicile1
*
* #ORM\Column(name="tel_domicile_1", type="string", length=14, nullable=false)
*/
private $telDomicile1;
/**
* #var string $telDomicile2
*
* #ORM\Column(name="tel_domicile_2", type="string", length=64, nullable=false)
*/
private $telDomicile2;
/**
* #var string $faxPro
*
* #ORM\Column(name="fax_pro", type="string", length=40, nullable=false)
*/
private $faxPro;
/**
* #var string $faxPerso
*
* #ORM\Column(name="fax_perso", type="string", length=64, nullable=false)
*/
private $faxPerso;
/**
* #var string $portablePro
*
* #ORM\Column(name="portable_pro", type="string", length=64, nullable=false)
*/
private $portablePro;
/**
* #var string $portablePerso
*
* #ORM\Column(name="portable_perso", type="string", length=40, nullable=false)
*/
private $portablePerso;
/**
* #var string $emailPro
*
* #ORM\Column(name="email_pro", type="string", length=64, nullable=false)
*/
private $emailPro;
/**
* #var string $emailPerso
*
* #ORM\Column(name="email_perso", type="string", length=64, nullable=false)
*/
private $emailPerso;
/**
* #var string $sitePerso
*
* #ORM\Column(name="site_perso", type="string", length=64, nullable=false)
*/
private $sitePerso;
/**
* #var string $dateNaissance
*
* #ORM\Column(name="date_naissance", type="string", length=64, nullable=false)
*/
private $dateNaissance;
/**
* #var string $lieuNaissance
*
* #ORM\Column(name="lieu_naissance", type="string", length=64, nullable=false)
*/
private $lieuNaissance;
/**
* #var string $paysNaissance
*
* #ORM\Column(name="pays_naissance", type="string", length=64, nullable=false)
*/
private $paysNaissance;
/**
* #var string $nationalite
*
* #ORM\Column(name="nationalite", type="string", length=64, nullable=false)
*/
private $nationalite;
/**
* #var string $situationMaritale
*
* #ORM\Column(name="situation_maritale", type="string", length=64, nullable=false)
*/
private $situationMaritale;
/**
* #var integer $enfantsACharge
*
* #ORM\Column(name="enfants_a_charge", type="integer", nullable=false)
*/
private $enfantsACharge;
/**
* #var integer $idSecu
*
* #ORM\Column(name="numero_SS", type="string", nullable=false)
*/
private $idSecu;
/**
* #ORM\OneToMany(targetEntity="EgwCategories", mappedBy="contactCategorie")
*/
private $typeContact;
/**
* #ORM\OneToMany(targetEntity="Relance", mappedBy="contact")
*
*/
protected $relances;
/**
* #ORM\OneToMany(targetEntity="EgwProjet", mappedBy="contact")
*/
protected $projets;
/**
* #ORM\OneToMany(targetEntity="EgwPrestation", mappedBy="contact")
*/
protected $prestations;
/**
* #ORM\OneToMany(targetEntity="EgwPrestation", mappedBy="contactP")
*/
protected $prestationsP;
/**
* #ORM\OneToMany(targetEntity="EgwContactParcoursPro", mappedBy="parcoursProContact")
*/
protected $contactParcoursPro;
/**
* #ORM\OneToMany(targetEntity="EgwContactFormation", mappedBy="formationContact")
*/
protected $contactFormation;
public function __construct()
{
$this->prestations = new ArrayCollection();
$this->prestationsP = new ArrayCollection();
$this->contactParcoursPro = new ArrayCollection();
$this->contactFormation = new ArrayCollection();
$this->typeContact = new ArrayCollection();
$this->projets = new ArrayCollection();
}
/**
* Get idBen
*
* #return integer
*/
public function getIdBen()
{
return $this->idBen;
}
/**
* Set idOrganisation
*
* #param string $idOrganisation
* #return EgwContact
*/
public function setIdOrganisation($idOrganisation = null)
{
$this->idOrganisation = $idOrganisation;
return $this;
}
/**
* Get idOrganisation
*
* #return string
*/
public function getIdOrganisation()
{
return $this->idOrganisation;
}
/**
* Set idOwner
*
* #param integer $idOwner
* #return EgwContact
*/
public function setIdOwner($idOwner)
{
$this->idOwner = $idOwner;
return $this;
}
/**
* Get idOwner
*
* #return integer
*/
public function getIdOwner()
{
return $this->idOwner;
}
/**
* Set dateCreation
*
* #param integer $dateCreation
* #return EgwContact
*/
public function setDateCreation($dateCreation)
{
$this->dateCreation = $dateCreation;
return $this;
}
/**
* Get dateCreation
*
* #return integer
*/
public function getDateCreation()
{
return $this->dateCreation;
}
/**
* Set idModifier
*
* #param integer $idModifier
* #return EgwContact
*/
public function setIdModifier($idModifier)
{
$this->idModifier = $idModifier;
return $this;
}
/**
* Get idModifier
*
* #return integer
*/
public function getIdModifier()
{
return $this->idModifier;
}
/**
* Set dateLastModified
*
* #param integer $dateLastModified
* #return EgwContact
*/
public function setDateLastModified($dateLastModified)
{
$this->dateLastModified = $dateLastModified;
return $this;
}
/**
* Get dateLastModified
*
* #return integer
*/
public function getDateLastModified()
{
return $this->dateLastModified;
}
/**
* Set catId
*
* #param string $catId
* #return EgwContact
*/
public function setCatId($catId)
{
$this->catId = $catId;
return $this;
}
/**
* Get catId
*
* #return string
*/
public function getCatId()
{
return $this->catId;
}
/**
* Set civilite
*
* #param string $civilite
* #return EgwContact
*/
public function setCivilite($civilite)
{
$this->civilite = $civilite;
return $this;
}
/**
* Get civilite
*
* #return string
*/
public function getCivilite()
{
return $this->civilite;
}
/**
* Set nomComplet
*
* #param string $nomComplet
* #return EgwContact
*/
public function setNomComplet($nomComplet)
{
$this->nomComplet = $nomComplet;
return $this;
}
/**
* Get nomComplet
*
* #return string
*/
public function getNomComplet()
{
return $this->nomComplet;
}
/**
* Set nom
*
* #param string $nom
* #return EgwContact
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get nom
*
* #return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Set prenom
*
* #param string $prenom
* #return EgwContact
*/
public function setPrenom($prenom)
{
$this->prenom = $prenom;
return $this;
}
/**
* Get prenom
*
* #return string
*/
public function getPrenom()
{
return $this->prenom;
}
/**
* Set deuxiemePrenom
*
* #param string $deuxiemePrenom
* #return EgwContact
*/
public function setDeuxiemePrenom($deuxiemePrenom)
{
$this->deuxiemePrenom = $deuxiemePrenom;
return $this;
}
/**
* Get deuxiemePrenom
*
* #return string
*/
public function getDeuxiemePrenom()
{
return $this->deuxiemePrenom;
}
/**
* Set nomJeuneFille
*
* #param string $nomJeuneFille
* #return EgwContact
*/
public function setNomJeuneFille($nomJeuneFille)
{
$this->nomJeuneFille = $nomJeuneFille;
return $this;
}
/**
* Get nomJeuneFille
*
* #return string
*/
public function getNomJeuneFille()
{
return $this->nomJeuneFille;
}
/**
* Set organisation
*
* #param string $organisation
* #return EgwContact
*/
public function setOrganisation($organisation)
{
$this->organisation = $organisation;
return $this;
}
/**
* Get organisation
*
* #return string
*/
public function getOrganisation()
{
return $this->organisation;
}
/**
* Set fonction
*
* #param string $fonction
* #return EgwContact
*/
public function setFonction($fonction)
{
$this->fonction = $fonction;
return $this;
}
/**
* Get fonction
*
* #return string
*/
public function getFonction()
{
return $this->fonction;
}
/**
* Set service
*
* #param string $service
* #return EgwContact
*/
public function setService($service)
{
$this->service = $service;
return $this;
}
/**
* Get service
*
* #return string
*/
public function getService()
{
return $this->service;
}
/**
* Set adresseLigne1
*
* #param string $adresseLigne1
* #return EgwContact
*/
public function setAdresseLigne1($adresseLigne1)
{
$this->adresseLigne1 = $adresseLigne1;
return $this;
}
/**
* Get adresseLigne1
*
* #return string
*/
public function getAdresseLigne1()
{
return $this->adresseLigne1;
}
/**
* Set adresseLigne2
*
* #param string $adresseLigne2
* #return EgwContact
*/
public function setAdresseLigne2($adresseLigne2)
{
$this->adresseLigne2 = $adresseLigne2;
return $this;
}
/**
* Get adresseLigne2
*
* #return string
*/
public function getAdresseLigne2()
{
return $this->adresseLigne2;
}
/**
* Set adresseLigne3
*
* #param string $adresseLigne3
* #return EgwContact
*/
public function setAdresseLigne3($adresseLigne3)
{
$this->adresseLigne3 = $adresseLigne3;
return $this;
}
/**
* Get adresseLigne3
*
* #return string
*/
public function getAdresseLigne3()
{
return $this->adresseLigne3;
}
/**
* Set ville
*
* #param string $ville
* #return EgwContact
*/
public function setVille($ville)
{
$this->ville = $ville;
return $this;
}
/**
* Get ville
*
* #return string
*/
public function getVille()
{
return $this->ville;
}
/**
* Set region
*
* #param string $region
* #return EgwContact
*/
public function setRegion($region)
{
$this->region = $region;
return $this;
}
/**
* Get region
*
* #return string
*/
public function getRegion()
{
return $this->region;
}
/**
* Set cp
*
* #param string $cp
* #return EgwContact
*/
public function setCp($cp)
{
$this->cp = $cp;
return $this;
}
/**
* Get cp
*
* #return string
*/
public function getCp()
{
return $this->cp;
}
/**
* Set pays
*
* #param string $pays
* #return EgwContact
*/
public function setPays($pays)
{
$this->pays = $pays;
return $this;
}
/**
* Get pays
*
* #return string
*/
public function getPays()
{
return $this->pays;
}
/**
* Set telPro1
*
* #param string $telPro1
* #return EgwContact
*/
public function setTelPro1($telPro1)
{
$this->telPro1 = $telPro1;
return $this;
}
/**
* Get telPro1
*
* #return string
*/
public function getTelPro1()
{
return $this->telPro1;
}
/**
* Set telPro2
*
* #param string $telPro2
* #return EgwContact
*/
public function setTelPro2($telPro2)
{
$this->telPro2 = $telPro2;
return $this;
}
/**
* Get telPro2
*
* #return string
*/
public function getTelPro2()
{
return $this->telPro2;
}
/**
* Set telDomicile1
*
* #param string $telDomicile1
* #return EgwContact
*/
public function setTelDomicile1($telDomicile1)
{
$this->telDomicile1 = $telDomicile1;
return $this;
}
/**
* Get telDomicile1
*
* #return string
*/
public function getTelDomicile1()
{
return $this->telDomicile1;
}
/**
* Set telDomicile2
*
* #param string $telDomicile2
* #return EgwContact
*/
public function setTelDomicile2($telDomicile2)
{
$this->telDomicile2 = $telDomicile2;
return $this;
}
/**
* Get telDomicile2
*
* #return string
*/
public function getTelDomicile2()
{
return $this->telDomicile2;
}
/**
* Set faxPro
*
* #param string $faxPro
* #return EgwContact
*/
public function setFaxPro($faxPro)
{
$this->faxPro = $faxPro;
return $this;
}
/**
* Get faxPro
*
* #return string
*/
public function getFaxPro()
{
return $this->faxPro;
}
/**
* Set faxPerso
*
* #param string $faxPerso
* #return EgwContact
*/
public function setFaxPerso($faxPerso)
{
$this->faxPerso = $faxPerso;
return $this;
}
/**
* Get faxPerso
*
* #return string
*/
public function getFaxPerso()
{
return $this->faxPerso;
}
/**
* Set portablePro
*
* #param string $portablePro
* #return EgwContact
*/
public function setPortablePro($portablePro)
{
$this->portablePro = $portablePro;
return $this;
}
/**
* Get portablePro
*
* #return string
*/
public function getPortablePro()
{
return $this->portablePro;
}
/**
* Set portablePerso
*
* #param string $portablePerso
* #return EgwContact
*/
public function setPortablePerso($portablePerso)
{
$this->portablePerso = $portablePerso;
return $this;
}
/**
* Get portablePerso
*
* #return string
*/
public function getPortablePerso()
{
return $this->portablePerso;
}
/**
* Set emailPro
*
* #param string $emailPro
* #return EgwContact
*/
public function setEmailPro($emailPro)
{
$this->emailPro = $emailPro;
return $this;
}
/**
* Get emailPro
*
* #return string
*/
public function getEmailPro()
{
return $this->emailPro;
}
/**
* Set emailPerso
*
* #param string $emailPerso
* #return EgwContact
*/
public function setEmailPerso($emailPerso)
{
$this->emailPerso = $emailPerso;
return $this;
}
/**
* Get emailPerso
*
* #return string
*/
public function getEmailPerso()
{
return $this->emailPerso;
}
/**
* Set sitePerso
*
* #param string $sitePerso
* #return EgwContact
*/
public function setSitePerso($sitePerso)
{
$this->sitePerso = $sitePerso;
return $this;
}
/**
* Get sitePerso
*
* #return string
*/
public function getSitePerso()
{
return $this->sitePerso;
}
/**
* Set dateNaissance
*
* #param string $dateNaissance
* #return EgwContact
*/
public function setDateNaissance($dateNaissance)
{
$this->dateNaissance = $dateNaissance;
return $this;
}
/**
* Get dateNaissance
*
* #return string
*/
public function getDateNaissance()
{
return $this->dateNaissance;
}
/**
* Set lieuNaissance
*
* #param string $lieuNaissance
* #return EgwContact
*/
public function setLieuNaissance($lieuNaissance)
{
$this->lieuNaissance = $lieuNaissance;
return $this;
}
/**
* Get lieuNaissance
*
* #return string
*/
public function getLieuNaissance()
{
return $this->lieuNaissance;
}
/**
* Set paysNaissance
*
* #param string $paysNaissance
* #return EgwContact
*/
public function setPaysNaissance($paysNaissance)
{
$this->paysNaissance = $paysNaissance;
return $this;
}
/**
* Get paysNaissance
*
* #return string
*/
public function getPaysNaissance()
{
return $this->paysNaissance;
}
/**
* Set nationalite
*
* #param string $nationalite
* #return EgwContact
*/
public function setNationalite($nationalite)
{
$this->nationalite = $nationalite;
return $this;
}
/**
* Get nationalite
*
* #return string
*/
public function getNationalite()
{
return $this->nationalite;
}
/**
* Set situationMaritale
*
* #param string $situationMaritale
* #return EgwContact
*/
public function setSituationMaritale($situationMaritale)
{
$this->situationMaritale = $situationMaritale;
return $this;
}
/**
* Get situationMaritale
*
* #return string
*/
public function getSituationMaritale()
{
return $this->situationMaritale;
}
/**
* Set enfantsACharge
*
* #param integer $enfantsACharge
* #return EgwContact
*/
public function setEnfantsACharge($enfantsACharge)
{
$this->enfantsACharge = $enfantsACharge;
return $this;
}
/**
* Get enfantsACharge
*
* #return integer
*/
public function getEnfantsACharge()
{
return $this->enfantsACharge;
}
/**
* Set idSecu
*
* #param integer $idSecu
* #return EgwContact
*/
public function setIdSecu($idSecu)
{
$this->idSecu = $idSecu;
return $this;
}
/**
* Get idSecu
*
* #return string
*/
public function getidSecu()
{
return $this->idSecu;
}
/**
* Add typeContact
*
* #param Lea\PrestaBundle\Entity\EgwContact $typeContact
* #return EgwContact
etc...
...
}

I FOUND ! in a Form calling the entity Ewg_contact linked to the entity Ewg_Categories, there was a hard parameter called: I replaced it with a variable. And it works.
This is by looking at the getProxy () function of the Doctrine class AbstractProxyFactory.php: there is an exception that calls the OutOfBoundsException :: missingPrimaryKeyValue function in which there is the message "
Missing value for primary key
Here is the correction made to the Form in question:
$param287=287;
$builder->add('categorie', EntityType::class, array(
'class' => 'LeaPrestaBundle:EgwCategories',
'label' => 'catName',
'required' => true,
'empty_data' => null,
'query_builder' => function(EntityRepository $er)
{
return $er->createQueryBuilder('c')
->where('c.catParent = :parent')
->setParameter('parent',$param287 )
->orderBy('c.catName','ASC');
},
));
EXPLANATION : Before it was :
->setParameter('parent', 287 )
witch provocated an exception in the getproxy function of AbstractProxyFactory.php class
Correct now
Thanks for your messages

i have the same problem. I found a possible "solution" in Doctrine Documentation. This one maybe can help.
i see in Documentation it's not possible to use not-primary key for joins columns.
Your column id_ben is a primary key ?
It is not possible to use join columns pointing to non-primary keys. Doctrine will think these are the primary keys and create lazy-loading proxies with the data, which can lead to unexpected results. Doctrine can for performance reasons not validate the correctness of this settings at runtime but only through the Validate Schema command.

It's probably a problem between 2 entities 👍
The link between entities egw_accounts and egw_addressbook is : ACCOUNT_ID
In the database, about the field ACCOUNT_ID there are exactly the same values in entities egw_accounts and egw_addressbook 👍
egw_accounts->ACCOUNT_ID = egw_addressbook->ACCOUNT_ID
SO, perhaps it's in the definition of entities that there's a problem
Remember that, i didnt have the problem in SYMFONY 2 : but in SYMFONY 3.4, the problem appears
THANKS for your help!
ENTITY EGW_ACCOUNTS 👍
class EgwAccounts { /** * #var integer $accountId * * #ORM\Id * #ORM\GeneratedValue(strategy="IDENTITY") * #ORM\OneToOne(targetEntity="EgwAddressbook", cascade={"persist", "merge", "remove"}) * #ORM\JoinColumn(name="account_id", referencedColumnName="account_id") */ private $accountId;
With the SETTER :
`
/**
* Set accountId
*
* #param Lea\PrestaBundle\Entity\EgwAddressbook $accountId
* #return EgwAccounts
*/
public function setAccountId(\Lea\PrestaBundle\Entity\EgwAddressbook $accountId)
{
$this->accountId = $accountId;
return $this;
}`
THE ENTITY EGW_ADDRESSBOOK 👍
/** * #var integer $accountId * #ORM\Column(name="account_id", type="integer", nullable=true) */ private $accountId;

Related

The mappings and are inconsistent with each other?

Query Warning message from Symfony Profiler:
Klient Entity
The mappings AdminBundle\Entity\Klient#contacts and
AdminBundle\Entity\KlientContact#fkKlient
are inconsistent with each other.
KlientContact Entity
The association AdminBundle\Entity\KlientContact#fkKlient refers to
the inverse side field AdminBundle\Entity\Klient#nip which is not
defined as association. The association
AdminBundle\Entity\KlientContact#fkKlient refers to the inverse side
field AdminBundle\Entity\Klient#nip which does not exist.
What did I do wrong ? I assume that there is something that I am missing on Klient#nip (which is mapped as Id field)
[Klient Entity]
<?php
namespace AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AdminBundle\Entity\KlientContact;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Klient
*
* #ORM\Table(name="klient")
* #ORM\Entity(repositoryClass="AdminBundle\Repository\KlientRepository")
* #ORM\HasLifecycleCallbacks
*/
class Klient
{
public function __construct()
{
$this->contacts = new ArrayCollection();
}
public function __toString() {
return "NIP: ".$this->nip .", NAZWA: ". $this->name .", TEL: ". $this->tel;
}
/**
* #var string
* #ORM\Id
* #ORM\Column(name="nip", type="string", length=255)
*
*/
private $nip;
/**
* #var string
*
* #ORM\Column(name="regon", type="string", length=255)
*/
private $regon;
/**
* #var \DateTime
* #ORM\Column(name="inserted_at", type="datetime", nullable=true)
*/
private $insertedAt;
/**
* #var \DateTime
* #ORM\Column(name="last_edited_at", type="datetime", nullable=true)
*/
private $lastEditedAt;
/**
* #var string
*
* #ORM\Column(name="krs", type="string", length=255)
*/
private $krs;
/**
* #var string
*
* #ORM\Column(name="address", type="string", length=255)
*/
private $address;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="tel", type="string", length=255, nullable=true)
*/
private $tel;
/**
* #var string
*
* #ORM\Column(name="email", type="string", length=255, nullable=true)
*/
private $email;
/**
* #var type
*
* #ORM\OneToMany(targetEntity="KlientContact", mappedBy="fkKlient")
*/
private $contacts; // optional properyty holds an array of contact objects - this is not a fild in database
/**
* Set nip
*
* #param string $nip
*
* #return Klient
*/
public function setNip($nip)
{
$this->nip = $nip;
return $this;
}
/**
* Get nip
*
* #return string
*/
public function getNip()
{
return $this->nip;
}
/**
* Set regon
*
* #param string $regon
*
* #return Klient
*/
public function setRegon($regon)
{
$this->regon = $regon;
return $this;
}
/**
* Get regon
*
* #return string
*/
public function getRegon()
{
return $this->regon;
}
/**
* Set krs
*
* #param string $krs
*
* #return Klient
*/
public function setKrs($krs)
{
$this->krs = $krs;
return $this;
}
/**
* Get krs
*
* #return string
*/
public function getKrs()
{
return $this->krs;
}
/**
* Set address
*
* #param string $address
*
* #return Klient
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* #return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set name
*
* #param string $name
*
* #return Klient
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set tel
*
* #param string $tel
*
* #return Klient
*/
public function setTel($tel)
{
$this->tel = $tel;
return $this;
}
/**
* Get tel
*
* #return string
*/
public function getTel()
{
return $this->tel;
}
/**
* Set email
*
* #param string $email
*
* #return Klient
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* #return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Add contact
*
* #param \AdminBundle\Entity\KlientContact $contact
*
* #return Klient
*/
public function addContact(\AdminBundle\Entity\KlientContact $contact)
{
$this->contacts[] = $contact;
return $this;
}
/**
* Remove contact
*
* #param \AdminBundle\Entity\KlientContact $contact
*/
public function removeContact(\AdminBundle\Entity\KlientContact $contact)
{
$this->contacts->removeElement($contact);
}
/**
* Get contacts
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getContacts()
{
return $this->contacts;
}
/**
* Set insertedAt
*
* #param \DateTime $insertedAt
*
* #return Klient
*/
public function setInsertedAt(\DateTime $insertedAt)
{
$this->insertedAt = $insertedAt;
return $this;
}
/**
* Get insertedAt
*
* #return \DateTime
*/
public function getInsertedAt()
{
return $this->insertedAt;
}
/**
* Set lastEditedAt
*
* #param \DateTime $lastEditedAt
*
* #return Klient
*/
public function setLastEditedAt(\DateTime $lastEditedAt)
{
$this->lastEditedAt = $lastEditedAt;
return $this;
}
/**
* Get lastEditedAt
*
* #return \DateTime
*/
public function getLastEditedAt()
{
return $this->lastEditedAt;
}
/**
*
* #ORM\PrePersist
* #ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setLastEditedAt(new \DateTime('now'));
if ($this->getInsertedAt() == null) {
$this->setInsertedAt(new \DateTime('now'));
}
}
}
[KlientContact Entity]
<?php
namespace AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AdminBundle\Entity\Klient;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* KlientContact
*
* #ORM\Table(name="klient_contact")
* #ORM\Entity(repositoryClass="AdminBundle\Repository\KlientContactRepository")
* #ORM\HasLifecycleCallbacks
*/
class KlientContact implements UserInterface
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var \DateTime
*
* #ORM\Column(name="inserted_at", type="datetime", nullable=true)
*/
private $insertedAt;
/**
* #var \DateTime
*
* #ORM\Column(name="last_edited_at", type="datetime", nullable=true)
*/
private $lastEditedAt;
/**
* #ORM\ManyToOne(targetEntity="Klient", inversedBy="nip")
* #ORM\JoinColumn(name="fk_klient", referencedColumnName="nip")
*/
private $fkKlient;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="surname", type="string", length=255)
*/
private $surname;
/**
* #var string
*
* #ORM\Column(name="email", type="string", length=255)
*/
private $email;
/**
* #var string
*
* #ORM\Column(name="phone", type="string", length=255)
*/
private $phone;
/**
* #var string
*
* #ORM\Column(name="login", type="string", length=255, unique=true)
*/
private $login;
/**
* #var string
*
* #ORM\Column(name="password", type="text")
*/
private $password;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
*
* #return KlientContact
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set surname
*
* #param string $surname
*
* #return KlientContact
*/
public function setSurname($surname)
{
$this->surname = $surname;
return $this;
}
/**
* Get surname
*
* #return string
*/
public function getSurname()
{
return $this->surname;
}
/**
* Set email
*
* #param string $email
*
* #return KlientContact
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* #return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set phone
*
* #param string $phone
*
* #return KlientContact
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Get phone
*
* #return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* Set login
*
* #param string $login
*
* #return KlientContact
*/
public function setLogin($login)
{
$this->login = $login;
return $this;
}
/**
* Get login
*
* #return string
*/
public function getLogin()
{
return $this->login;
}
/**
* Set password
*
* #param string $password
*
* #return KlientContact
*/
public function setPassword($password)
{
$hash = password_hash($password, PASSWORD_BCRYPT , ['cost' => 5]);
$this->password = $hash;
return $this;
}
/**
* Get password
*
* #return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set fkKlient
*
* #param \AdminBundle\Entity\Klient $fkKlient
*
* #return KlientContact
*/
public function setFkKlient(\AdminBundle\Entity\Klient $fkKlient = null)
{
$this->fkKlient = $fkKlient;
return $this;
}
/**
* Get fkKlient
*
* #return \AdminBundle\Entity\Klient
*/
public function getFkKlient()
{
return $this->fkKlient;
}
public function eraseCredentials() {
}
public function getRoles() {
return ['ROLE_USER'];
}
public function getSalt() {
return null;
}
public function getUsername() {
}
/**
* Set insertedAt
*
* #param \DateTime $insertedAt
*
* #return KlientContact
*/
public function setInsertedAt(\DateTime $insertedAt)
{
$this->insertedAt = $insertedAt;
return $this;
}
/**
* Get insertedAt
*
* #return \DateTime
*/
public function getInsertedAt()
{
return $this->insertedAt;
}
/**
* Set lastEditedAt
*
* #param \DateTime $lastEditedAt
*
* #return KlientContact
*/
public function setLastEditedAt(\DateTime $lastEditedAt)
{
$this->lastEditedAt = $lastEditedAt;
return $this;
}
/**
* Get lastEditedAt
*
* #return \DateTime
*/
public function getLastEditedAt()
{
return $this->lastEditedAt;
}
/**
*
* #ORM\PrePersist
* #ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setLastEditedAt(new \DateTime('now'));
if ($this->getInsertedAt() == null) {
$this->setInsertedAt(new \DateTime('now'));
}
}
}
The inverse side is wrong. Should be:
[KlientContact Entity]
/**
* #ORM\ManyToOne(targetEntity="Klient", inversedBy="contacts")
* #ORM\JoinColumn(name="fk_klient", referencedColumnName="nip")
*/
private $fkKlient;

Doctrine only returns a single result from database even though it should return multple records

I have a strange problem with a query in my Symfony2 project.
I have the following query:
$enviroFigures = $dm->createQuery('
SELECT efu.wasteType, efu.ewcCode, SUM(efu.totalUom) AS totalTonne, SUM(efu.co2Saving) AS totalCO2
FROM CoreBundle:EnviroFiguresUpload efu
WHERE efu.customerSite = :site
AND efu.completionDate BETWEEN :start AND :end
AND efu.completionDate != :blank
AND efu.totalUom != :zero
AND efu.wasteType != :blank
ORDER BY efu.completionDate DESC'
)->setParameters(array(
'site' => $cs,
'start' => $ds,
'end' => $de,
'blank' => '',
'zero' => '0'
));
$enviFig = $enviroFigures->getResult();
And with the test data I have, there are two records this query should return from the database. I've even used this SQL query to test the general query, and it has returned two rows of data as expected.
SELECT waste_type AS wasteType, ewc_code AS ewcCode, SUM(total_uom) AS totalTonne, SUM(co2_saving) AS totalCO2
FROM `enviro_figures_upload
WHERE customer_site = 'A Customer'
AND completion_date BETWEEN '2014-01-01' AND '2015-01-15'
AND completion_date != ''
AND total_uom != ''
AND waste_type != ''
GROUP BY waste_type
ORDER BY completion_date DESC
This is the output
wasteType ewcCode totalTonne totalCO2
Dry Mixed Recycling 20 03 01 20 2
Confidential Paper Shred service 20 01 01 75 0.84
However, inside the Symfony2 application only one result is returned:
wasteType ewcCode totalTonne totalCO2
Confidential Paper Shred service 20 01 01 75 0.84
I have also used a native SQL query inside Symfony2 but that returns the same result. Even removing any parameter to search with returns the one record (even though using this method, it should have displayed 100 records).
Here is the Entity file for the table in question:
<?php
namespace CWWA\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* EnviroFiguresUpload
*
* #ORM\Table(name="enviro_figures_upload")
* #ORM\Entity
*/
class EnviroFiguresUpload
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="account_number", type="integer", nullable=false)
*/
private $accountNumber;
/**
* #var integer
*
* #ORM\Column(name="customer_reference", type="integer", nullable=false)
*/
private $customerReference;
/**
* #var string
*
* #ORM\Column(name="billing_customer", type="string", length=500, nullable=false)
*/
private $billingCustomer;
/**
* #var string
*
* #ORM\Column(name="division", type="string", length=500, nullable=false)
*/
private $division;
/**
* #var string
*
* #ORM\Column(name="customer_site", type="string", length=500, nullable=false)
*/
private $customerSite;
/**
* #var string
*
* #ORM\Column(name="town", type="string", length=500, nullable=false)
*/
private $town;
/**
* #var string
*
* #ORM\Column(name="postcode", type="string", length=12, nullable=false)
*/
private $postcode;
/**
* #var integer
*
* #ORM\Column(name="job_number", type="integer", nullable=false)
*/
private $jobNumber;
/**
* #var string
*
* #ORM\Column(name="job_status", type="string", length=50, nullable=false)
*/
private $jobStatus;
/**
* #var string
*
* #ORM\Column(name="job_type", type="string", length=50, nullable=false)
*/
private $jobType;
/**
* #var string
*
* #ORM\Column(name="completion_date", type="string", length=45, nullable=false)
*/
private $completionDate;
/**
* #var string
*
* #ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* #var string
*
* #ORM\Column(name="waste_type", type="string", length=100, nullable=true)
*/
private $wasteType;
/**
* #var string
*
* #ORM\Column(name="ewc_code", type="string", length=12, nullable=true)
*/
private $ewcCode;
/**
* #var string
*
* #ORM\Column(name="container", type="string", length=50, nullable=true)
*/
private $container;
/**
* #var integer
*
* #ORM\Column(name="quantity", type="integer", nullable=true)
*/
private $quantity;
/**
* #var string
*
* #ORM\Column(name="total_uom", type="string", length=45, nullable=true)
*/
private $totalUom;
/**
* #var string
*
* #ORM\Column(name="co2_saving", type="string", length=45, nullable=true)
*/
private $co2Saving;
/**
* #var string
*
* #ORM\Column(name="total_resource", type="string", length=45, nullable=true)
*/
private $totalResource;
/**
* #var string
*
* #ORM\Column(name="total_co2_saving", type="string", length=45, nullable=true)
*/
private $totalCo2Saving;
/**
* #var string
*
* #ORM\Column(name="recovery_rate", type="string", length=45, nullable=true)
*/
private $recoveryRate;
/**
* #var string
*
* #ORM\Column(name="disposal_method", type="string", length=120, nullable=true)
*/
private $disposalMethod;
/**
* #var string
*
* #ORM\Column(name="waste_hierarchy", type="string", length=120, nullable=true)
*/
private $wasteHierarchy;
/**
* #var string
*
* #ORM\Column(name="customer_order_date", type="string", length=45, nullable=true)
*/
private $customerOrderDate;
/**
* #var string
*
* #ORM\Column(name="job_notes", type="text", nullable=true)
*/
private $jobNotes;
/**
* #var string
*
* #ORM\Column(name="customer_ref_po", type="text", nullable=true)
*/
private $customerRefPo;
/**
* #var \Date
*
* #ORM\Column(name="uploaded", type="date", nullable=false)
*/
private $uploaded;
/**
* #var boolean
*
* #ORM\Column(name="processed", type="boolean", nullable=false)
*/
private $processed;
/**
* #var boolean
*
* #ORM\Column(name="deleted", type="boolean", nullable=false)
*/
private $deleted;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set accountNumber
*
* #param integer $accountNumber
* #return EnviroFiguresUpload
*/
public function setAccountNumber($accountNumber)
{
$this->accountNumber = $accountNumber;
return $this;
}
/**
* Get accountNumber
*
* #return integer
*/
public function getAccountNumber()
{
return $this->accountNumber;
}
/**
* Set customerReference
*
* #param integer $customerReference
* #return EnviroFiguresUpload
*/
public function setCustomerReference($customerReference)
{
$this->customerReference = $customerReference;
return $this;
}
/**
* Get customerReference
*
* #return integer
*/
public function getCustomerReference()
{
return $this->customerReference;
}
/**
* Set billingCustomer
*
* #param string $billingCustomer
* #return EnviroFiguresUpload
*/
public function setBillingCustomer($billingCustomer)
{
$this->billingCustomer = $billingCustomer;
return $this;
}
/**
* Get billingCustomer
*
* #return string
*/
public function getBillingCustomer()
{
return $this->billingCustomer;
}
/**
* Set division
*
* #param string $division
* #return EnviroFiguresUpload
*/
public function setDivision($division)
{
$this->division = $division;
return $this;
}
/**
* Get division
*
* #return string
*/
public function getDivision()
{
return $this->division;
}
/**
* Set customerSite
*
* #param string $customerSite
* #return EnviroFiguresUpload
*/
public function setCustomerSite($customerSite)
{
$this->customerSite = $customerSite;
return $this;
}
/**
* Get customerSite
*
* #return string
*/
public function getCustomerSite()
{
return $this->customerSite;
}
/**
* Set town
*
* #param string $town
* #return EnviroFiguresUpload
*/
public function setTown($town)
{
$this->town = $town;
return $this;
}
/**
* Get town
*
* #return string
*/
public function getTown()
{
return $this->town;
}
/**
* Set postcode
*
* #param string $postcode
* #return EnviroFiguresUpload
*/
public function setPostcode($postcode)
{
$this->postcode = $postcode;
return $this;
}
/**
* Get postcode
*
* #return string
*/
public function getPostcode()
{
return $this->postcode;
}
/**
* Set jobNumber
*
* #param integer $jobNumber
* #return EnviroFiguresUpload
*/
public function setJobNumber($jobNumber)
{
$this->jobNumber = $jobNumber;
return $this;
}
/**
* Get jobNumber
*
* #return integer
*/
public function getJobNumber()
{
return $this->jobNumber;
}
/**
* Set jobStatus
*
* #param string $jobStatus
* #return EnviroFiguresUpload
*/
public function setJobStatus($jobStatus)
{
$this->jobStatus = $jobStatus;
return $this;
}
/**
* Get jobStatus
*
* #return string
*/
public function getJobStatus()
{
return $this->jobStatus;
}
/**
* Set jobType
*
* #param string $jobType
* #return EnviroFiguresUpload
*/
public function setJobType($jobType)
{
$this->jobType = $jobType;
return $this;
}
/**
* Get jobType
*
* #return string
*/
public function getJobType()
{
return $this->jobType;
}
/**
* Set completionDate
*
* #param string $completionDate
* #return EnviroFiguresUpload
*/
public function setCompletionDate($completionDate)
{
$this->completionDate = $completionDate;
return $this;
}
/**
* Get completionDate
*
* #return string
*/
public function getCompletionDate()
{
return $this->completionDate;
}
/**
* Set description
*
* #param string $description
* #return EnviroFiguresUpload
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set wasteType
*
* #param string $wasteType
* #return EnviroFiguresUpload
*/
public function setWasteType($wasteType)
{
$this->wasteType = $wasteType;
return $this;
}
/**
* Get wasteType
*
* #return string
*/
public function getWasteType()
{
return $this->wasteType;
}
/**
* Set ewcCode
*
* #param string $ewcCode
* #return EnviroFiguresUpload
*/
public function setEwcCode($ewcCode)
{
$this->ewcCode = $ewcCode;
return $this;
}
/**
* Get ewcCode
*
* #return string
*/
public function getEwcCode()
{
return $this->ewcCode;
}
/**
* Set container
*
* #param string $container
* #return EnviroFiguresUpload
*/
public function setContainer($container)
{
$this->container = $container;
return $this;
}
/**
* Get container
*
* #return string
*/
public function getContainer()
{
return $this->container;
}
/**
* Set quantity
*
* #param integer $quantity
* #return EnviroFiguresUpload
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* Get quantity
*
* #return integer
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* Set totalUom
*
* #param string $totalUom
* #return EnviroFiguresUpload
*/
public function setTotalUom($totalUom)
{
$this->totalUom = $totalUom;
return $this;
}
/**
* Get totalUom
*
* #return string
*/
public function getTotalUom()
{
return $this->totalUom;
}
/**
* Set co2Saving
*
* #param string $co2Saving
* #return EnviroFiguresUpload
*/
public function setCo2Saving($co2Saving)
{
$this->co2Saving = $co2Saving;
return $this;
}
/**
* Get co2Saving
*
* #return string
*/
public function getCo2Saving()
{
return $this->co2Saving;
}
/**
* Set totalResource
*
* #param string $totalResource
* #return EnviroFiguresUpload
*/
public function setTotalResource($totalResource)
{
$this->totalResource = $totalResource;
return $this;
}
/**
* Get totalResource
*
* #return string
*/
public function getTotalResource()
{
return $this->totalResource;
}
/**
* Set totalCo2Saving
*
* #param string $totalCo2Saving
* #return EnviroFiguresUpload
*/
public function setTotalCo2Saving($totalCo2Saving)
{
$this->totalCo2Saving = $totalCo2Saving;
return $this;
}
/**
* Get totalCo2Saving
*
* #return string
*/
public function getTotalCo2Saving()
{
return $this->totalCo2Saving;
}
/**
* Set recoveryRate
*
* #param string $recoveryRate
* #return EnviroFiguresUpload
*/
public function setRecoveryRate($recoveryRate)
{
$this->recoveryRate = $recoveryRate;
return $this;
}
/**
* Get recoveryRate
*
* #return string
*/
public function getRecoveryRate()
{
return $this->recoveryRate;
}
/**
* Set disposalMethod
*
* #param string $disposalMethod
* #return EnviroFiguresUpload
*/
public function setDisposalMethod($disposalMethod)
{
$this->disposalMethod = $disposalMethod;
return $this;
}
/**
* Get disposalMethod
*
* #return string
*/
public function getDisposalMethod()
{
return $this->disposalMethod;
}
/**
* Set wasteHierarchy
*
* #param string $wasteHierarchy
* #return EnviroFiguresUpload
*/
public function setWasteHierarchy($wasteHierarchy)
{
$this->wasteHierarchy = $wasteHierarchy;
return $this;
}
/**
* Get wasteHierarchy
*
* #return string
*/
public function getWasteHierarchy()
{
return $this->wasteHierarchy;
}
/**
* Set customerOrderDate
*
* #param string $customerOrderDate
* #return EnviroFiguresUpload
*/
public function setCustomerOrderDate($customerOrderDate)
{
$this->customerOrderDate = $customerOrderDate;
return $this;
}
/**
* Get customerOrderDate
*
* #return string
*/
public function getCustomerOrderDate()
{
return $this->customerOrderDate;
}
/**
* Set jobNotes
*
* #param string $jobNotes
* #return EnviroFiguresUpload
*/
public function setJobNotes($jobNotes)
{
$this->jobNotes = $jobNotes;
return $this;
}
/**
* Get jobNotes
*
* #return string
*/
public function getJobNotes()
{
return $this->jobNotes;
}
/**
* Set customerRefPo
*
* #param string $customerRefPo
* #return EnviroFiguresUpload
*/
public function setCustomerRefPo($customerRefPo)
{
$this->customerRefPo = $customerRefPo;
return $this;
}
/**
* Get customerRefPo
*
* #return string
*/
public function getCustomerRefPo()
{
return $this->customerRefPo;
}
/**
* Set uploaded
*
* #param \Date $uploaded
* #return EnviroFiguresUpload
*/
public function setUploaded($uploaded)
{
$this->uploaded = $uploaded;
return $this;
}
/**
* Get uploaded
*
* #return \Date
*/
public function getUploaded()
{
return $this->uploaded;
}
/**
* Set processed
*
* #param boolean $processed
* #return EnviroFiguresUpload
*/
public function setProcessed($processed)
{
$this->processed = $processed;
return $this;
}
/**
* Get processed
*
* #return boolean
*/
public function getProcessed()
{
return $this->processed;
}
/**
* Set deleted
*
* #param boolean $deleted
* #return EnviroFiguresUpload
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
return $this;
}
/**
* Get deleted
*
* #return boolean
*/
public function getDeleted()
{
return $this->deleted;
}
}
From what I've done so far, it does seem to be a Symfony2 issue as I can retrieve the data from MySQL quite easily. It just doesn't work here.
EDIT
I noticed that with the collation of the table, all the fields were set to latin1_swedish_ci. I've changed this to utf8_unicode_cibut this hasn't made a difference. I've also removed the blank checks in the query, again this still only returns one record.
EDIT 2
I've used EchoSQLLogger, and this is the output for this particular query inside Symfony2:
SELECT e0_.waste_type AS waste_type0, e0_.ewc_code AS ewc_code1, SUM(e0_.total_uom) AS sclr2, SUM(e0_.co2_saving) AS sclr3 FROM enviro_figures_upload e0_ WHERE e0_.customer_site = ? AND e0_.completion_date BETWEEN ? AND ? AND e0_.completion_date <> ? AND e0_.total_uom <> ? AND e0_.waste_type <> ? GROUP BY e0_.waste_type ORDER BY e0_.completion_date DESC
array(6) {
[0]=>
string(25) "CBS - Arena Park Coventry"
[1]=>
string(10) "2014-01-16"
[2]=>
string(10) "2015-01-16"
[3]=>
string(0) ""
[4]=>
string(0) ""
[5]=>
string(0) ""
}
array(6) {
[0]=>
int(2)
[1]=>
int(2)
[2]=>
int(2)
[3]=>
int(2)
[4]=>
int(2)
[5]=>
int(2)
}
It seems that you are comparing with empty sting AND total_uom != '' in custom query where in symfony query you are comparing with AND efu.totalUom != :zero.
Also group by statement is missing in symfony query.

Symfony 2 doctrine left join

I have query
$em = $this->getDoctrine()->getManager();
$query = $em->createQueryBuilder();
$query = $em->createQueryBuilder()
->select('com', 'cit')
->from('CatalogWebBundle:ComCompany', 'com')
->leftJoin('com.cmpCity', 'cit')
->getQuery()
->setMaxResults(1);
$info = $query->getResult();
work fine, but I dont know how to get result from JOINED TABLE. I try use get method from JOINED table ENTITIES, but it not work ?
Maybe I need to ad something to ENTITIES ?
class ComCity
{
/**
* #var integer
*
* #ORM\Column(name="cit_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $citId;
/**
* #var string
*
* #ORM\Column(name="cit_name", type="string", length=255, nullable=true)
*/
private $citName;
/**
* Get citId
*
* #return integer
*/
public function getCitId()
{
return $this->citId;
}
/**
* Set citName
*
* #param string $citName
* #return ComCity
*/
public function setCitName($citName)
{
$this->citName = $citName;
return $this;
}
/**
* Get citName
*
* #return string
*/
public function getCitName()
{
return $this->citName;
}
}
namespace Catalog\WebBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
class ComCompany
{
/**
* #var integer
*
* #ORM\Column(name="cmp_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $cmpId;
/**
* #var string
*
* #ORM\Column(name="cmp_name", type="string", length=255, nullable=true)
*/
private $cmpName;
/**
* #var integer
*
* #ORM\Column(name="cmp_code", type="bigint", nullable=true)
*/
private $cmpCode;
/**
* #var string
*
* #ORM\Column(name="cmp_vat", type="string", length=255, nullable=true)
*/
private $cmpVat;
/**
* #var integer
*
* #ORM\Column(name="cmp_emp", type="integer", nullable=true)
*/
private $cmpEmp;
/**
* #var string
*
* #ORM\Column(name="cmp_return", type="string", length=255, nullable=true)
*/
private $cmpReturn;
/**
* #var string
*
* #ORM\Column(name="cmp_return_from", type="string", length=255, nullable=true)
*/
private $cmpReturnFrom;
/**
* #var string
*
* #ORM\Column(name="cmp_return_till", type="string", length=255, nullable=true)
*/
private $cmpReturnTill;
/**
* #var string
*
* #ORM\Column(name="cmp_address", type="string", length=255, nullable=true)
*/
private $cmpAddress;
/**
* #var integer
*
* #ORM\Column(name="cmp_phone", type="bigint", nullable=true)
*/
private $cmpPhone;
/**
* #var string
*
* #ORM\Column(name="cmp_email", type="string", length=255, nullable=true)
*/
private $cmpEmail;
/**
* #var string
*
* #ORM\Column(name="cmp_site", type="string", length=255, nullable=true)
*/
private $cmpSite;
/**
* #var string
*
* #ORM\Column(name="cmp_ceo", type="string", length=255, nullable=true)
*/
private $cmpCeo;
/**
* #var string
*
* #ORM\Column(name="cmp_register", type="string", length=255, nullable=true)
*/
private $cmpRegister;
/**
* #var string
*
* #ORM\Column(name="cmp_url", type="string", length=255, nullable=false)
*/
private $cmpUrl;
/**
* #var \Catalog\WebBundle\Entity\ComCategory
*
* #ORM\ManyToOne(targetEntity="Catalog\WebBundle\Entity\ComCategory")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="cmp_category", referencedColumnName="cat_id")
* })
*/
private $cmpCategory;
/**
* #var \Catalog\WebBundle\Entity\ComCity
*
* #ORM\ManyToOne(targetEntity="Catalog\WebBundle\Entity\ComCity")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="cmp_city", referencedColumnName="cit_id")
* })
*/
private $cmpCity;
/**
* Get cmpId
*
* #return integer
*/
public function getCmpId()
{
return $this->cmpId;
}
/**
* Set cmpName
*
* #param string $cmpName
* #return ComCompany
*/
public function setCmpName($cmpName)
{
$this->cmpName = $cmpName;
return $this;
}
/**
* Get cmpName
*
* #return string
*/
public function getCmpName()
{
return $this->cmpName;
}
/**
* Set cmpCode
*
* #param integer $cmpCode
* #return ComCompany
*/
public function setCmpCode($cmpCode)
{
$this->cmpCode = $cmpCode;
return $this;
}
/**
* Get cmpCode
*
* #return integer
*/
public function getCmpCode()
{
return $this->cmpCode;
}
/**
* Set cmpVat
*
* #param string $cmpVat
* #return ComCompany
*/
public function setCmpVat($cmpVat)
{
$this->cmpVat = $cmpVat;
return $this;
}
/**
* Get cmpVat
*
* #return string
*/
public function getCmpVat()
{
return $this->cmpVat;
}
/**
* Set cmpEmp
*
* #param integer $cmpEmp
* #return ComCompany
*/
public function setCmpEmp($cmpEmp)
{
$this->cmpEmp = $cmpEmp;
return $this;
}
/**
* Get cmpEmp
*
* #return integer
*/
public function getCmpEmp()
{
return $this->cmpEmp;
}
/**
* Set cmpReturn
*
* #param string $cmpReturn
* #return ComCompany
*/
public function setCmpReturn($cmpReturn)
{
$this->cmpReturn = $cmpReturn;
return $this;
}
/**
* Get cmpReturn
*
* #return string
*/
public function getCmpReturn()
{
return $this->cmpReturn;
}
/**
* Set cmpReturnFrom
*
* #param string $cmpReturnFrom
* #return ComCompany
*/
public function setCmpReturnFrom($cmpReturnFrom)
{
$this->cmpReturnFrom = $cmpReturnFrom;
return $this;
}
/**
* Get cmpReturnFrom
*
* #return string
*/
public function getCmpReturnFrom()
{
return $this->cmpReturnFrom;
}
/**
* Set cmpReturnTill
*
* #param string $cmpReturnTill
* #return ComCompany
*/
public function setCmpReturnTill($cmpReturnTill)
{
$this->cmpReturnTill = $cmpReturnTill;
return $this;
}
/**
* Get cmpReturnTill
*
* #return string
*/
public function getCmpReturnTill()
{
return $this->cmpReturnTill;
}
/**
* Set cmpAddress
*
* #param string $cmpAddress
* #return ComCompany
*/
public function setCmpAddress($cmpAddress)
{
$this->cmpAddress = $cmpAddress;
return $this;
}
/**
* Get cmpAddress
*
* #return string
*/
public function getCmpAddress()
{
return $this->cmpAddress;
}
/**
* Set cmpPhone
*
* #param integer $cmpPhone
* #return ComCompany
*/
public function setCmpPhone($cmpPhone)
{
$this->cmpPhone = $cmpPhone;
return $this;
}
/**
* Get cmpPhone
*
* #return integer
*/
public function getCmpPhone()
{
return $this->cmpPhone;
}
/**
* Set cmpEmail
*
* #param string $cmpEmail
* #return ComCompany
*/
public function setCmpEmail($cmpEmail)
{
$this->cmpEmail = $cmpEmail;
return $this;
}
/**
* Get cmpEmail
*
* #return string
*/
public function getCmpEmail()
{
return $this->cmpEmail;
}
/**
* Set cmpSite
*
* #param string $cmpSite
* #return ComCompany
*/
public function setCmpSite($cmpSite)
{
$this->cmpSite = $cmpSite;
return $this;
}
/**
* Get cmpSite
*
* #return string
*/
public function getCmpSite()
{
return $this->cmpSite;
}
/**
* Set cmpCeo
*
* #param string $cmpCeo
* #return ComCompany
*/
public function setCmpCeo($cmpCeo)
{
$this->cmpCeo = $cmpCeo;
return $this;
}
/**
* Get cmpCeo
*
* #return string
*/
public function getCmpCeo()
{
return $this->cmpCeo;
}
/**
* Set cmpRegister
*
* #param string $cmpRegister
* #return ComCompany
*/
public function setCmpRegister($cmpRegister)
{
$this->cmpRegister = $cmpRegister;
return $this;
}
/**
* Get cmpRegister
*
* #return string
*/
public function getCmpRegister()
{
return $this->cmpRegister;
}
/**
* Set cmpUrl
*
* #param string $cmpUrl
* #return ComCompany
*/
public function setCmpUrl($cmpUrl)
{
$this->cmpUrl = $cmpUrl;
return $this;
}
/**
* Get cmpUrl
*
* #return string
*/
public function getCmpUrl()
{
return $this->cmpUrl;
}
/**
* Set cmpCategory
*
* #param \Catalog\WebBundle\Entity\ComCategory $cmpCategory
* #return ComCompany
*/
public function setCmpCategory(\Catalog\WebBundle\Entity\ComCategory $cmpCategory = null)
{
$this->cmpCategory = $cmpCategory;
return $this;
}
/**
* Get cmpCategory
*
* #return \Catalog\WebBundle\Entity\ComCategory
*/
public function getCmpCategory()
{
return $this->cmpCategory;
}
/**
* Set cmpCity
*
* #param \Catalog\WebBundle\Entity\ComCity $cmpCity
* #return ComCompany
*/
public function setCmpCity(\Catalog\WebBundle\Entity\ComCity $cmpCity = null)
{
$this->cmpCity = $cmpCity;
return $this;
}
/**
* Get cmpCity
*
* #return \Catalog\WebBundle\Entity\ComCity
*/
public function getCmpCity()
{
return $this->cmpCity;
}
}
getResult() returns the entire set of results as an iterable array collection, not a single result. Thus, when you are using setMaxResults(1), it is wise to fetch that single result using getSingleResult():
$info = $query->getSingleResult();
If no results are returned, $info will be null. Otherwise you will be able to access the cmpCity property using:
$cmpCity = $info->getCmpCity();
Again, $cmpCity will be null if there is no cmpCity associated with the ComCompany object. If you want to get the first ComCompany object that does have an associated cmpCity, use innerJoin instead of leftJoin:
$query = $em->createQueryBuilder()
->select('com', 'cit')
->from('CatalogWebBundle:ComCompany', 'com')
->innerJoin('com.cmpCity', 'cit')
->getQuery()
->setMaxResults(1);
$info = $query->getSingleResult();
$cmpCity = $info->getCmpCity();
This might be related to the issue when you combine leftJoin and setMaxResults.
There is already answers on how you should do your query : https://stackoverflow.com/a/14886847/3726645

#Assert\Valid of OneToMany property doesn't work

I'm trying to solve my problem but after many hours of search, It doesn't work :(
So I've got a class :
<?php
namespace Application\HappyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Bar
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="Application\HappyBundle\Entity\BarRepository")
*/
class Bar
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
* #Assert\NotBlank()
* #ORM\Column(name="name", type="string", length=45)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="address", type="string", length=255)
*/
private $address;
/**
* #var string
*
* #ORM\Column(name="addressComplete", type="string", length=255)
*/
private $addressComplete;
/**
* #var string
*
* #ORM\Column(name="postal_code", type="string", length=5, nullable=true)
*/
private $postalCode;
/**
* #var string
*
* #ORM\Column(name="town", type="string", length=45)
*/
private $town;
/**
* #var string
*
* #ORM\Column(name="country", type="string", length=45)
*/
private $country;
/**
* #var string
*
* #ORM\Column(name="latitude", type="string", length=20)
*/
private $latitude;
/**
* #var string
*
* #ORM\Column(name="longitude", type="string", length=20)
*/
private $longitude;
/**
* #var array
*
* #ORM\Column(name="validate", type="boolean", nullable=false)
*/
private $validate;
/**
* #var \DateTime
*
* #ORM\Column(name="last_update", type="datetime", nullable=true)
*/
private $lastUpdate;
/**
* #var ArrayCollection of AssocBarDay
* #Assert\Valid
* #ORM\OneToMany(targetEntity="Application\HappyBundle\Entity\AssocBarDay", mappedBy="bar" , cascade={"persist" , "remove"})
*/
private $day;
/**
* #ORM\OneToMany(targetEntity="Application\HappyBundle\Entity\AssocBarDrink", mappedBy="drink", cascade={"persist"})
*/
private $drink;
/**
* #ORM\OneToMany(targetEntity="Application\HappyBundle\Entity\Bar", mappedBy="barVersionned", cascade={"persist"})
*/
private $barHaveVersions;
/**
* #ORM\ManyToOne(targetEntity="Application\HappyBundle\Entity\Bar", inversedBy="barHaveVersions" , cascade={"persist"})
*/
private $barVersionned;
/**
* Constructor
*/
public function __construct()
{
$this->day = new \Doctrine\Common\Collections\ArrayCollection();
$this->drink = new \Doctrine\Common\Collections\ArrayCollection();
$this->validate = false;
$this->lastUpdate = new \DateTime('now');
}
public function __toString(){
return $this->name;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
* #return Bar
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set address
*
* #param string $address
* #return Bar
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* #return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set postalCode
*
* #param string $postalCode
* #return Bar
*/
public function setPostalCode($postalCode)
{
$this->postalCode = $postalCode;
return $this;
}
/**
* Get postalCode
*
* #return string
*/
public function getPostalCode()
{
return $this->postalCode;
}
/**
* Set town
*
* #param string $town
* #return Bar
*/
public function setTown($town)
{
$this->town = $town;
return $this;
}
/**
* Get town
*
* #return string
*/
public function getTown()
{
return $this->town;
}
/**
* Set country
*
* #param string $country
* #return Bar
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* #return string
*/
public function getCountry()
{
return $this->country;
}
/**
* Set latitude
*
* #param string $latitude
* #return Bar
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
return $this;
}
/**
* Get latitude
*
* #return string
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Set longitude
*
* #param string $longitude
* #return Bar
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
return $this;
}
/**
* Get longitude
*
* #return string
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Add drink
*
* #param \Application\HappyBundle\Entity\AssocBarDrink $drink
* #return Bar
*/
public function addDrink(\Application\HappyBundle\Entity\AssocBarDrink $drink)
{
$this->drink[] = $drink;
return $this;
}
/**
* Remove drink
*
* #param \Application\HappyBundle\Entity\AssocBarDrink $drink
*/
public function removeDrink(\Application\HappyBundle\Entity\AssocBarDrink $drink)
{
$this->drink->removeElement($drink);
}
/**
* Get drink
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getDrink()
{
return $this->drink;
}
/**
* Add day
*
* #param \Application\HappyBundle\Entity\AssocBarDay $day
* #return Bar
*/
public function addDay(\Application\HappyBundle\Entity\AssocBarDay $day)
{
$this->day[] = $day;
return $this;
}
/**
* Remove day
*
* #param \Application\HappyBundle\Entity\AssocBarDay $day
*/
public function removeDay(\Application\HappyBundle\Entity\AssocBarDay $day)
{
$this->day->removeElement($day);
}
/**
* Get day
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getDay()
{
return $this->day;
}
/**
* Set lastUpdate
*
* #param \DateTime $lastUpdate
* #return Bar
*/
public function setLastUpdate($lastUpdate)
{
$this->lastUpdate = $lastUpdate;
return $this;
}
/**
* Get lastUpdate
*
* #return \DateTime
*/
public function getLastUpdate()
{
return $this->lastUpdate;
}
/**
* Set validate
*
* #param boolean $validate
* #return Bar
*/
public function setValidate($validate)
{
$this->validate = $validate;
return $this;
}
/**
* Get validate
*
* #return boolean
*/
public function getValidate()
{
return $this->validate;
}
/**
* Add barHaveVersions
*
* #param \Application\HappyBundle\Entity\Bar $barHaveVersions
* #return Bar
*/
public function addBarHaveVersion(\Application\HappyBundle\Entity\Bar $barHaveVersions)
{
$this->barHaveVersions[] = $barHaveVersions;
return $this;
}
/**
* Remove barHaveVersions
*
* #param \Application\HappyBundle\Entity\Bar $barHaveVersions
*/
public function removeBarHaveVersion(\Application\HappyBundle\Entity\Bar $barHaveVersions)
{
$this->barHaveVersions->removeElement($barHaveVersions);
}
/**
* Get barHaveVersions
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getBarHaveVersions()
{
return $this->barHaveVersions;
}
/**
* Set barVersionned
*
* #param \Application\HappyBundle\Entity\Bar $barVersionned
* #return Bar
*/
public function setBarVersionned(\Application\HappyBundle\Entity\Bar $barVersionned = null)
{
$this->barVersionned = $barVersionned;
return $this;
}
/**
* Get barVersionned
*
* #return \Application\HappyBundle\Entity\Bar
*/
public function getBarVersionned()
{
return $this->barVersionned;
}
/**
* Set addressComplete
*
* #param string $addressComplete
* #return Bar
*/
public function setAddressComplete($addressComplete)
{
$this->addressComplete = $addressComplete;
return $this;
}
/**
* Get addressComplete
*
* #return string
*/
public function getAddressComplete()
{
return $this->addressComplete;
}
}
and OneToMany with this class:
<?php
namespace Application\HappyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\ExecutionContextInterface;
/**
* AssocBarDayHappyHour
* #ORM\Table(name="assoc_bar_day")
* #ORM\Entity(repositoryClass="Application\HappyBundle\Entity\AssocBarDayRepository")
*/
class AssocBarDay
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="Application\HappyBundle\Entity\Bar", inversedBy="day" , cascade={"persist"})
*/
private $bar;
/**
* #var array
* #ORM\Column(name="day", type="array", nullable=true)
*/
private $day;
/**
* #var \DateTime
* #Assert\Time()
* #ORM\Column(name="time_start_happy_hour", type="time", nullable=true)
*/
private $timeStartHappyHour;
/**
* #var \DateTime
* #Assert\Time()
* #ORM\Column(name="time_end_happy_hour", type="time", nullable=true)
*/
private $timeEndHappyHour;
/**
* #var \DateTime
* #Assert\Time()
* #ORM\Column(name="time_bar_open", type="time", nullable=true)
*/
private $timeBarOpen;
/**
* #var \DateTime
* #Assert\Time()
* #ORM\Column(name="time_bar_close", type="time" , nullable=true)
*/
private $timeBarClose;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set timeStartHappyHour
*
* #param \DateTime $timeStartHappyHour
* #return AssocBarDay
*/
public function setTimeStartHappyHour($timeStartHappyHour)
{
$this->timeStartHappyHour = $timeStartHappyHour;
return $this;
}
/**
* Get timeStartHappyHour
*
* #return \DateTime
*/
public function getTimeStartHappyHour()
{
return $this->timeStartHappyHour;
}
/**
* Set timeEndHappyHour
*
* #param \DateTime $timeEndHappyHour
* #return AssocBarDay
*/
public function setTimeEndHappyHour($timeEndHappyHour)
{
$this->timeEndHappyHour = $timeEndHappyHour;
return $this;
}
/**
* Get timeEndHappyHour
*
* #return \DateTime
*/
public function getTimeEndHappyHour()
{
return $this->timeEndHappyHour;
}
/**
* Set timeBarOpen
*
* #param \DateTime $timeBarOpen
* #return AssocBarDay
*/
public function setTimeBarOpen($timeBarOpen)
{
$this->timeBarOpen = $timeBarOpen;
return $this;
}
/**
* Get timeBarOpen
*
* #return \DateTime
*/
public function getTimeBarOpen()
{
return $this->timeBarOpen;
}
/**
* Set timeBarClose
*
* #param \DateTime $timeBarClose
* #return AssocBarDay
*/
public function setTimeBarClose($timeBarClose)
{
$this->timeBarClose = $timeBarClose;
return $this;
}
/**
* Get timeBarClose
*
* #return \DateTime
*/
public function getTimeBarClose()
{
return $this->timeBarClose;
}
/**
* Set bar
*
* #param \Application\HappyBundle\Entity\Bar $bar
* #return AssocBarDay
*/
public function setBar(\Application\HappyBundle\Entity\Bar $bar = null)
{
$this->bar = $bar;
return $this;
}
/**
* Get bar
*
* #return \Application\HappyBundle\Entity\Bar
*/
public function getBar()
{
return $this->bar;
}
/**
* Set day
*
* #param array $day
* #return AssocBarDay
*/
public function setDay($day)
{
$this->day = $day;
return $this;
}
/**
* Get day
*
* #return array
*/
public function getDay()
{
return $this->day;
}
}
So when I post my form, the Assert of the Collection of days doesn't block when time is empty?
I put correctly the:
#Assert\Valid
Over day Collection and
#Assert\Time()
of each property of AssocBarDay
:( anyone I've got an idea?
Thanks for your help.
The reason is almost all of the validation constraints will not return invalid for empty/null values.
Just have a look at the TimeValidator's validate method ...
if (null === $value || '' === $value || $value instanceof \DateTime) {
return;
}
Therefore you will need to add the #Assert\NotBlank constraint additionally to have empty values generate a validation error for that property.
NotBlank
Validates that a value is not blank, defined as not equal to a blank
string and also not equal to null.

Symfony2: Query the database with Doctrine

I have a small database connected with my Symfony2 project. I have my controller, the entity etc.
When I try to use the method find(), I am allways obtaining a null.
Here is how the find method is called:
public function loginsuccessAction()
{
$em = $this->getDoctrine()->getEntityManager();
$user = $em->getRepository('MDPILoginBundle:Users')->find(1);
var_dump($user);
}
My Users entity class has the needed getters and setters. My table Users is well populated.
What am I missing ? New with symfony, I am trying to do it for the first time, reading some tutorials.
Thank you very much.
PS: If you need more details, please feel free to ask me.
EDIT: Entity Users.php added
Here is the Users.php entity
<?php
namespace MDPI\LoginBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* MDPI\LoginBundle\Entity\Users
*
* #ORM\Table(name="users")
* #ORM\Entity
*/
class Users
{
/**
* #var integer $id
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var integer $editorId
*
* #ORM\Column(name="editor_id", type="integer", nullable=true)
*/
private $editorId;
/**
* #var string $email
*
* #ORM\Column(name="email", type="string", length=255, nullable=false)
*/
private $email;
/**
* #var string $password
*
* #ORM\Column(name="password", type="string", length=255, nullable=false)
*/
private $password;
/**
* #var integer $titleId
*
* #ORM\Column(name="title_id", type="integer", nullable=true)
*/
private $titleId;
/**
* #var string $firstname
*
* #ORM\Column(name="firstname", type="string", length=255, nullable=true)
*/
private $firstname;
/**
* #var string $lastname
*
* #ORM\Column(name="lastname", type="string", length=255, nullable=true)
*/
private $lastname;
/**
* #var string $department
*
* #ORM\Column(name="department", type="string", length=255, nullable=true)
*/
private $department;
/**
* #var string $organization
*
* #ORM\Column(name="organization", type="string", length=255, nullable=true)
*/
private $organization;
/**
* #var string $address1
*
* #ORM\Column(name="address1", type="string", length=255, nullable=true)
*/
private $address1;
/**
* #var string $address2
*
* #ORM\Column(name="address2", type="string", length=255, nullable=true)
*/
private $address2;
/**
* #var string $city
*
* #ORM\Column(name="city", type="string", length=50, nullable=true)
*/
private $city;
/**
* #var string $state
*
* #ORM\Column(name="state", type="string", length=50, nullable=true)
*/
private $state;
/**
* #var string $zipcode
*
* #ORM\Column(name="zipcode", type="string", length=50, nullable=true)
*/
private $zipcode;
/**
* #var integer $countryId
*
* #ORM\Column(name="country_id", type="integer", nullable=true)
*/
private $countryId;
/**
* #var string $telephone
*
* #ORM\Column(name="telephone", type="string", length=25, nullable=true)
*/
private $telephone;
/**
* #var string $fax
*
* #ORM\Column(name="fax", type="string", length=25, nullable=true)
*/
private $fax;
/**
* #var integer $workplaceId
*
* #ORM\Column(name="workplace_id", type="integer", nullable=true)
*/
private $workplaceId;
/**
* #var integer $jobtypeId
*
* #ORM\Column(name="jobtype_id", type="integer", nullable=true)
*/
private $jobtypeId;
/**
* #var string $researchKeywords
*
* #ORM\Column(name="research_keywords", type="string", length=255, nullable=true)
*/
private $researchKeywords;
/**
* #var string $ip
*
* #ORM\Column(name="ip", type="string", length=15, nullable=true)
*/
private $ip;
/**
* #var boolean $status
*
* #ORM\Column(name="status", type="boolean", nullable=false)
*/
private $status;
/**
* #var boolean $active
*
* #ORM\Column(name="active", type="boolean", nullable=false)
*/
private $active;
/**
* #var bigint $dateRegistered
*
* #ORM\Column(name="date_registered", type="bigint", nullable=false)
*/
private $dateRegistered;
/**
* #var string $alertFrequency
*
* #ORM\Column(name="alert_frequency", type="string", length=10, nullable=true)
*/
private $alertFrequency;
/**
* #var datetime $alertLastSuccess
*
* #ORM\Column(name="alert_last_success", type="datetime", nullable=false)
*/
private $alertLastSuccess;
/**
* #var text $signature
*
* #ORM\Column(name="signature", type="text", nullable=true)
*/
private $signature;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set editorId
*
* #param integer $editorId
*/
public function setEditorId($editorId)
{
$this->editorId = $editorId;
}
/**
* Get editorId
*
* #return integer
*/
public function getEditorId()
{
return $this->editorId;
}
/**
* Set email
*
* #param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* Get email
*
* #return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set password
*
* #param string $password
*/
public function setPassword($password)
{
$this->password = $password;
}
/**
* Get password
*
* #return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set titleId
*
* #param integer $titleId
*/
public function setTitleId($titleId)
{
$this->titleId = $titleId;
}
/**
* Get titleId
*
* #return integer
*/
public function getTitleId()
{
return $this->titleId;
}
/**
* Set firstname
*
* #param string $firstname
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
}
/**
* Get firstname
*
* #return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set lastname
*
* #param string $lastname
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
}
/**
* Get lastname
*
* #return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Set department
*
* #param string $department
*/
public function setDepartment($department)
{
$this->department = $department;
}
/**
* Get department
*
* #return string
*/
public function getDepartment()
{
return $this->department;
}
/**
* Set organization
*
* #param string $organization
*/
public function setOrganization($organization)
{
$this->organization = $organization;
}
/**
* Get organization
*
* #return string
*/
public function getOrganization()
{
return $this->organization;
}
/**
* Set address1
*
* #param string $address1
*/
public function setAddress1($address1)
{
$this->address1 = $address1;
}
/**
* Get address1
*
* #return string
*/
public function getAddress1()
{
return $this->address1;
}
/**
* Set address2
*
* #param string $address2
*/
public function setAddress2($address2)
{
$this->address2 = $address2;
}
/**
* Get address2
*
* #return string
*/
public function getAddress2()
{
return $this->address2;
}
/**
* Set city
*
* #param string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* Get city
*
* #return string
*/
public function getCity()
{
return $this->city;
}
/**
* Set state
*
* #param string $state
*/
public function setState($state)
{
$this->state = $state;
}
/**
* Get state
*
* #return string
*/
public function getState()
{
return $this->state;
}
/**
* Set zipcode
*
* #param string $zipcode
*/
public function setZipcode($zipcode)
{
$this->zipcode = $zipcode;
}
/**
* Get zipcode
*
* #return string
*/
public function getZipcode()
{
return $this->zipcode;
}
/**
* Set countryId
*
* #param integer $countryId
*/
public function setCountryId($countryId)
{
$this->countryId = $countryId;
}
/**
* Get countryId
*
* #return integer
*/
public function getCountryId()
{
return $this->countryId;
}
/**
* Set telephone
*
* #param string $telephone
*/
public function setTelephone($telephone)
{
$this->telephone = $telephone;
}
/**
* Get telephone
*
* #return string
*/
public function getTelephone()
{
return $this->telephone;
}
/**
* Set fax
*
* #param string $fax
*/
public function setFax($fax)
{
$this->fax = $fax;
}
/**
* Get fax
*
* #return string
*/
public function getFax()
{
return $this->fax;
}
/**
* Set workplaceId
*
* #param integer $workplaceId
*/
public function setWorkplaceId($workplaceId)
{
$this->workplaceId = $workplaceId;
}
/**
* Get workplaceId
*
* #return integer
*/
public function getWorkplaceId()
{
return $this->workplaceId;
}
/**
* Set jobtypeId
*
* #param integer $jobtypeId
*/
public function setJobtypeId($jobtypeId)
{
$this->jobtypeId = $jobtypeId;
}
/**
* Get jobtypeId
*
* #return integer
*/
public function getJobtypeId()
{
return $this->jobtypeId;
}
/**
* Set researchKeywords
*
* #param string $researchKeywords
*/
public function setResearchKeywords($researchKeywords)
{
$this->researchKeywords = $researchKeywords;
}
/**
* Get researchKeywords
*
* #return string
*/
public function getResearchKeywords()
{
return $this->researchKeywords;
}
/**
* Set ip
*
* #param string $ip
*/
public function setIp($ip)
{
$this->ip = $ip;
}
/**
* Get ip
*
* #return string
*/
public function getIp()
{
return $this->ip;
}
/**
* Set status
*
* #param boolean $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
* Get status
*
* #return boolean
*/
public function getStatus()
{
return $this->status;
}
/**
* Set active
*
* #param boolean $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* Get active
*
* #return boolean
*/
public function getActive()
{
return $this->active;
}
/**
* Set dateRegistered
*
* #param bigint $dateRegistered
*/
public function setDateRegistered($dateRegistered)
{
$this->dateRegistered = $dateRegistered;
}
/**
* Get dateRegistered
*
* #return bigint
*/
public function getDateRegistered()
{
return $this->dateRegistered;
}
/**
* Set alertFrequency
*
* #param string $alertFrequency
*/
public function setAlertFrequency($alertFrequency)
{
$this->alertFrequency = $alertFrequency;
}
/**
* Get alertFrequency
*
* #return string
*/
public function getAlertFrequency()
{
return $this->alertFrequency;
}
/**
* Set alertLastSuccess
*
* #param datetime $alertLastSuccess
*/
public function setAlertLastSuccess($alertLastSuccess)
{
$this->alertLastSuccess = $alertLastSuccess;
}
/**
* Get alertLastSuccess
*
* #return datetime
*/
public function getAlertLastSuccess()
{
return $this->alertLastSuccess;
}
/**
* Set signature
*
* #param text $signature
*/
public function setSignature($signature)
{
$this->signature = $signature;
}
/**
* Get signature
*
* #return text
*/
public function getSignature()
{
return $this->signature;
}
}
Make sure the value you are using in the find method is the same as the defined primary key ( #ID ) in your entity.

Resources