doctrine2 , Do you know a web with list of Doctrine2 attributes and short description of each?


Do you know a web with list of Doctrine2 attributes and short description of each?

Question:

Tag: doctrine2

this is impossible to find all Doctrine2 attributes in the web.

Do you know a web with list of Doctrine2 attributes and short description of each?


Answer:

Check out the following webs:

http://ormcheatsheet.com/ (Doctrine part of the web)

http://www.elao.com/fr/blog/symfony-2-doctrine-2-cheat-sheets

http://zf2cheatsheet.com/ (about zf but it has a doctrine part)

Hope it helps.


Related:


Converting query string to an associative array in symfony2


symfony2,doctrine2,symfony-2.7
How to convert query string to an associative array in symfony2? Im new to symfony2. I googled it for couple of hours but there is no straightforward answer (example). Can anyone tell me how to do this?...

Multiple level of different kind of inheritance


php,doctrine2,multiple-inheritance,single-table-inheritance
For my project, I'm trying to use the inheritance feature of Doctrine. I need to represent medias (through different tables : one table for uploaded documents, one for linked videos, ... and so on). But, the videos can vary from provider to provider (such as Youtube, Dailymotion, you name it)....

Store entity from session doesn't work => $em->persist()


php,symfony2,doctrine2
at first: Sorry for my poor english :-) A beginner need help! I have 3 entities/tables: Tables: contact_person id, title, firstname, surname, adress_id address id, street, zip, city, country_id country (fix values) id, name, code 1, Austria, AT 2, Germany, DE ... Entities: /** * ContactPerson * * @ORM\Table(name="contact_person") *...

Symfony Entity query builder that checks for free spots


php,mysql,symfony2,doctrine2,dql
First off all: I know the title isn't helping, but it's the best I can think of. So I've got two entities in Symfony one is called Team and the other one Slot the Slot entity has a name, a start and end date and all that stuff. Besides that...

doctrine does not hydration when select custom fields


doctrine2,doctrine,doctrine-query
i have tried select fields with doctrine query buidler. $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder->select('au.id, au.firstName') ->from('Api\V1\Entity\AgencyUser', 'au') ->orderBy('au.firstName', 'asc'); $queryBuilder->andWhere('au.agency = :agencyId') ->setParameter('agencyId', $agency->getId()); print_r($queryBuilder->getQuery()->getResult(Query::HYDRATE_OBJECT));exit; result : Array ( [0] => Array ( [id] => 1 [firstName] => agency ) ) why this is an array ? i want to hydrated...

Add brands through company, it's possible? How?


php,symfony2,doctrine2,mapping,symfony-2.6
I have this two tables (see pics below) mapped as follow: class Brand { ... /** * @var Company * * @ORM\ManyToOne(targetEntity="Company") * @ORM\JoinColumn(name="companies_id", referencedColumnName="id") */ protected $company; } class Company { ... } I need to add support for add a new Brand from Company but I have not...

Doctrine migrations:diff ignores cascade


mysql,symfony2,doctrine2
I have ManyToOne relation between two entities and would like to use DB (MySQL) level cascade on delete. When I use doctrine:migrations:diff foreign key is created without ON DELETE CASCADE. So I added this cascade myself but on next migrations:diff this statement has been removed. Is there any way how...

How to select all rows that don't have one-to-many entity with certain value using Doctrine


php,mysql,orm,doctrine2,doctrine
I have two entities: Cage and Bird. Cage has Birds inside so their relationship is one-to-many. Bird has a field name. How can I select all Cages where there's no Bird with name eagle inside. I was trying to do this: $cages = $this->createQueryBuilder("c") ->leftJoin("c.birds", "b") ->where("b.name != :name") ->setParameter("name",...

How to query in Doctrine2 WHERE = 'value from a related Entity'


php,json,symfony2,orm,doctrine2
The relationship is as easy as Many posts -> one User // Acme\AppBundle\Entity\UploadPlugin\Post /** * @ORM\ManyToOne(targetEntity="Acme\AppBundle\Entity\AuthBundle\LiveUser") * @ORM\JoinColumn(name="posts", referencedColumnName="id") **/ private $postOwner; So when I create a new Post like this : $image = new Post(); $image->setName($imagetitle); $image->setPostowner($this->getUser()); //(...) set further stuff $em = $this->getDoctrine()->getManager(); $em->persist($image); $em->flush(); I'd just return...

