doctrine

What is the syntax for a multi-table delete on a MySQL database using Doctrine?

Using Doctrine, I am trying to delete records in a single table based on data gathered from multiple tables. 'companies_groups' is an association table linking 'companies' to 'groups'. I want to delete all records in this table linked to a specific company, with the restriction that only 'companies_groups' records linked to a 'public' g...

Doctrine nestedset delete

Hi there, I have some models witch are using Doctrine nestedset feature. I want to add delete functionaly of elements from tree since that is required in my application. I was trying with snippets from documentation but I am getting a very strange error with that code. YAML is here: http://pastie.org/820978 And I am trying with this c...

Doctrine 2 Validations

Hello fellow PHPers! It does not seem like Doctrine 2 has built-in validation. Is this a feature that will be supported in the future? How and where do you validate your Doctrine 2 entities? Guess I have to write my own validation engine for Doctrine. thanks ...

[Doctrine 1.1] Using moveAsLastChildOf to move nodes

For all of you who work with Doctrine, I've a question related to moveAsLastChildOf(). I'm using Doctrine 1.1.6 and Symfony 1.2 I have a nested tree, with lots of elements. I want to delete an element of the tree, so first I have to move all its children (and descendants) to its parent; and then delete it. I do the following: // Get th...

doctrine 2.0 mini tutorial error - The 'class-dir' argument is required for this driver.

i am getting orm:schema-tool => The supplied configuration uses the annotation metadata driver. The 'class-dir' argument is required for this driver. when i try to follow the doctrine 2.0 alpha (i know its alpha) mini tutorial i am on windows 7 x64, wamp 2. i ran php.exe doctrine.php orm:schema-tool --create ...

PHP MVC general question

I'm building a small MVC framewrok for a specific PHP application - using Doctrine as ORM. I'd like to know what it would be the best practice to manage the frontend Menu. My application has 3 menus (horizontal menu, left menu, bottom/footer menu) that can be edited by the site Admin (the menu is stored in a Doctrine NestedSet). Where ...

Getting distance from given coordinates in doctrine geographical records

Hello everybody, I'm developing a Symfony 1.4 project where one of the tables has the Geographical template. The present functions can give the distance between two records, but not between records and given coordinates. How can be implemented such feature in Symfony way? More specific: I need the records ordered by descending distanc...

Ignore duplicates when using INSERT in a Database with Symfony and Doctrine

I have a table CREATE TABLE `sob_tags_articles` ( `tag_id` int(11) NOT NULL, `article_id` int(11) NOT NULL, `id` int(11) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=112 And triing to save an object with Doctrine: $sbTagsArticles = new SobTagsArticles(); $sbTagsArticles->article_id = $pubId; $sb...

Exclude rows with Doctrine ORM DQL (NOT IN)

I'm building a chat application with codeigniter and doctrine. Tables: - User - User_roles - User_available Relations: ONE user have MANY roles. ONE user_available have ONE user. Users available for chatting will be in the user_available table. Problem: I need to get all users in in user_available that hasn't got role_id 7. So I ...

Doctrine: Joining a table doesn't mark the data as loaded

So I have two tables: X and Y. The schema.yml looks like: X: columns: something: { type: string(255), notnull: true } y_id: { type: integer, notnull: true } relations: Y: { onDelete: CASCADE, local: y_id, foreign: id, foreignAlias: xs } Y: columns: something: { type: string(255), notnull: true } And in my XTabl...

In Symfony with the Doctrine ORM how do you default autoincrement columns to integer and not bigint?

It seems that in Symfony 1.4 with Doctrine that when generating auto-increment columns (id) it defaults to bigint. This seems like total overkill and I would just like to default it to an integer instead. The following produces a primary key column named id that is a bigint JobeetCategory: actAs: { Timestampable: ~ } columns: ...

How to "order by" a sfWidgetFormDoctrineChoice in the Admin Generator

I'm using Symfony 1.4 and Doctrine. Let's say I have 2 classes : a Brand and a Product. When I create a new product in the Admin Generator based admin, I'd like to choose a brand from a dropdown list. The Admin Generator is doing that for me, automatically creating a sfWidgetFormDoctrineChoice. The problem is that the brands are order...

Problem storing blob values with Doctrine

Hi, I'm using Doctrine 1.1.2 as my ORM framework in combination with Zend Framework and a MSSQL server back-end. What I am trying to do is to store a blob to the database, but Doctrine is throwing me errors when I try. The column in the database is of type varbinary(max), and the model in Doctrine is configured as follows: $this->hasCo...

What are the options for Doctrine's addColumn() migration method?

The API gives the code as: public function up() { $this->addColumn('table_name', 'column_name', 'string', $options); } but there's no documentation for what can be included in the options array. http://www.doctrine-project.org/Doctrine_Migration_Base/1_2#method_addcolumn ...

Aggregate values in Doctrine_RawSql queries

Is it possible to use aggregate values in Doctrine_RawSql query? Here's what I'm trying to do: $q = new Doctrine_RawSql(); $q->select('{q.*}, AVG(a.value) AS avg'); $q->from('-- complex from clause'); $q->addComponent('q', 'Question'); However, SQL created by Doctrine leaves only columns from table question and omits aggregate value a...

Customizing symfony autogenerated forms

I'm trying to use auto-generated forms in symfony, but I have troubles finding good up to date articles about customization. One of the most important thing is - queries from / updates to several tables. Specificaly, example: there's table tblMain and auto-generated class tblMainForm I use. However, column ForeignKey references to tblAd...

What does actAs and relations mean in doctrine?

I'm totally at a loss with the following schema.yml: JobeetCategory: actAs: { Timestampable: ~ } columns: name: { type: string(255), notnull: true, unique: true } JobeetJob: actAs: { Timestampable: ~ } columns: category_id: { type: integer, notnull: true } type: { type: string(255) } company: { typ...

setBaseQuery not working on Tasks in Symfony

Hi, I'm building a Task in Symfony with Doctrine. I'm getting all the places to make a batch update to a particular field. This has to be done in two languages. I'm using setBaseQuery() to make the JOIN on the query with the language I want. If I do the following in an action, it works without any problem. However, If I do it in a task...

Formatting column results in Doctrine ORM?

I have a timestamp field (using the timestampable template) that I want formatted differently in the results for only one SELECT query. Is there a way to pass in a date/time format string in the Doctrine_Query::create() method? Or maybe there's a way with ->setParams() or ->setOptions? I could format the date in the View using Zend_Da...

How to override preUpdate action to not modify my `updated_at` field in Doctrine?

Hi, I want to disable the automatic behaviour of changing the 'updated_at' field when an object is updated. I want to do it manually; or at least, have the posibility to disable it as wanted. I know I can do this by building my own behaviour as in this great answer. But I was searching for something 'cleaner' modifying a listener of th...