doctrine-orm

Exception with Doctrine2 and HYDRATE_SIMPLEOBJECT

廉价感情. 提交于 2020-01-06 14:55:31
问题 As a good practice i'm tring to hydrate an object as small as possible since data is going to be read only (just show the entity in my Twig template). So i've tried HYDRATE_SIMPLEOBJECT hydratation mode but i'm getting this exception: Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result. How should i interpret this message? By the way, here is the code that throws the exception: protected function getFindAllQueryBuilder() { return $this-

JOIN DQL (symfony2) multiple joins between two tables

拈花ヽ惹草 提交于 2020-01-06 14:50:11
问题 I have a problem in my DQL query. I have a table which has 3 foreign keys userId, userRId and userAId. Two of those foreign keys may be NULL. I want to join all the foreign keys in the query but i don't know how to join two or three foreign keys between the same tables. (see query ) Could somebody give me some ideas?? **TABLE A** id userId userRId userAId 1 2 NULL NULL 1 2 1 NULL 1 2 NULL 1 **TABLE USER** userId name 2 xxxx 1 xxxx The DQL query: "SELECT FROM nasyBundle:A a JOIN a.userId u , a

Getting fixtures to load after creating a join table entity

别说谁变了你拦得住时间么 提交于 2020-01-06 08:45:09
问题 I recently asked the following question: Many to Many, One to Many or Many to One After doing the updates suggested by @inanzzz my database looks great now however my fixtures seem to not work. I get the following error when trying to load them: [Symfony\Component\Debug\Exception\ContextErrorException] Catchable Fatal Error: Argument 1 passed to BBQ\Charcoal\WebsiteBundle\Enti ty\Templates::addModule() must be an instance of BBQ\Charcoal\WebsiteBundle \Entity\TemplateModules, instance of

Symfony entities are not updated in database after changes

落爺英雄遲暮 提交于 2020-01-06 08:00:50
问题 My symfony app is using Doctrine to persist entities in mysql. Today I updated my entities "Advertiser" and "Report" so there are relations between the two - as suggested in this post: When using EntityType to show a select, can't save entity from Symfony form When I try creating a migration, it says that the database is already in sync. php bin/console make:migration Returns: [WARNING] No database changes were detected. The database schema and the application mapping information are already

Symfony2 / Doctrine2 - How to convert this SQL request with QueryBuilder?

♀尐吖头ヾ 提交于 2020-01-06 07:04:17
问题 I have a relation : User -> [OneToMany] -> Profile <- [OneToMany] <- Group When a user joins a group, a profile is created with the couple user_id/group_id. And I want to get the unjoined groups from a user. This SQL request work good, but I want to translate it with QueryBuilder : For the user with id 2, SELECT g.id FROM Group g WHERE id NOT IN (SELECT group_id FROM Profile WHERE user_id = 2) Thanks for your help. 回答1: I didn't test it, but I think this should work $qb = $this->conn-

Symfony2 / Doctrine2 - How to convert this SQL request with QueryBuilder?

廉价感情. 提交于 2020-01-06 07:04:03
问题 I have a relation : User -> [OneToMany] -> Profile <- [OneToMany] <- Group When a user joins a group, a profile is created with the couple user_id/group_id. And I want to get the unjoined groups from a user. This SQL request work good, but I want to translate it with QueryBuilder : For the user with id 2, SELECT g.id FROM Group g WHERE id NOT IN (SELECT group_id FROM Profile WHERE user_id = 2) Thanks for your help. 回答1: I didn't test it, but I think this should work $qb = $this->conn-

Could not find any fixture services to load - Symfony 3.2

痴心易碎 提交于 2020-01-06 06:06:06
问题 After I run php bin/console doctrine:fixtures:load command I got this error message. 20:41:01 ERROR [console] Error thrown while running command "doctrine:fixtures:load". Message: "Could not find any fixture services to load." ["error" => InvalidArgumentException {trace: { …} …},"c ommand" => "doctrine:fixtures:load","message" => "Could not find any fixture services to load."] [] 20:41:01 ERROR [console] Command "doctrine:fixtures:load" exited with code "1" ["command" => "doctrine

make entities with multiple databases

谁说我不能喝 提交于 2020-01-06 05:03:06
问题 I have to do large refactoring/enhancements on web apps. We decided to use Symfony4. I want to define 2 (or more) databases: the old one and the new one. (In the future, I think to have more location , person databases common at several web apps) In my researches, I use Multiple Entity Managers, create my databases as mentionned, then create my src/Entity/Main and src/Entity/Customer folders. Then, I want to create my entities , especially new one with php bin/console make:entity but it

Updating DateTime in doctrine impossible

杀马特。学长 韩版系。学妹 提交于 2020-01-05 20:01:23
问题 I would like to update DateTime with Doctrine in my controller. The aim of page is to upload photos on a database. Only one upload by user is allowed. Everything is working but the DateTime is not persisted in the database. Here is my controller: public function delationAction(Request $request) { $_SESSION['AriseID']="boucas2013"; $finder = new Finder(); $finder->in('/var/www/html/separatiiste/web/uploads'); $photos = array(); foreach ($finder as $file) { array_push($photos, $file-

Oracle database error in symfony2 (doctrine). Is parameters.yml setup correctly?

≡放荡痞女 提交于 2020-01-05 10:03:01
问题 This is the info they gave me for the DB HOST: <ip> PORT: <port> DB NAME: <name> DB USER : <user> DB PASSWORD: <password> SERVICE: <service name> CHARSET: WE8MSWIN1252 My parameters.yml looks like this parameters: database_driver: oci8 database_host: <ip> database_port: <port> database_name: <name> database_user: <user> database_password: <password> database_service: true database_charset: WE8MSWIN1252 My guess is that I'm missing the service name, but I don't know how to set it up since