doctrine

How to retrieve a Doctrine record with all relational records?

Hi, I was wondering if there is a way to get a record with all relational data, something like a 'Deep-Fetch' So if a model Child were related to another model Parent, can we fetch Child & then access Child->Parent->name thru a single query? Doctrine today fires a query whenever a relationship is accessed. Is this too costly? does it n...

How do i truncate a post (HTML/Markdown) but not give invalid markup

is there a way i can truncate a post. eg. create a blog summary. while not breaking the markup? 1st i am thinking of HTML if that can be done, how do i work on markdown posts i use PHP/Zend Framework/MySQL/Doctrine2 ...

Doctrine 2: Call to a member function format() on a non-object ... in DateTimeType.php

i have a datatime field /** * Date time posted * @Column(type="datetime") */ private $dtPosted; set to a default value by use of a LifeCycleCallback /** * @PrePersist */ function onPrePersist() { // set default date $this->dtPosted = date('Y-m-d H:m:s'); i am getting Fatal error: Call to a member function forma...

How do I save related objects in many to many relationships?

I have the following schema definition: Usuario: columns: empresa_id: { type: BIGINT, notnull: true } direccion_id: { type: BIGINT, notnull: false } publicidad_id: { type: BIGINT, notnull: true } tipo_id: { type: BIGINT, notnull: true } nombre: { type: string(60), notnull: true } paterno: { ty...

Accessing Many-to-Many Field in Doctrine

This must be simple, but I can't seem to find the answer online nor figure it out through trial and error. I have a class Deck and a class Card which have a many to many relationship with each other. I'm fairly confident that I am adding Cards to Decks correctly (they are being written correctly into the DB, junction table and all), but...

HowTo: display custom error message when unique index fails on object save

I have added an index on a table just to ensure that a set of fields together form a composite unique key (Is this approach correct? or is there a better option with Doctrine?) After having done that, when I try to save an object and the unique constraint fails, a SQL exception is generated. What is the best way to handle this? and to d...

How to install Doctrine 2 on Windows 7?

Hi, What is the best way to install Doctrine 2 on Windows 7? I'm running WampServer 2.0. Thanks ...

DQL How do i query a many to many relationship

if i have a many to many relationship between posts and tags, how do i select posts that contain a specific tag? update: the problem i am having is that because of the where tag.name = 'xxx', only that tag is selected. what i want is to select all posts that have the tag specified, tgt with all their tags, eg. Post 1 -> tag1, tag2 Po...

Doctrine - how to get the SQL INSERT query, in the postSave() event?

I would like to get the exact SQL INSERT query that Doctrine generates when an object's save() method is called. Preferably, I would like to get it in the postSave() event of the model and log it in a txt file. For instance: <?php $user = new User(); // A Doctrine Model with timestampable behavior enabled $user->first_name = 'Manny';...

Doctrine 2 configuration with MySQL

I'm busy with Doctrine2, but I can't get it to work. Everything works fine out of the box with sqlite. But when I try to change the database in the sandbox demo to MySQL I'm getting confused. This is what I did. I created a database, changed the connectionOptions array to: $connectionOptions = array( 'driver' => 'pdo_mysql', '...

Doctrine 2 tables sharing multiple relationships

Is it possible in Doctrine for 2 tables to share more than one relationship based on different columns? Also does Doctrine support a ternary relationship? Thanks in Advance ...

What is the max length of a varchar (doctrine:string) in Doctrine 2 or SQL?

if i use a string type in doctrine 2 (maps to sql varchar), what is the max length i can use? ...

Doctrine : Rollback failed. There is no active transaction.

Rollback failed. There is no active transaction. I am getting the above error when i tried to rollback. I googled the issue and few suggested to disabling the autocommit..... How do we disable autocommit? Is there any other reason for the above error? I am using MYSQL and Zend and my php.ini file loaded the required drivers Thanks i...

doctrine query for chained one-to-many relationships

I have three tables A, B, C. A and B have a one-to-many relationship. B and C have another one -to-many relationship. In another word, each A can have multiple Bs, while each B can have multiple Cs. Now I want to do a query for a given record of A, to get all the related Bs which have related Cs. In another word, for a given a, which is...

Prevent specific Connections from beeing dropped by doctrine:build Task

Hello everyone, i've 2 connections in my databases.yml file, one contains the whole i18n Stuff for the project, the other one regular application Data which shall be erased from time to time during development. What i'm looking for is a way to keep the database with my i18n Data untouched during build, while the other one gets's droppe...

Autocompete using phpDoc

I heard you can use phpDoc to help IDE with autocomplete. Can someone show how to use it with Doctrine? For example, I have a JobTable class that extends Doctrine_Table with a bunch of methods and would like to have autocompletion when i type: Doctrine::getTable('Job')-> ... Is it possible? Is there a way to do it without phpDoc? ...

Auto update sluggable field with Doctrine

Hello everyone, I'm using CodeIgniter with Doctrine in a project. One of my models has the Sluggable behavior. The slug is created according to another field X when the object is saved. I was wondering if there was a way to automatically update this slug field when the X field is updated. At the moment, if I update the X field, the slu...

symfony : Problem 'Integrity constraint violation' with primary key

Hello, When I want to create a new object with one of my form, Doctrine take me an error : Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' Creating worked previously, but I don't know what I have change to have an error now. My schema for ID : Logement: connection: doctrine actAs: [Timestampable] ta...

symfony : How can I optimize Doctrine query ?

Hello, I want to know how I can optimize my Doctrine queries because some of my queries are too long. I don't want a method particularly to my querie, but common methods I can apply to all requests, because I don't find information about this. ...

Referencing variable set by application in models (a good idea?)

i am using zend framework 1.10 with doctrine 2. i wonder if in my (doctrine) model class, isit a good idea to reference a variable set by my application (bootstrap.php, variable stored in Zend_Registry, i think its something like a global variable) what i want to access is the doctrine entityManager. also i want the id of the logged in...