doctrine

Doctrine raw sql and prepared statements

I've got a Doctrine_RawSql query using prepared statements. However, they seem to get ignored when the SQL query is generated. But If I leave out the token values, I get an exception about number of bound variables not matching (so it's at least trying to sub them in). If I include these values inline, is Doctrine doing anything behind ...

Doctrine_RawSql custom Select

I having problems to generate a doctrine_rawsql with a custom select. this is my rawsql $distance = glength(linestringfromwkb(linestring(asbinary(GeomFromText('POINT( FLOAT('30') FLOAT('-3')),asbinary({l.point})))) as distance $q->select($distance) ->from('place p INNER JOIN location l ON p.location_id = l.id') ...

How much should doctrine record do?

Hello I'm creating my own CMS and use doctrine for database. Now I wonder, when I crate Post record, how much work should that record do? An example: I have Post -> Categories relation (one to many), should I create separate functions to append categories (to look if Post already has category, etc. ) or should Post do that using acc...

implementing "update if exists" in Doctrine ORM

I am trying to INSERT OR UPDATE IF EXISTS in one transaction. in mysql, I would generally use DUPLICATE KEY ("UPDATE ON DUPLICATE KEY".) I'm aware of many solutions to this problem using various sql variants and subqueries, but I'm trying to implement this in Doctrine (php ORM). It seems there would be Doctrine methods for doing this...

can you begin a mysql statement with "IF"?

I am trying to implement "IF record EXISTS THEN UPDATE ELSE INSERT" in mysql. Specifically, I have to figure out how to do that with Doctrine ORM. One solution using native MySql is to use "ON DUPLICATE KEY UPDATE". This is unfortunately not supported in Doctrine. Another semi solution is to use "REPLACE INTO" syntax. Doctrine sup...

Behind the scenes: How does an ORM "think"?

I'm interested in some of the design behind Rails ActiveRecord, Doctrine for PHP (and similar ORMs). How does an ORM manage to accomplish features like chained accessors and how deep are they typically expected to work? How does an ORM construct queries internally? How does an ORM manage the queries while sustaining the arbitrary natur...

Trouble getting MAMP to work with PDO-MySQL

Problem: Doctrine test application isn't working because of driver issue. Setup: Mac OS X 10.5.7 (not server), MAMP 1.7.2, Doctrine 2.2.1, PHP 5.2.6 I am following the doctrine documentation to try to set up a development environment on my local machine. The output of running the page from the web (through MAMP) shows an empty screen (...

Doctrine migrations in symfony don't update model and forms

I've been testing the Doctrine migrations in symfony and I finally got them to work, but I noticed that these migrations only update the database. The forms and the model are not updated as I expected... Is this normal? If it's normal, is there a way to update the model with the changes made to the db? ...

Use Unix timestamp in Doctrine Timestampable

How do I use Unix timestamps with the Doctrine Timestampable behavior? I found the following code snippet here, but I'd rather not manually add this everywhere: $this->actAs('Timestampable', array( 'created' => array('name' => 'created_at', 'type' => 'integer', 'format' => 'U', 'disabled' => false, 'options' => ar...

Do any ORM frameworks support cross-database/cross-server joins?

I have two servers: Server A: MySql Table A key-a foreign-key-b Server B: MsSql Table B key-b foreign-key-a Presumably I have two objects with methods that handle the relationships: TableA->getRelatedTableB(); TableB->getRelatedTableA(); This is easy to implement in most ORMs. But what if I want to get a large set of objec...

In Doctrine, where should I put my own methods?

Let's say I have a User model. Would I put methods on the model itself, or as a template so I can access it from the user table object? In other words, which is more preferable: $u=new User(); $u->register($username, $password, $email); or $userTable = Doctrine::getTable('User'); $userTable->register($username, $password, $email); ...

Am I doing Doctrine subclasses correctly? Why the Error?

I started to build a POS system in Doctrine. I am getting an order, but I have no clue whether or not I even set up subclasses in the proper way for Doctrine. Here is the model I came up with for line items on an order lineItem: line_total, order_id, type rentLineItem: returned_date_time, item_id, sold buyLineItem: item_id The databa...

How to use a doctrine construct function

Doctrine documentation says you can use public function construct() { ... } as a construct function since __construct can't be overridden. When I place it in my code and put a echo in it public function construct() { echo "constructing..."; } it isn't called during the construction of the object. How is it supposed to be called o...

How do I send a literal parameter via Doctrine to the DB?

If I want to do something like this (notice the expires line): $duration=24; //in hours $reset=new PasswordReset(); $reset->code=md5(uniqid()); $reset->expires="now() + interval $duration hours"; $reset->User=$user; $reset->save(); How can I get Doctrine to NOT quote it before sending it to postgresql? I know I could do this in PHP, ...

PHP data access design patterns to complement an ORM

I've currently got a site that depends on an Active Record pattern using the Doctrine ORM in PHP. I'm generally a fan of this approach - it's very straightforward and works well for managing for simple CRUD apps. But as this site grows, I think my need for more robust domain functionality will grow as well. I was wondering what other kin...

Custom error messages on doctrine validations

I need to modify default error messages of doctrine validations. How can I do this? thanks ...

How do I handle multiple datasources?

I am working on a web application (PHP + Doctrine + MySQL) to sell. The problem is that there is information that the clients will need from my central data source and they will have information that they don't want me to see (financial and such). My Question, what is the best way to get that information to the customer application? My...

Zend Framework 1.9 and Doctrine Integration

I'm trying to setup Zend Framework and Doctrine. There is this previous discussion with ZF 1.8 http://stackoverflow.com/questions/973259/integrate-doctrine-with-zend-framework-1-8-app That discussion doesn't take into account the AutoLoader / Bootstrap System. If I generate an application skeleton with ./zh.sh how would I go about ...

Doctrine queries take over 4 seconds to execute

We're in the last stage of a project and started optimizing it. After a few tests, we realized that most (if not all) of the time spent loading a page, is spent in Doctrine. Out of 5 seconds page load, 3 - 4 seconds are spent only on 2 Doctrine queries. We've enabled query cache on the mysql server and on Doctrine as well as result ca...

Views in Doctrine ORM

Hello. I encountered a problem dealing with views in Doctrine. I have the following view in my database: $q = Doctrine_Query::create() ->select('c.id, c.name, m.id, m.name, m.status, m.modified, m.entered, m.accountid') ->from('Category c') ...