doctrine

How do you override a Constant in Doctrine's Models?

末鹿安然 提交于 2019-12-24 17:29:04
问题 In Doctrine you are provided with a Constant Variable that allows you to set a global Identifier column in all of the models that are generated by Doctrine's code. I am trying to figure out how I can override/shut off this value so that it does not create this column in a specific table. The Constant is: ATTR_DEFAULT_IDENTIFIER_OPTIONS It gets set in a bootstrapped PHP file and it automatically creates the appropriate table in your Database. Example Code: // set the default primary key to be

Right way to define MongoDB in config.yml

断了今生、忘了曾经 提交于 2019-12-24 17:27:35
问题 I'm using MongoDB in my project but apparently Doctrine update their bundle and now I'm having issues if I run "composer update" command. This is my doctrine.yml file: # ODM doctrine_odm.mongodb: connections: default: server: mongodb://%mongo_host%:%mongo_port% options: {} default_database: %mongo_database% document_managers: default: auto_mapping: true But I get this error: [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] There is no extension able to load the

How can I join multiple tables in symfony2?

纵然是瞬间 提交于 2019-12-24 17:15:56
问题 I am working on a project. I am using symfony2 with XAMPP with PHP version of 5.5.19. I have three tables that have relationship .. Here are the tables : table_name : transaction_tbl - transaction_id -filename -filepath -sender -doctype_id table_name : doctype_tbl -doctype_id - doctype -name -description table_name : transaction_details - details_id -ref_numbers -amount -transaction_id what I want to do is to join the three tables so I can get the doctype with its details. Meaning need to

Doctrine Composite Keys Throwing Error

不打扰是莪最后的温柔 提交于 2019-12-24 15:59:15
问题 I am trying to update my schema in doctrine using: php vendor/bin/doctrine orm:schema-tool:update But I am getting the error message: [Doctrine\ORM\Mapping\MappingException] Single id is not allowed on composite primary key in entity entities\Events The events entity looks like this: <?php // entities/Events.php namespace entities; use Entities\Enities; use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Table; /** * @Entity * @Table(name="development.events") **/ class Events extends Entities

Symfony 4 Doctrine EventSubscriber not used

狂风中的少年 提交于 2019-12-24 15:56:50
问题 Trying to register a Doctrine EventSubscriber but nothing is ever actually fired. I have, on the Entity, in question, set the @ORM\HasLifeCycleCallbacks annotation. Here's the Subscriber: <?php namespace App\Subscriber; use App\Entity\User; use Doctrine\Common\EventSubscriber; use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Event\PreUpdateEventArgs; use Doctrine\ORM\Events; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; class

Doctrine: Models with column_aggregation inheritance appear twice in SQL

亡梦爱人 提交于 2019-12-24 15:36:17
问题 Has anyone noticed this? Whenever a model uses column_aggregation (inheritance), the schema.sql has 2 CREATE TABLE commands, one creates the basic table, and the other (apart from fields) adds an index on the inheritence column CREATE TABLE Prop (id INT AUTO_INCREMENT, opt_property_type SMALLINT UNSIGNED DEFAULT 251 NOT NULL, property_nature VARCHAR(255), INDEX opt_property_type_idx (opt_property_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

Error: Invalid PathExpression. Must be a StateFieldPathExpression.

安稳与你 提交于 2019-12-24 14:34:59
问题 I'm working on a symfony project entity with query builder . When I try to run this function I get this issue. [Semantical Error] line 0, col 9 near 'category FROM': Error: Invalid PathExpression. Must be a StateFieldPathExpression. public function json_filterAllproductsAction() { $search = ""; $category = 1; //Combine tables and create the query with querybuilder $em = $this->container->get('doctrine.orm.entity_manager'); $qb = $em->createQueryBuilder(); $qb->select('p.category') ->from(

Symfony hiddenType using data_class for entity instead of transformer

让人想犯罪 __ 提交于 2019-12-24 13:53:00
问题 So i tried to store the id of one of my entities in the hiddenType and i got: The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class AppBundle\Entity\Users. You can avoid this error by setting the "data_class" option to "AppBundle\Entity\Users" or by adding a view transformer that transforms an instance of class AppBundle\Entity\Users to scalar, array or an instance of \ArrayAccess. data_class : "This option is used to set the

How to get entities in a many-to-many relationship that do NOT have a corresponding linked entity with DQL and Doctrine?

☆樱花仙子☆ 提交于 2019-12-24 12:43:53
问题 I have a standard many-to-many relationship set up. Entity A can have many of Entity B, and vice versa . I'm trying to get a list of all Entity A that do NOT have any corresponding Entity B. In SQL, I'd run a query like this: SELECT a.* FROM entity_a a LEFT JOIN a_b r ON r.AID = a.id WHERE r.BID IS NULL In this query, a_b is the linking table. I'm trying to write a DQL statement (or use some other method) to get the same result, but the following does not work: SELECT s FROM VendorMyBundle

Application works in app_dev.php, but not visible using app.php

无人久伴 提交于 2019-12-24 12:21:54
问题 I am really confused. I am using Symfony 2.7 and doctrine as its native ORM. So everything works as it is supposed to work when I start it using app_dev.php, but when I start it using app.php. It just doesn't work. In logs it says [2017-11-27 09:02:51] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "An exception occurred while executing 'SELECT t1.id AS id2, t1.code AS code3, t1.created AS created4, t1.updated AS updated5, t1.template_code AS template_code6, t1.label