Symfony Doctrine findBy and then map


php,symfony2,doctrine2,doctrine
Basically I want to execute this mysql query with doctrine: select distinct user_id from work_hour where project_id = ?; But I don't know how I can do this with pretty Doctrine code. Is it possible to make it look like the following pseudo code or do I have to use...

Is it a bad practice to move all Doctrine2 Entities into one single Bundle?


symfony2,doctrine2
Here is my issue; Lets say you create a relationship from one bundle to another (In this case, one user => many notifications) (UserBundle => NotificationsBundle) /** * @ORM\OneToMany(targetEntity="Gabriel\NotificationsBundle\Entity\Notification", mappedBy="notificationOwner") */ private $notifications; The Problem: When the Notificationsbundle gets removed from the AppKernel, the class above gets lost, and the...

Wrong datatype for referenced entity on Doctrine ObjectSelect


php,zend-framework,orm,doctrine2
I have a form which uses Doctrine's ObjectSelect to make a dropdown $this->add(array( 'name' => 'category', 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'options' => array( 'label' => 'Category', 'object_manager' => $em, 'target_class' => 'Blog\Entity\Category', 'property' => 'name' ), 'attributes' => array( 'required' => true ) )); the issue I have, is that this...

Error while generating doctrine entities with FOSUser Bundle in Symfony2


symfony2,doctrine2,fosuserbundle
I'm using FOSUser bundle and everything went ok until I tried to create the database entities, I get this error: It has nothing to do with the bug in Symfony 2.5, I'm using version 2.7 Case mismatch between loaded and declared class names: App\UserBundle\Entity\user vs App\UserBundle\Entity\User This is my config...

The class 'Doctrine\ORM\EntityManager' was not found in the chain configured namespaces XXX


php,doctrine2,zend-framework2,doctrine
I have read the the other questions concerning this issue but have not come across a solution as of yet. I get the following error message: The class 'Doctrine\ORM\EntityManager' was not found in the chain configured >namespaces ZfcUser\Entity, Common\Entity, Employment\Entity, Intern\Entity, >Team\Entity, PurchaseRequest\Entity. I have a HolidayEntity, HolidayController, HolidayService. Adding...

Join between ManyToMany properties at Doctrine2 entities


