php,symfony2,doctrine2,doctrine,migration
Firstly, the migration tool is just a tool. It is not meant as a bulletproof way to generate paths from versions. Generally, it is used as a template to which you will manually modify. To answer your question specifically, because the tool is designed to compare the overall schema. Considering...
php,class,symfony2,model-view-controller,doctrine
Check out this: $posts = $em->getRepository('BlogBundle:Post') ->getLatestPosts(); It must be $posts = $em->getRepository('BlogBlogBundle:Post') ->getLatestPosts(); Look up your namespace....
doctrine2,doctrine,doctrine-query
You want to use Doctrine's Partial Object Syntax $queryBuilder->select('partial au.{id, firstName}') As to why it's not returning an object, this is from the same documentation linked above: By default when you run a DQL query in Doctrine and select only a subset of the fields for a given entity, you...
php,symfony2,doctrine2,doctrine
Flush statement should be execute after persist. So Code should be: getEntityManager()->persist($user); getEntityManager()->flush(); ...
You need to persist your entity to let the EntityManager knows that it exists. $em->persist($item); $em->flush($item); ...
Finally I solved using a EventListener with a PreRemove action: public function preRemove(LifecycleEventArgs $args) { $entity = $args->getEntity(); $em = $args->getEntityManager(); if (get_class($entity) == 'Intranet\WebBundle\Entity\Notice') { $notificationRepository = $em->getRepository('IntranetNotificationsBundle:UserNoticeNotification'); $notifications = $notificationRepository->findByNotice($entity); foreach ($notifications as $notification) { $em->remove($notification); } $em->flush(); } } and defining the entity...
php,symfony2,doctrine2,doctrine,doctrine-1.2
you probably can use doctrine filters: http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html http://www.michaelperrin.fr/2014/07/25/doctrine-filters/ to disable: http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#disabling-enabling-filters-and-setting-parameters...
php,laravel,doctrine,eloquent,propel
As mentioned earlier, there is more than one way to accomplish the task, but here's a quick example using Commands. Controller namespace App\Http\Controllers; //... use App\Http\Requests\UpdateUserRequest; use App\Commands\UpdateUser; use App\User; //... class UserController extends Controller { /** * Update the specified resource in storage. * * @param int $id *...
That's almost correct. I would change: remove an extra addSelect() - put everything in a single select() change the leftJoin to utilize @ManyToMany relation So, something like this: $customers = $em->createQueryBuilder() ->select('c', 'ph') ->from('AppBundle:Customer', 'c') ->leftJoin('c.phoneNumbers', 'ph') ->orderBy('c.id', 'ASC') ->setFirstResult($offset) ->setMaxResults($max) ->getQuery() ->getResult(); Hope this helps......
php,mongodb,doctrine,full-text-search
I could not find relevant documentation, but I did find this issue on the project's Github repo. The issue has a milestone of 1.2.0 release, but it seems it has already been released in the 1.1.x branch. The issue has been closed via this commit. From the commit, it seems...
php,symfony2,doctrine2,doctrine
There is list of releases of migration bundle. Here is your working config(i tested it on my pc): "require": { "php": ">=5.3.3", "symfony/symfony": "2.2.*", "symfony/debug": "2.3.*", "doctrine/orm": "~2.2,>=2.2.3", "doctrine/doctrine-bundle": "1.2.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.2.*", "symfony/monolog-bundle": "2.2.*", "sensio/distribution-bundle": "2.2.*", "sensio/framework-extra-bundle": "2.2.*", "sensio/generator-bundle": "2.2.*", "jms/security-extra-bundle":...
With ManyToMany association, an Address can have multiple countries. Is this correct for your logic? If it is, you have to iterate on all countries of Address: {% for country in customer.address.country %} {{ country.isocode2 }} {% endfor %} If your address have only one country, you must use ManyToOne...
You need to move bin/cli-config.php in config/cli-config.php. Unfortunately I have not found documentation about it. I opened doctrine/dbal/bin/doctrine-dbal.php and checked how it worked....
php,validation,symfony2,doctrine
As you are not using symfony fullstack, you should manually create a validator servie to use it. See Usage Section of Validator component readme use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Constraints as Assert; class User { /** * @Assert\Length(min = 3) * @Assert\NotBlank */ private $name; /** * @Assert\Email * @Assert\NotBlank */ private...
Well I found it http://blog.lazycloud.net/symfony2-doctrine2-extentions-translatable/ Apparently I should add to my entity a $locale attribute and set above it the annotation * @Gedmo\Locale . and then I can use that to override the default fallback of the entity by seting the locale to whatever language I wish then calling $em->refresh($entity)...
php,symfony2,doctrine2,doctrine,override
All DoctrineBundle classes are configured here: https://github.com/doctrine/DoctrineBundle/blob/master/Resources/config/dbal.xml You could probably override "doctrine.dbal.logger.profiling.class" with your own implementation like this: # app/config/config.yml parameters: doctrine.dbal.logger.profiling.class: Acme\HelloBundle\Logging\MyDebugStack And in your class: namespace Acme\HelloBundle\Logging; use Doctrine\DBAL\Logging\DebugStack; class MyDebugStack extends DebugStack { //... } Also, read this section about bundle overriding:...
Remember you declared $menuItems as protected. To access it you should create a getter (if you are calling it outside the class, which you don't specify, but i'm guessing it): public function getMenuItems() { return $this->menuItems; } and then to add a MenuItem: $menu->getMenuItems()->add($item); ...
symfony2,doctrine,query-builder
You can use the getDql() method (but i think it fail when the subquery have a parameter) : $querym = $querym->select('DISTINCT(a.id)') ->where ('a.doctorid =' . (int) $u); $query = $query->select('DISTINCT(d.id),d.name,d.dob,d.mobile')->...->where($query->expr()->In('d.id', $querym->getDql())); You can also use 2 queries (as Derick F say), something like that : $ids = array(); $querym =...
symfony2,doctrine,entities,persist
Ok i managed to fix this somehow by regenerating my User entity with php app/console doctrine:generate:entities BeArtsUserBundle ...
php,mysql,symfony2,doctrine,data-modeling
Here is an approach I used to create a series of crosstab reports for a client. Doing so required abstracting at least some of the formatting of a pivot table. Hope it helps. First, an example of a report: In this report, the county entity (linked to the address of...
api,symfony2,exception-handling,doctrine
The Symfony validator service can be used directly to validate any object for which validation constraints are defined. For example in a controller: $validator = $this->get('validator'); $errors = $validator->validate($test); To perform validation within a service you can pass the validator service into your service....
symfony2,doctrine,sonata-admin,symfony-sonata
Ok, I solved it by adding the following options to the StoDoctrineExtensions-Bundle: stof_doctrine_extensions: translation_fallback: false persist_default_translation: true ...
php,forms,doctrine,symfony1,symfony-1.4
You should put these kind of logics into a custom validator: class myValidatorMoney extends sfValidatorNumber { protected function doClean($value) { $clean = $this->processNumber($value); // your logic in this function if($clean === false) { // if not possible to process throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return parent::doClean($clean); }...
If you want to use single table for 3 classes, you should use DiscriminatorMap Example: We have a class Product, and two child classes Coupon and CustomProduct that inherited from Product /** * MyApp\ProductBundle\Entity\Product * * @ORM\Table(name="product") * @ORM\Entity(repositoryClass="MyApp\ProductBundle\Repository\ProductRepository") * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="productType", type="string") * @ORM\DiscriminatorMap({ * "Product" = "Product",...
database,symfony2,model,doctrine,nosql
So i kept searching and i found this: Mix of MySQL and Mongodb in an application The hstore field got my interest. Looking further i have discovered an extension to add hstore support on Doctrine and Symfony https://github.com/intaro/hstore-extension and it looks like it's exactly what i need. In alternative i...
php,sql,doctrine,business-intelligence,domain-model
I'm not sure if this question is asking for an opinion. This answer is intended to give you things to think about in making the choice. The choice between "external" ETL or "internal" ETL depends on several factors: The skill set of the developers. The requirements for the ETL. Specific...
php,symfony2,doctrine2,doctrine,symfony-2.3
You need to add a JoinTable for your ManyToMany association and set the owning and inverse sides: /** * @ORM\ManyToMany(targetEntity="PFE\EmployeesBundle\Entity\MembreFamille", * cascade={"persist"}, mapped="employees") */ private $membreFamilles; ................................. /** * @ORM\ManyToMany(targetEntity="PFE\UserBundle\Entity\Employee", cascade={"persist"}, inversedBy="membreFamilles") * @ORM\JoinTable(name="membre_familles_employees") */ private $employees; ...
php,symfony2,orm,doctrine2,doctrine
You should not use $em->flush() inside prePersist, it is restricted by Doctrine: http://doctrine-orm.readthedocs.org/en/latest/reference/events.html#reference-events-implementing-listeners There is information about preUpdate, but same situation (loop) is applied for prePesist call 9.6.6. preUpdate PreUpdate is the most restrictive to use event, since it is called right before an update statement is called for an...
database,symfony2,doctrine,one-to-many,dql
That's correct behavior. A collection is returned by $user->getClients(), not a single object. Doctrine's collections do not proxy method calls to their members. There are two ways to solve your problem: The simpler one. Rely on Doctrine's lazy load. Let's say you use data like this: foreach ($client as $user->getClients())...
php,symfony2,doctrine2,doctrine
Try to set the entity manager to providers, I think it should help: providers: administrators: entity: class: FinanceCmsBundle:AuthUser property: username ussers: entity: class: FinanceCzBundle:SystemAuthMailCentrum property: username manager_name: admin ...
From the sluggable readme: https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sluggable.md Update 2013-08-19 allow empty slug #807 regenerate slug only if set to null so: Fetch your entities Set their slug to null Flush And you are done !...
performance,orm,doctrine,comparison,propel
I'm also during making my decision which PHP ORM to choose and recently I found the following comparison of the main features of Doctrine2 and Propel 2: Side by side: Doctrine2 and Propel 2. The comparison is very precise and comprehensive, so surely it can come in handy when making...
php,symfony2,doctrine2,doctrine
For those who don't know it, turned out that the automatic labels are already translation keys, you simply need to specify the translation_domain in your form, so i have now a messages.fr.yml: First Name: Prénom And it's enough! No need to generate / specify a translation label. Plus it is...
I solved adding this to my AppKernel: if (in_array($this->getEnvironment(), array('prod'))) { $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); } Thanks anyways....
symfony2,doctrine,fosuserbundle
To start with, sql databases do a good job of automatically caching queries. So while there is some overhead in composing and sending the query to the server, the server itself will respond very quickly. You won't save much be adding another cache. Should you still try and optimize? In...
php,inheritance,orm,doctrine2,doctrine
I would recommend you to define all possible values in a configuration file. With that you don't have to implement a sophisticated auto-discovery that will fail as soon as requirements change and you can even supply additional information. Consider this example: boxes.yml boxes: text: class: "My\FQCN\To\TextBox" displayName: "Text Box" editableBy:...
Alexandr's response is close. When you query for id < 2 LIMIT 1 it will return 1, but if you query for id < 5 LIMIT 1 this will also return 1. That is because it returns 1, 2, 3, 4 and takes the first element, which is 1 rather...
Calling createQueryBuilder('p') will add the select statement on p which symbolize the entity the repo is linked to. If you want to select anything which is out of your entity's scope, then you need to use addSelect('yourentity.attribute') to make the selection explicit....
php,symfony2,doctrine,symfony-2.6
replace the line $em = $this->container()->get('doctrine')->getEntityManager(); with $em = $this->container->get('doctrine')->getEntityManager(); ...
mysql,symfony2,doctrine,twig,silex
Oh yeah twig is really nice... I thought I have to link the objects in the controller, but now I simply wrote: {% for teamGroup in teamGroups %} <div class="row row-centered"> <h3 class="text-center">{{ teamGroup.name }}</h3> {% for teamMember in teamMembers %} {% if teamMember.team_group_id is same as(teamGroup.id) %} <div class="col-xs-6...
php,mysql,symfony2,doctrine2,doctrine
You have several issues with your code: Two return statements Creating a form from an array of customers rather than a single entity Not using variable names that you have set in the template Here is what your view might look like: <table> {% for c in customers %} <tr>...
php,validation,symfony2,doctrine,custom-validators
Your custom validator must be in the same folder than your constraint. According to your namespaces, it's not the case. If you want to separate them, you can override the validatedBy() method of your Constraint class : public function validatedBy() { return get_class($this).'Validator'; } ...
symfony2,orm,doctrine2,doctrine
You need to create listener and listen for persisting on Distance entity. While it persists you can create new Distance with reverse route.
xml,symfony2,doctrine2,doctrine
Your implementation is confused in a few different ways. The object returned by a factory-method must be of the same type defined in the class attribute - so something that inherits from Doctrine\ORM\EntityRepository (this is where your "strange error" is coming from) It doesn't make sense to define a service...
php,symfony2,doctrine,deserialization,jmsserializerbundle
I solved the same problem with merge() function : $entity = $em->merge($data); $em->persist($entity); $em->flush(); ...
RELEASE is a reserved word in MySQL. If you really want to have your table be named release, you must set the table name in the entity and qoute it, like this: <?php /** * @ORM\Enity * @ORM\Table(name="`release`") */ class Release; … However, if you still have the option to...
php,sql-server,symfony2,doctrine2,doctrine
I develop a multi-database sf2 app with doctrine2 orm mapping. We use intellectsoft-uk/MssqlBundle Our configuration is: config.yml # Doctrine Configuration doctrine: dbal: default_connection: acme_mysql connections: acme_mysql: host: %acme_mysql_database_host% port: %acme_mysql_database_port% dbname: %acme_mysql_database_name% user: %acme_mysql_database_user% password: %acme_mysql_database_password% charset: UTF8 acme_slqsrv: driver: sqlsrv driver_class: \Realestate\MssqlBundle\Driver\PDODblib\Driver host: %acme_slqsrv% port: %acme_slqsrv%...
You need to persist your TypePurchase entity before you persist your Purchase Entity. The following example is an extension to the User-Comment example of this chapter. Suppose in our application a user is created whenever he writes his first comment. In this case we would use the following code: <?php...
Actually the problem is in line 26. Please change $qb->orderBy('f.dateTime', 'ASC');->setFirstResult($page); to $qb->orderBy('f.dateTime', 'ASC')->setFirstResult($page); Note:- line 25 seems correct.May be the problem due to line 26 only. please try to do like above and check once. thanks....
php,symfony2,doctrine2,doctrine
Looking at the annotations, my guess is that User::setParentId() is expecting a User object, not an integer: /** * @ORM\ManyToOne(targetEntity="User", inversedBy="children") * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true) * */ So instead of passing $new_user->setParentId($currentuser->getId()); try: $new_user->setParentId($currentuser); If that works, the field name should be changed appropriately to something like parent instead of...
php,symfony2,doctrine,composer-php,doctrine-migrations
Try this "repositories": [ { "source": { "url": "https://github.com/wimvds/DoctrineMigrationsBundle", "type": "git", } } } ], "require": { (...) "doctrine/migrations": "1.0.*@dev", "doctrine/doctrine-migrations-bundle": "dev-feature/multiple-em-support", (...) } ...
symfony2,doctrine2,annotations,doctrine,opcache
Problem is solved! It was caused by webhosting provider and server configuration. Opcache or Zend Optimizer was not configured properly
php,symfony2,datetime,doctrine2,doctrine
I see this simple way: $now = new \DateTime(); $data = $entityRepository->getByDate($now); then in your repository public function getByDate(\Datetime $date) { $from = new \DateTime($date->format("Y-m-d")." 00:00:00"); $to = new \DateTime($date->format("Y-m-d")." 23:59:59"); $qb = $this->createQueryBuilder("e"); $qb ->andWhere('e.date BETWEEN :from AND :to') ->setParameter('from', $from ) ->setParameter('to', $to) ; $result = $qb->getQuery()->getResult(); return...
symfony2,doctrine2,doctrine,mariadb
In haven't ever been able to get orWhere to function the way I think it should. It might be that you need a Where in your opening definition before you can add an orWhere later. You might have to use the nested orX statement like this instead: $query3->andWhere($query3->expr()->orX( $query3->expr()->like('t.languageIso', $query3->expr()->literal('en-US')),...
Thanks for all the help guys. The answer ended up being, in the orm.xml files for doctrine, the generatedvalue would never change, I manually removed the generatedvalue, in the xml document. After this, the insert DML statement worked correctly, and I see the row in my DB. The orm.xml file...
php,symfony2,doctrine2,doctrine,one-to-many
Assuming that your dump function is symfony/var-dumper and not a custom function Question 1 Yes, nested collection are not displayed by default by dump function, its about performance. This is not a Doctrine related issue. Your data are loaded here. You can play around with advanced use of var-dumper, like...
symfony2,doctrine,doctrine-extensions
https://github.com/l3pp4rd/DoctrineExtensions/blob/master/lib/Gedmo/Loggable/Entity/MappedSuperclass/AbstractLogEntry.php#L35 Is loggedAt property an answer for your question?...
symfony2,join,doctrine,many-to-many,createquery
Try this public function rechercherProjets($lang, $cat) { $qb = $this->createQueryBuilder('p') ->innerJoin ('p.description', 'pi') ->innerJoin('p.categories', 'pc') ->andWhere('pc.tag = :cat') ->andWhere('pi.langue = :lang') ->setParameters(array('lang'=>$lang,'cat'=>$cat)); return $qb->getQuery()->getResult() } ...
php,symfony2,doctrine2,doctrine
You're right: Doctrine looks only for changes into owning side but you're wrong: owning side of your relationship is Step, not Channel. Why is step the owning side? Because is the entity that has foreign key. Even Doctrine documentation says to you The owning side has to use the inversedBy...
php,symfony2,datetime,doctrine2,doctrine
The solution lies in the setDuration() setter, as both Doctrine and Symfony use it to set the duration. Just don't update the whole DateTime object, only its time part: public function setDuration(\DateTime $duration) { $this->duration->setTime( $duration->format('G'), $duration->format('i'), $duration->format('s') ); return $this; } ...
php,symfony2,orm,doctrine,assert
I have found out what is the problem. I have marked "link" column as a file and thus the validator was failing as link was text and not a file. My link code was: /** * @ORM\Column(type="string", length=220) * @Assert\File(maxSize="6000000") */ protected $link; and the line: * @Assert\File(maxSize="6000000") should not...
You need to persist the task object before flush like this: $em->persist($task); then you'll be able to flush. Read how to work with doctrine associations....
php,mysql,symfony2,doctrine2,doctrine
You need to extend Symfony's Controller class to be able to use getDoctrine() method. So: use Symfony\Bundle\FrameworkBundle\Controller\Controller; class CustomerController extends Controller { public function indexAction($id) { $customer = $this->getDoctrine()->getRepository('GSOrderBundle:Customer')->find($id); return new Response( '<html><body>Number: '.$id.'</body></html>' ); } } (you can also define controller as a service but this is more complex...
Maybe something like this will work: //In your Question entity add this public function __clone() { $this->id = null; } And modify your code like this: foreach ( $subject->getQuestions() as $question ) { $new_question = clone $question; $this->getEntityManager()->detach($new_question); $new_question->setUser( $user ); $new_question->setAnswers( new ArrayCollection() ); $new_question->setQuestionStatuses( new ArrayCollection() ); $new_question->setOptions(...
php,symfony2,doctrine,many-to-many
You are simply removing Tag if count($tag->getBooks()) == 0: $this->em->remove($tag); and persisting it again: $this->em->persist($tag); else is required: if(count($tag->getBooks()) == 0) { $this->em->remove($tag); } else { $this->em->persist($tag); } ...
php,symfony2,doctrine2,doctrine
You'll need to use a QueryBuilder for that, but that would still be quite a "pretty Doctrine code" and would still look quite like your pseudo-code. Something like this should work: $queryBuilder = $em->createQueryBuilder(); $query = queryBuilder ->select('u') ->distinct() ->from('AppBundle:User', 'u') ->join('AppBundle:WorkHour', 'wh') ->where('u.workHour = wh') ->andWhere('wh.project = :project') ->getQuery();...
php,symfony2,doctrine,migration,unique
I think the problem could be from your NOT NULL constraint on the settings_id column. You have to: Add you foreign key (settings_id) without the NOT NULL constraint Update all your foreign fields (settings_id) with values ALTER your foreign key (settings_id) with NOT NULL constraint ...
php,doctrine2,zend-framework2,doctrine
The error you are getting relates to Doctrine not being able to find an Entity called Doctrine\ORM\EntityManager, which is clearly wrong. My guess is that somewhere (perhaps in the getEntityManager() method) you are passing an instance of the entity manager to the entity manager. For example $entityManager = new EntityManager();...
A ManyToMany relationship does seem appropriate. You shouldn't have any trouble with this since ManyToMany uses a join table which handles all foreign keys, which means neither of your entities will actually have a field pointing towards the other in the database. Take a look at Doctrine's documentation : Many-To-Many,...
sql,postgresql,doctrine2,doctrine
With this query you will obtain all id, all pets, ordered by pet: SELECT id, unnest(string_to_array(pets, ',')) AS mypet FROM favpets ORDER BY mypet; Using it as subquery it will became easy to group and count: SELECT mypet, COUNT(*) FROM ( SELECT id, unnest(string_to_array(pets, ',')) AS mypet FROM favpets ORDER...
You can solve it in many ways but i like to make an parent entity eg ItemsCollection that holds an arrayCollection of Items. Then i give the new entity some extra functionality e.g. public function countItemValues() { $total = 0; foreach($this->items as $item) { $total += $item->getValue(); } return $total;...
When you using development enviorment (app_dev.php) profiler works independend of the fact of displaying toolbar unless you force to disable it via config. You can view all the profile data after successfull or failed request via http://your.app.address/_profiler/ If it is not enough there is a way to Change profile storage...
For what you've currently shown, you got an array result. Currently your Message instance is being stored in $messages[0]. So you either have to iterate over your result (if you expect more than one record) or replace your findBy with findOneBy if you expect one record.
findBy returns an array of entities that satisfy the condition. If you are sure there is only one, you can just use findOneBy instead and you will get a single entity. Check out http://doctrine-orm.readthedocs.org/en/latest/reference/working-with-objects.html#by-simple-conditions ...
sql,database,postgresql,doctrine
user is a reserved word. It's an alias for current_user. regress=> SELECT * FROM user; current_user -------------- myusername (1 row) If you want to use user as a table name, since it's a reserved word you must quote the identifier, e.g.: SELECT id FROM "user"; Your ORM should be quoting...
You could use a doctrine entity listener: https://symfony.com/doc/current/bundles/DoctrineBundle/entity-listeners.html http://doctrine-orm.readthedocs.org/en/latest/reference/events.html#entity-listeners And have something like this in it: public function postUpdateHandler(Vote $vote, LifecycleEventArgs $event) { if (null === $vote->getValue()) { // Following two lines could be avoided with a onDelete: "SET NULL" in Picture orm mapping $picture = $vote->getPicture(); $picture->removeVote($vote); $this->em->remove($vote);...
We found that in the Tree mapping file, we had to name the left: and right: columns as lft: and rgt:, identically to the examples on the github repository for the yaml mappings. fields: lft: <---- type: integer nullable: false options: unsigned: false gedmo: - treeLeft rgt: <----- type: integer...
php,symfony2,doctrine2,doctrine
Well, thats kind of ugly, but the only way I have found is to generate after all tables another set of migrations that altered the table and converted the encoding. the migration up() and down() functions looked like: ...... /** * @param Schema $schema */ public function up(Schema $schema) {...
symfony2,doctrine,composer-php,sylius,ezpublish
You have to configure doctrine to enable ORM like this: (example taken from the Symfony Standard Edition) # Doctrine Configuration doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8 # if using pdo_sqlite as your database driver: # 1. add the path in...
php,symfony2,doctrine2,doctrine,batch-insert
If it is a command, try running it with the option --no-debug. Or, you can disable the logger by calling $manager->getConnection()->getConfiguration()->setSQLLogger(null); at the beginning of your loadfunction. Either way disabling the logger saves quite a lot of memory during Doctrine batch tasks....
symfony2,merge,doctrine,persist
no, you can't remove The difference is what you do with entity after. Persist takes an entity instance, adds it to persistance context and makes it managed, so all other updates will be managed by entity manager. Merge will create new instance of entity, copies state form provided entity, and...
php,doctrine2,doctrine,php-5.3
You forgot quotes surrounding the value. $query = $em->createQuery('SELECT u FROM Usuario u WHERE u.usuario_email ="'. $usuario->getUsuario_email(). '"'); If you have a problem with SQL statements best thing to do is copy the query you got paste it to your SQL editor and see normally you would have spotted the...
doctrine2,doctrine,doctrine-query
$queryBuilder ->select('u', 'i.item_name', 't.otherColumns2') ->from('user_lp_requirement', 'u') ->innerJoin('u', 'item_master', 'i', 'u.item_id = i.item_id') ->innerJoin('u', 'training_program', 't', 'u.item_id = t.item_id'); This assumes that you want the user table mapped to the item table AND the user table mapped to the training table rather than the user table mapped to a join of...
mysql,symfony2,doctrine,foreign-keys
Add to Ordertaxi this code @JoinColumn(name="customOrder_id", referencedColumnName="id") ...
I did manually and work..but if has any other automatically, can post. thank you. ... $localizacao->setBairro($form->get('pessoajuridica')->get('localizacao')->get('bairro')->getValue()); $localizacao->setCep($form->get('pessoajuridica')->get('localizacao')->get('cep')->getValue()); $localizacao->setCidade($form->get('pessoajuridica')->get('localizacao')->get('cidade')->getValue());...
symfony2,caching,doctrine,capifony
Migrations are responsible for persistence layer only. It has nothing to do with EntityProxies, it only makes Database in sync with Model - that's all. In production, during deployment, you probably run git pull and composer install, which clears the cache, so migrations shoud run just after that. Reason -...
php,mysql,orm,doctrine2,doctrine
This is the idea, adapt table and column names as necessary: SELECT * FROM cages WHERE cage_id NOT IN (SELECT cage_id FROM birds WHERE name='eagle'); So, using doctrine: $qb = $this->createQueryBuilder(); $cagesWithEagles = $qb->select('b.cage_id') ->from('birds', 'b') ->where("b.name = :name") ->setParameter("name", 'eagle') ->getQuery() ->getResult(); $cagesWithoutEagles = $qb->select('c.cage_id') ->from('cages', 'c') ->where($qb->expr()->notIn('c.cage_id', $cagesWithEagles))...
mongodb,symfony2,doctrine,doctrine-odm
Alright it seems that in the current state doctrine-odm does not support multi-level priming. This is a known issue on GitHub. I found a solution in the GitHub Issue that passes a closure to the prime method to allow at least two level priming. Hope this helps someone. $myPrimer =...
I was despairing of finding a solution when I remembered that Doctrine have its proper cache, independent from Symfony (I tried tens of cache:clear without any change). I thought that my problem could be a Doctrine cache issue, so I tried to clear the cache: app/console doctrine:cache:clear-metadata (If you are...
php,symfony2,doctrine,entity,twig
You can filter a collection in a form by restricting the query results. E.g. something like: $accountData = $this->getEntityManager() ->createQueryBuilder()->select('a, c') ->from('YourAccountBundle:Account', 'a') ->join('a.customers', 'c') // assuming there is a relationship like this ->where('a = :yourAccountManager') ->setParameter('yourAccountManager', $accountEntity) ->getQuery()->getResult(); Then use $accountData in your parent form. This will restrict the...
In this case you can just give Doctrine (the default ORM of Symfony) the Object itself instead its id. Doctrine will figure out that it only has to save the id to the database. So it would be: $user = $this->getUser($user_id); $entity->setAuthor($user); You don't need to set it on the...