doctrine

Attching a Behaviour to a dynamically created table in Doctrine

How do I programmatically attach a Doctrine Behaviour to a table dynamically created through $conn->export->createTable('MyTable', $definition)? For example, if I have the following code: $definition = array( 'id' => array( 'type' => 'integer', 'primary' => true, 'autoincrement' => true ), 'name' => ...

How to use less memory while running a task in Symfony 1.4?

I'm using Symfony 1.4 and Doctrine. So far I had no problem running tasks with Symfony. But now that I have to import a pretty big amount of data and save them in the database, I get the infamous "Fatal Error: Allowed memory size of XXXX bytes exhausted" During this import I'm only creating new objects, setting a few fields and...

Doctrine: Select elements that are related to one or more items in many-to-many relation

I have a category system that is related many-to-many with posts. How can I select a list of those categories that are related to one or more posts? $q = Doctrine_Query::create() ->from('Category c') ->where('<DONT KNOW WHAT TO WRITE>') ->select('c.name'); ...

Join query in doctrine symfony

I have two tables userdetails and blog question The schema is UserDetails: connection: doctrine tableName: user_details columns: id: type: integer(8) fixed: false name: type: string(255) fixed: false BlogQuestion: connection: doctrine tableName: blog_question columns: question_id: ...

displaying values from join query array

I have used a join query for retrieving value from two tables one is blogquestion and userdetails I wrote this query $this->questions = Doctrine_Query::create() ->select('b.question_id,b.user_id,b.question_title,b.question_tags,b.created_at,u.id,u.name') ->from('BlogQuestion b') ->leftJoin('b.UserDetails u') ->execute(); In ...

Doctrine: Update Join?

Hi, Anyone know how to do an update with a join (i.e. update on two tables in one query) in Doctrine 1.2? I spotted something obscure on a forum that hinted that this is not supported in 1.x but it was about as vague as it comes. Thank you. ...

Model-layer validation in Doctrine, Symfony

Hi there, I have a schema.yml containing something similiar to the following: Character: tableName: characters actAs: { Timestampable: ~ } columns: id: { type: integer(4), primary: true, autoincrement: true } name: { type: string(255), notnull: true, notblank: true, minlength: 3 } I define the minlength of the column n...

Symfony - Delete and reload all database records for each test

Hi there, From the Jobeet tutorial provided in Symfony website, I found out that I can load fixtures data each time I run unit test by using this script: Doctrine_Core::loadData(sfConfig::get('sf_test_dir').'/fixtures'); However, I want to delete and reload all records from database each time I run a unit test. Currently, I'm doing t...

problem with doctrine:build-schema

Hi, im using symfony with doctrine, and Im trying to generate the schema yml file from a db. I get an this error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group' at line 1. Failing Que...

Doctrine issue - Different queries, same results but not with Doctrine

Hi, i'm having a little issue with doctrine using symfony 1.4 (I think it's using doctrine 1.2). I have 2 queries, using raw sql in the mysql console, they produce the same resultset. The queries can be generated using this code : $dates = Doctrine::getTable('Picture') ->createQuery('a') ->select('substr...

Doctrine: textarea line breaks & nl2br

Hi, I'm pulling my hair out with something that should be very simple: getting line breaks to show up properly in text that's returned from the database with Doctrine 1.2 I'm saving a message: $body = [text from a form textarea]; $m = new Message(); $m->setSubject($subject); $m->setBody($body); $m->save(); Query...

How to embed a Form with an m:n (many to many) relation into an other?

I have a genereated form which handles a m:n relation. The generated form overrides the doSave() method to handle the "list". If I embed this Form in an other the special doSave() mothod is never called. The result is that everything works fine except that the m:n relation isn't stored. Do I have to handle the m:n relation manuel? Th...

How do i use findAll method with a class in Doctrine?

Hi, I am a little bit confused with Doctrine class. I created a class and its base class in Doctrine. The class's name is User. so..I created an object of class User. $oUser = new User(); when I try to use findAll method, it does not work. I found the following code on the doctrine documentation. Doctrine_Core::getTable('User')->fin...

How do I sort an internationalized i18n table with symfony and doctrine?

I would like to display a list of records from an internationalized table using sfDoctrinePager. Not all the records have been translated to all the languages supported by the application, so I had to implement a fallback mechanism for some fields (by overriding the getFoo() function in the Bar.class.php, as explained in another post her...

Sensible Doctrine Expression and Zend_Auth setCredentialTreatment()

How to create reasonable expression to store password in database using Doctrine and Zend_Auth::setCredentialTreatment()? I don't want to use md5() and the code must be portable, and with salt. I would call this not easy one to guess: setCredentialTreatment("SHA1(CONCAT(username, SHA1(CONCAT(username, ?)))"); but it is not portable t...

Zend Framework :: ORM - doctrine / propel over Zend_Db_Table

Hi guys, do anyone suggest using an external ORM like Doctrine/Propel over the defualt Zend_Db_Table in Zend Framework ? I think your answers with reasons would be valuable across the ZF community. -DevD ...

Doctrine date in save override / before save

I have Doctrine model with a date field "date_of_birth" (symfony form date) which is filled in by the user all works 100% it saves to the db as expected, however in the model save() method I need to retrieve the value of this field before save occurs. My problem is that When trying to get the date value it returns empty string if its a n...

Can I get a collection of versions for versionable Doctrine record?

So I'm trying to find a way to get a collection of all versions of a versionable Doctrine Record. Is this possible? I could definitely build something that would do it but I wasn't sure if the functionality was already built in. Thanks in advance, John ...

PHP Doctrine: filtering data which is already loaded?

I'm new to Doctrine and ActiveRecord. How should I filter a table after it has been loaded? (i suppose this is preferred over sending multiple queries?) Is this 'good' or 'bad'? class UserTable extends Doctrine_Table { function filterByGroup($group) { $ut = new UserTable(); foreach($this as $u) { if($u-...

Retrive unchanged data

How can i get the Doctrine_Record's unchanged version of field data. For example; echo $user->username; // Prints 'David' $user->username = 'John'; echo $user->username; // Prints 'John' How to get the pre-changed value (David)? ...