php,symfony2,doctrine2,dql,symfony-2.6
I have this tables relationship: This is how my entities for messages and emails looks like (I've just added the important info): class Message { /** * @var Brand * * @ORM\ManyToOne(targetEntity="Brand") * @ORM\JoinColumn(name="brands_id", referencedColumnName="id") */ protected $brand; ... } class Email { /** * @ORM\ManyToMany(targetEntity="Message", inversedBy="messageXrefMail", cascade={"persist", "remove"}) *...

Entity MetaData for Doctrine and multiple Entity Managers


symfony2,doctrine2
I'm trying to setup an Sql Server connection for Doctrine in Symfony2.However I can not figure out how to setup some Entity Foo to be managed by the new Entity Manager. I have seen this post in regards to managing Entities with multiple Entity Managers, however I don't know how...

How to set Symfony 2 slave database config in php


php,mysql,symfony2,configuration,doctrine2
I have a Symfony 2.7 application with Doctrine. I am trying to setup slave databases. We use lockerbox to manage our server configs. We use Constants to keep all database configuration, ex: <?php define('DB_MASTER_HOST', 'localhost'); define('DB_MASTER_USER', 'user'); define('DB_MASTER_PASS', 'password'); define('DB_MASTER_NAME', 'db_name'); define('DB_SLAVE_ENABLED', FALSE); define('DB_SLAVE_HOST', 'server-1,server-2'); define('DB_SLAVE_USER', 'username1,username2'); define('DB_SLAVE_PASS', 'password1,password2'); define('DB_SLAVE_NAME',...

Symfony2 - Access of the Repository from Entity


php,symfony2,doctrine2
I'm trying to learn Symfony, and I found it don't access the doctrine from the entity. I created an Entity <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Facility * * @ORM\Table() * @ORM\Entity * @ORM\Entity(repositoryClass="AppBundle\Entity\FacilityRepository") */ class Facility { /** * @var integer * * @ORM\Column(name="id", type="integer") *...

Symfony one-to-one, unidirectional relation


symfony2,doctrine2
I have two entities. User and Contact. User and contact have the same property phone_number. I would like to get all contacts with user object if its exists. It is also possible that the same phone number exists in contact table but it doesn't exist in user table. Below is...

Improve memory usage when importing data


symfony2,doctrine2
I'm actually searching for an advice, not a solution. I made a service that compare data from a distant database and insert, update, or remove local data if necessary. There are more than 50k entries in the source database, and local memory usage slow the script make it veeeery long....

How to fix Symfony2 deployment issues?


php,symfony2,deployment,doctrine2,symfony-2.7
I'm having this issue for a while at differents environments, differents projects and some times I did fixed some others likes now I can't find what is failing so this is my latest try. I want to deploy a app so following rules as docs say the first I did...

create properly a ManyToMany Recursive / Reflexive relation with doctrine ORM (Symfony)


php,database,symfony2,doctrine2,recursive-datastructures
I have this entity named Pointscomptage.php: class Pointscomptage { /** * @var integer * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string * * @ORM\Column(name="invariant", type="string", length=150, nullable=false) */ private $invariant; /** * @var string * * @ORM\Column(name="nom", type="string", length=150, nullable=false) */ private...

Doctrine fixtures won't get loaded in given order, instead, they get loaded in alphabetical order


symfony2,doctrine2
As far as I know, fixtures will be loaded in given order, based on the value returned in getOrder() method of each fixture files. Sharing Objects between Fixtures. For some reason, doctrine tries to load fixtures below in alphabetical order (class name) instead. In example below, it has to load...

Symfony2 entity foreign keys


symfony2,doctrine2,foreign-keys,entity
I can't figure it out.. Why I haven't access to Country table? countryName should show Great Britain but it doesn't. This is my dump($User): My my piece of code of User entity: /** * * @ORM\ManyToOne(targetEntity="Dashboard\MainBundle\Entity\Country", cascade={"persist"}) * @ORM\JoinColumn(name="country_id", referencedColumnName="id", nullable=true) * */ private $countryId; And my piece of code...

Class inheritance in Symfony2


php,symfony2,doctrine2
I'm a bit confused about an error that I'm getting: Undefined method 'getAsArray'. The method name must start with either findBy or findOneBy! getAsArray() is a method in my repository class, it's called in PostsController.php like so: $categoriesList = $this->getDoctrine()->getRepository('AirBlogBundle:Category')->getAsArray(); CategoryRepository.php is defined like this: namespace Air\BlogBundle\Repository; class CategoryRepository extends...

Persisting other entities inside preUpdate of Doctrine Entity Listener


symfony2,doctrine2
For clarity I continue here the discussion started here. Inside a Doctrine Entity Listener, in the preUpdate method (where I have access to both the old and new value of any field of the entity) I'm trying to persist an entity unrelated to the focal one. Basically I have entity...

how to access class variables and constants in annotation in symfony 2 php


php,symfony2,doctrine2
I have a class like this: class Student { const GENDER_MALE = "male", GENDER_FEMALE = "female"; /** * @var string $gender * * @ORM\Column(name="gender", type="string", length=50,nullable=false) * @Assert\NotBlank(message="Gender cannot be blank",groups={"new"}) * @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.", groups={"new"}) */ private $gender; I have to hard...

Sorting a collection in doctrine2


php,mongodb,doctrine2,doctrine,odm
I've written the following query (that may or may not be efficient, I'm still a newbie): $collection = $this->dm->getConnection()->selectCollection('db_name', 'collection_name'); $query = array('array_name' => new \MongoId(id)); $cursor = $collection->find($query)->limit(9)->sort('r', 'desc'); I'm trying to sort by an r value that looks like this in the document: "r": 0.58325652219355106354 but it isn't...

Inject a parameter into an entity in symfony2


php,symfony2,doctrine2
I feel silly asking this question but I can't find a clear answer anywhere. I have a token entity which has, among other things, a creation_time. I have a parameter in parameters.yml called token_lifespan. For a token, if creation_time < (time() - token_lifespan) then it has expired. The problem is...

How can i view Result of Database from doctrine in twig


php,symfony2,doctrine2,twig
Edit: change findOneBy to findBy In symfony I am using the FOS-UserBundle. I have three tables. fos_user customer customer_user This is the customerUser.orm.xml <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity...

Symfony Array Collection as Entity Property


php,symfony2,doctrine2
Is there a way to associate an ArrayCollection to a database column created by an Entity? For example, I have two entities: Household and Pet Type. Household current has a property for Pet Type, but it expects the Pet Type object, so only one can chosen at the moment. I'd...

Jms serializer @JMS\Inline() annotation overrides an actual id


php,symfony2,doctrine2,jmsserializerbundle,jms-serializer
I have product and product_detail tables in database. Every product has a product detail. class Product { /** * @var ProductDetail * @JMS\ReadOnly() * @ORM\OneToOne(targetEntity="ApiBundle\Entity\ProductDetail", mappedBy="product", cascade={"persist"}) * @JMS\Inline() */ private $detail; } I use @JMS\Inline() annotation to show only detail information of product_detail table. But when I serialize a...

Getting Objects from database in Symfony2


php,database,symfony2,doctrine2,symfony-2.7
I had read somewhere some day that symfony2/Doctrine2 has a method(i don't remember the method name now) that fetches all "like" objects that we specify.. For example, I have User entity that has userName , password, name, state and city as properties.. For getting all Users who has name =...

Why tree is invalid?


symfony2,doctrine2,tree,doctrine-extensions,stofdoctrineextensions
I have a entity that use doctrine extension, tree behaviuor, i found problems in tree and don't know it's reason. my entity: MyEntity: type: entity gedmo: tree: type: nested id: id: type: integer generator: strategy: AUTO fields: # ... lft: type: integer gedmo: - treeLeft rgt: type: integer gedmo: -...

“Unable to open database file” error when trying to load Doctrine Data Fixtures in Symfony


symfony2,doctrine2,behat
I'm using pdo_mysql for prod, stag and dev environments and pdo_sqlite for test environment. The problem is that loading Doctrine Data Fixtures generates unable to open database file error as shown below. I assigned the permissions to cache folder as defined in symfony website and also tried with 777 but...

RowAction in a Vector source APYDataGridBundle Symfony 2


symfony2,vector,datagrid,doctrine2
Im stuck with this issue for a few days, i currently have grid filled with results from a Stored Procedure, i run a nativequery with the SP, get the results in an Array and use the Vector class from ApyDataGrid to display the results. All of the above is working...

Symfony2 - Share Entity Between Bundles with different relationships


symfony2,doctrine2
How do you share an entity between multiple bundles with different relationships? For example both the ZooAnimalBundle and FarmAnimalBundle need a User Entity. A third Bundle AccountUserBundle has the User Entity. In both the Zoo and Farm AnimalBundles I create a User Entity like so: use Account\UserBundle\Entity\User as BaseUser; class...

AppBundle's Best Practice and how-to go further


php,symfony2,doctrine2,entity
According to this page on the documentation website of symfony they explain how to address your application logic and the best practices. The one thing I am missing in this documentation is the way to store and use your entities. There is a small section that covers the usage of...

Symfony2 Doctrine: ContextErrorException: Catchable Fatal Error: Object of class DateTime could not be converted to string


php,symfony2,doctrine2
In my Symfony2 project I have the following query in my ProductRepository.php: $dateNow = new \DateTime(); $query = $this->createQueryBuilder('p') ->update('MyBundle\Products', 'p') ->set('p.published', $dateNow) ->getQuery(); $query->execute(); ProductEntity.php: /** * Set published * * @param \DateTime $published * @return Product */ public function setPublished($published) { $this->published = $published; return $this; } ERROR:...

Doctrine persist entity with inverse relation not work


symfony2,doctrine2,entity
I'm trying to save two entities linked. Product entity may have any or many entities ProviderRate. When I try to save the product entity, it tells me that ProviderRate related entity has not assigned one of their required fields. I need to save a product with no need to assign...

doctrine/migrations incompatible with symfony 2.2.*


php,symfony2,doctrine2,doctrine
long story short: Im using Symfony 2.2.* (yes, its old) and a DEV-Enviroment using a deploy script. This script runs "composer update". Every thing works fine until today. Now I recive this error: - Conclusion: remove symfony/symfony v2.2.11 - Conclusion: don't install symfony/symfony v2.2.11 - Conclusion: don't install symfony/symfony v2.2.10...

Doctrine OneByOne's and Date


php,symfony2,doctrine2,entity
I am using Symfony 2.7.1 and I seem to have a problem while using my News Entity. I am trying to use the published_at in my twig template. I tried using {{ news_item.published_at|date("m/d/Y") }} but that seems to follow up by a fatal error: Method "published_at" for object "AppBundle\Entity\News" does...

Symfony time field not using the same date as the corresponding entity property


php,symfony2,datetime,doctrine2,doctrine
I've got an entity with a duration property, declared as time type: /* @ORM\Column(type="time") */ private $duration; In my Symfony form, this duration property maps to a time field: $builder->add( 'duration', 'time', [ 'input' => 'datetime', 'widget' => 'text' ] ) As the time type does not exist in PHP,...

Symfony2 Functional Testing: Is a database required or not?


php,unit-testing,symfony2,doctrine2,functional-testing
I have to write functional tests for a controller that registers a user in the application. The controller has two methods (and routes): registrationAction (route=registration) endAction (route=registration/end) Now I would like to write functional tests for those two methods. My question is: as the controller creates and persists a new...

With a OneToMany relation between entities, how create the right queryBuilder with Doctrine (on the Inversed Side entity)


php,symfony2,doctrine2,one-to-many,query-builder
I have these 3 entities in my symfony2.6 project: Compteurs.php class Compteurs { /** * @var \PointsComptage * * @ORM\ManyToOne(targetEntity="PointsComptage", inversedBy="compteurs") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="pointscomptage_id", referencedColumnName="id") * }) */ private $pointsComptage; /** * @var \Doctrine\Common\Collections\Collection * * @ORM\OneToMany(targetEntity="ParametresMesure", mappedBy="compteurs") */ private $parametresMesure; ParametresMesure.php: class ParametresMesure { /** * @var Compteurs...

Search from comma separated values in column


sql,postgresql,doctrine2,doctrine
I have a table with 2 coloums - id and pets pets column contain abbreviated pet names separated by , [comma] as shown below +----+-------------+ | id | pets | +----+-------------+ | 1 | CAT,DOG | +----+-------------+ | 2 | CAT,DOG,TIG | +----+-------------+ | 3 | ZEB,MOU | +----+-------------+ Now...

Doctrine include null on join


sql,symfony2,orm,doctrine2
I am trying to create a query that will fetch every users, and, for those that have received a feedback, fetch their rating average as well. After some research, I have crafted a query that will return all the users that have received a feedback and their respective rating. Which...

Symfony2 creating and persisting entity relationships


php,mysql,symfony2,doctrine2
I have two entities Skin and Email. I want Email to be a part of the Skin entity, however I can't use the console to update schema automatically right now, and that is probably why I can't get the relationship to work. So I want to store all the Emails...

what is wrong in this statement php doctrine


php,doctrine2,doctrine,php-5.3
I'm trying make a validation in my db using doctrine where I just need to make this statement in SQL like, Select * from usuarios where usuario_email = someEmail After I click the submit button from my form, I instantiate the class UsuarioDao, from a script that includes bootstrap.php (from...

Doctrine batch inserting uses 2GB of Ram


php,symfony2,doctrine2,doctrine,batch-insert
I am trying to insert approximately 200k of records with Symfony2 and Doctrine via Doctrine Fixtures Bundle. I am using flush and clear but at the end script uses 1.8 GB of RAM. This is the class that loads SmartMeter entities into database: <?php namespace HTEC\SmartMeteringAPIBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\FixtureInterface;...