I have Symfony 3.1 project with Doctrine and doctrine/doctrine-fixtures-bundle and doctrine/data-fixtures installed. However, when i run a console command php bin/console doctrine:fixtures:load i get a message saying that there are no commands defined in the doctrine:fixtures namespace. The class DoctrineBundleFixturesBundleCommandLoadDataFixturesDoctrineCommand exists. Please suggest how to fix that. Answer Run first php bin/console and see if the command appear in the
Tag: doctrine-orm
logged user does not have all fields filled up
I’m using Symfony 2.8 and Doctrine and I have security.yml configured to point to the User class which implements UserInterface. My ORM schema is in YAML. The problem: In database the user has also specified “email” field, Symfony for LOGGED USER is not filling up that field and also “password” field is empty. When I do $this->get(‘doctrine.orm.entity_manager’)->clear(User::class); then the entity
Symfony get connected user id from entity
In a Symfony2.8/Doctrine2 application, I need to store in each row of my SQL tables the id of the user who created or updated the row (users can connect with Ldap). So all my entities inherited of a GenericEntity which contains this variable (type would be string if I want to store Ldap username): And I use the prePersistCallback() to
Aliasing fields using partial object syntax + array hydrator in doctrine 2
Is there any way to alias fields when using partial object syntax in Doctrine 2? I know I can do this: $this->createQueryBuilder(‘user’)->select([ ‘user.id AS id’, ‘user.firstName AS …
Semantical Error: Class MailileoBundleEntityMatch has no field or association named getMailid
I went through all similar issues but nothing appears to solve my problem. I’ve put a simple query in my MatchRepository but it throws a semantic error. I’ve double(triple) checked my entity and everything looks fine. It even works fine when I pull all Matches via findAll() and then run a $match->getMailid() The problem appears only in the MatchRepository file.
How to fetch entities in db while using doctrine fixtures?
I have been the ContainerAwareInterface on my LoadAdvert class so I can call and use the EntityManager to retrieve users in the database. However, when executing php bin/console doctrine:fixtures:load, the entity manager retrieves only an empty array, as if there was no user in the db. Answer Here it is how I do it. The main thing is to set
How to properly set “0000-00-00 00:00:00” as a DateTime in PHP
I have a column viewedAt which is a DATETIME and accept NULL values. It’s a software restriction to set that column on each new record as 0000-00-00 00:00:00 so I go through the easy way using Symfony and Doctrine as show below: But surprise PHP change that date to this -0001-11-30 00:00:00 and SQL mode in MySQL server is set
PHP Mocking Final Class
I am attempting to mock a php final class but since it is declared final I keep receiving this error: PHPUnit_Framework_Exception: Class “DoctrineORMQuery” is declared “final” and cannot be mocked. Is there anyway to get around this final behavior just for my unit tests without introducing any new frameworks? Answer Since you mentioned you don’t want to use any other
Doctrine migrations table collation
Trying to find a way to programatically create tables with certain collation, but can’t seem to find a way how to do it properly. I am using the “doctrine/doctrine-migrations-bundle”: “2.1.*@dev” and Symfony 2.3, I set up in my config.yml: It creates the database with LATIN1 charset and latin1_swedish_ci as default collation, when I run doctrine:database:create tool. Then I run my
Compare dates between datetimes with Doctrine
I have a Symfony2 application with a table that contains a date field, whose type is DateTime. I need to get all the entities where that field value is now. If I uses the following code, I get 0 results because Doctrine is comparing the DateTime object. I need to only compare year, month, and day, not hours. How can