doctrine

Need help understanding Doctrine many to many self referencing code

i am having trouble deciphering this block of code from doctrine documentation /** @Entity */ class User { // ... /** * @ManyToMany(targetEntity="User", mappedBy="myFriends") */ private $friendsWithMe; /** * @ManyToMany(targetEntity="User", inversedBy="friendsWithMe") * @JoinTable(name="friends", ...

Saving parent/child header/line using Doctrine 1.2

I have a simple parent-child/header-line model in my project. The problem is that its creating a cyclic relation or something, and not letting me save the parent without the child! Detect relations is switched off! detect_relations: false ... BillHeader: package: Billing tableName: Bill_Headers actAs: SoftDelete: ~ columns: ...

Can't delete objects due to foreign key constraints

This is a strange one Take this schema: Contact: actAs: [Timestampable,SoftDelete] columns: first_name: { type: string(255), notnull: true } second_name: { type: string(255), notnull: true } relations: Forums: class: Forum refClass: ContactForum local: forum_id foreign: contact_id fore...

Need help with: Couldn't call Doctrine_Core::set()... symfony 1.4 fixture

I keep getting: Couldn't call Doctrine_Core::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references. This happens when I include data for 'asset' in the 'Upload' table in my fixture. See part of the schema.yml below: detect_relations: true options: collate: utf8_general_ci char...

PHPUnit coverage now incomplete as class' opening brace is not covered.

Hey everyone, I've been using PHPUnit to to do unit testing on a Symfony/Doctrine project I'm working on. It was working fine until yesterday when various classes dropped from 100% coverage to 98-99%. The reason for the change is because the opening left brace of these classes is no longer considered "covered" for some reason. Here's a s...

Doctrine Record Listener

I have a listener which contains a preSave() method. Is there a way for me to halt doctrine from calling the save method if a condition fails. Unfortunately I am not allowed to throw an exception. Is there any other way? ...

Doctrine: How do i add elements to a relationship

i think my question is not clear but i try to illustrate my point here. assuming i have a many to many, self referencing relationship where a user can be a teacher (say u post answers at SO) and a teacher can be a student (u may answer questions but may ask too) too. namespace Entities; /** @Entity @Table(name="users")) */ class User {...

Fatal Error with Doctrine while using generate.php

I'm working on the Doctrine tutorial at http://www.Doctrine-project.org/ and I receive a fatal error when I try to run my generate.php script which makes my models and makes tables in the database: Fatal error: Class 'BaseCharity' not found in ...\models\Charity.php on line 14 generate.php: require_once('bootstrap.php'); Doctrine_Cor...

PHP Doctrine - Integrity constraint violation: 1062 Duplicate entry (Primary key)

I'm loading lots of User and related Group objects from a custom PDO query (using the Doctrine connection => $dbh = Doctrine_Manager::connection()->getDbh(); ). The query involves a cross join which isn't supported in DQL. I'm manually creating the objects and passing the values like so: foreach($pdo as $p) { $u = new U...

how can I find out if a method exist for a doctrine model in symfony?

I have a doctrine model that has a method getSomethingId() and I'm making something of an automated form generator for internal use in the company how can I check if my model has this method? I've tried with php's method_exists but it returns false for every method, what can I do? thanks ...

Doctrine case sensitivity in schema.yml

Doctrine turns my column names into all lower case to improve compatibility. How do I prevent this from happening? users: actAs: [Timestampable] columns: userId: type: integer length: 4 primary: true autoincrement: true or $this->hasColumn('userId', 'integer', 4, array( 'type' => 'integer', ...

Doctrine DQL: Select entities having children/relations to FK table

assuming my setup is Teachers (id, name) Students (id, name, teacher [FK]); how do i select in DQL teachers that have students? i guess it will be something like select t FROM Entities\Teachers t WHERE count(t.students) > 0 but i know count(t.students) > 0 is wrong ... what do i use then? UPDATE now what abt a many to many self...

Doctrine not returing whats the the database until next request

i am starting out with doctrine as created a test page. i have a OneToMany relationship between User and Entry. the problem i am having is on 1st request, it creates the objects, checked the database tables - OK, but the output, doctrine didnt return any entries, it did correctly on users tho ... until i refresh the page again - it added...

Doctrine Regular vs Fetch join

in doctrine, whats the diff between regular and fetch join? i dont get it just by reading the docs. // regular $query = $em->createQuery("SELECT u FROM User u JOIN u.address a WHERE a.city = 'Berlin'"); $users = $query->getResult(); // fetch $query = $em->createQuery("SELECT u, a FROM User u JOIN u.address a WHERE a.city = 'Berlin'"); ...

Doctrine partial objects ... isit for performance?

i learnt that in doctrine i can return partial objects. when i just do print_r() of the result set returned, they seem to still contain the definations for the fields, except that when i echo them out i get nth. so i guess the definations are there but the values are not. is this for performance? eg. in SQL i shld do SELECT field1, field...

Run normal SQL using Doctrine 2

i know i can run DQL and all the fancy ORM features using Doctrine. but for development, maybe i want to just initialize the database with defalt data. say i want to do: truncate the database tables initialize tables with default test data i am thinking it will be good if i can just go to a page say /initData that truncates databas...

Integrating ZF/Doctrine2: Where do i put my Models/Entities & Proxy classes

if i do integrate Zend Framework 1.10 with Doctrine 2 where do i put my Doctrine Models/Entities and Proxies? i thought of the /application or the /library directories. if i do put in the /library directory tho, will it interfere with ZF autoloading classes from there since the classes there will be using PHP 5.3 namespaces vs PEAR style...

How should i find objects in Doctrine? DQL or find()

i wonder whats the correct way of finding objects from the database? i know there's $em->find() $em->createQuery() i guess createQuery will be more like prepared statements thus more secure? how do i set named parameters in DQL? $em->createQuery('select u from \Entities\Users u WHERE u.name = :name'); ...

Doctrine : Hydrate doctrine collection with another model than the FROM clause

Hello, On my application, i frequently do doctrine query like this : $coms = Doctrine_Core::getTable('Comment') ->createQuery('c') ->join('c.article a') ->join('a.Writter w') ->where('w.something = ?', $something); I want to extract the comments from articles with a condition on the writter. Le query start from the Comment Table (...

Doctrine DQL and Namespaces (relative only?)

i noticed that if i try to do soemthing like $query = $em->createQuery('SELECT u FROM \Application\Entities\User u'); i get [Semantical Error] line 0, col 14 near '\Application\Entities\User': Error: Class '\' is not defined. if i do $query = $em->createQuery('SELECT u FROM Application\Entities\User u'); its ok. so the que...