2
голосов
2ответов
9613 просмотров

Cumulative DQL with Doctrine

Im having a hard time working out a proper DQL to generate cumulative sum. I can do it in plain SQL but when it comes to DQL i cant get hold of it. Here is how it looks in SQL: SELECT s.name, p.date_short, p.nettobuy, (select sum(pp.nettobuy) as sum from price pp where pp.stock_id = p...

2
голосов
2ответов
3267 просмотров

PHP Doctrine - loading related records

Using Doctrine PHP If I have a user with a many to many relationship with the model address and each address has a foreign key to a address type (home, office). Doctrine doesn't automatically load the related records for that address type. $user = Doctrine::getTable('User')->findOneById(1); ...

2
голосов
2ответов
1168 просмотров

Doctrine ORM: Models not respecting case

I have a mysql database table called UserDegree, when i try to import back to PHP using Doctrine it generates a model name Userdegree, is there a way to solve this? i really can't find any good doctrine documentation. thanks!

1
голосов
2ответов
1124 просмотров

How to keep two development databases in sync with Doctrine?

(Make this CW if needed) We are two developers working on a web application based (PHP5, ZF, Doctrine, MySQL5). We are working each with a local webserver and a local database. The database schema is defined in a YAML file. What's the best way to keep our database schemas in sync? Here's how w...

1
голосов
3ответов
6316 просмотров

In symfony/doctrine's schema.yml, where should I put onDelete: CASCADE for a many-to-many relationship?

I have a many-to-many relationship defined in my Symfony (using doctrine) project between Orders and Upgrades (an Order can be associated with zero or more Upgrades, and an Upgrade can apply to zero or more Orders). # schema.yml Order: columns: order_id: {...} relations: Upgrades: ...

4
голосов
5ответов
2053 просмотров

What is the best MVC, Doctrine2, Datamapper practice?

I am looking into using Doctrine2 with my Zend Framework setup. I really like the datamapper pattern, mainly because it seperates my domain models with my database. My question is what is the best practice for using Doctrine and DQL with my controllers? controllers uses Doctrine DQL/EntityMana...

6
голосов
6ответов
3639 просмотров

How do i detach a behavior in Symfony/Doctrine?

I have doctrine's softdelete behavior attached to all of my models. Is there a way I can hard delete a particular record? In cakephp I remember detaching the behavior... deleting the record and then re attaching the behavior. Is there something similar in symfony/doctrine ? If so then how do I ...

1
голосов
1ответов
1585 просмотров

Doctrine - own postgres function

how can i call my own function stored in postgres DB, while i am selecting data throught Doctrine_Query::create() ->select('schema.my_function(id)')

3
голосов
2ответов
3615 просмотров

Doctrine: Set model values as array

I've got an array of values I want to update my model with. Doctrine_Access provides a function setArray which is nearly exactly what I need - except it cares about values that don't have fields in the model. I want those to be ignored. A little example. Say we have a User table with the field ...

10
голосов
7ответов
9724 просмотров

Doctrine query memory usage

Doctrine appears to be taking well over 4MB of RAM to execute a single, simple query: print memory_get_peak_usage()." <br>\n"; $q = Doctrine_Query::create() ->from('Directories d') ->where('d.DIRECTORY_ID = ?', 5); $dir = $q->fetchOne(); print $dir['name']." ".$dir['descr...

15
голосов
7ответов
24193 просмотров

Doctrine ORM: drop all tables without dropping database

I have to work with an existing database (not managed with Doctrine) and I want to use doctrine only for new tables in this db. is there a way to tell Doctrine to not drop the entire DB on reload but only the models defined in the yaml file ?

1
голосов
3ответов
3842 просмотров

unit testing with symfony + doctrine + PHPUnit

I'm working with Symfony + Doctrine + PHPUnit, with NetBeans IDE. Here' my current approach to unit testing. setUp() function loads the test fixtures from .yml files tearDown() function delete all data from models. this is done by looping through an array of all my models' names to something li...

2
голосов
1ответов
1472 просмотров

Zend_Validate: Db_NoRecordExists with Doctrine

Hey there, I'm trying to validate a form with Zend_Validate and Zend_Form. My element: $this->addElement('text', 'username', array( 'validators' => array( array( 'validator' => 'Db_NoRecordExists', 'options' => array('user','username') ...

1
голосов
1ответов
2288 просмотров

How to use Doctrine_RawSql for a fulltext search and sorting by relevance

I'm trying to get fulltext searches to be sorted by relevance in a Doctrine_RawSql query. This code will perform the search: $q = new Doctrine_RawSql(); $q->select('{p.*}') ->from('cms_page p') ->where('match(p.content) against (?)', $user_query) ->addComponent('p', 'CmsPage ...

0
голосов
2ответов
973 просмотров

How do I remove a self referencing n:n relation in Doctrine?

I'd like to represent e friend relationship between two users in Doctrine. I am able to create the relationship, but I don't know what's the best way to delete it. I have the following schema: User: columns: name: string(255) relations: Friends: class: User local: user1 ...

1
голосов
2ответов
722 просмотров

Fetching categories and items with Zend Framework

Currently my code below works fine but it's a bit of overkill. In my controller I fetch the categories that have links and all the links in my database. In my view I loop through all the categories and then when I want to add the links under the category I loop through all the links in my databas...

0
голосов
1ответов
1477 просмотров

Finding extra columns in a many to many relationship table

I wish to persist some extra data in a many-to-many relationship by having some extra fields in the association table. For instance, I would like to keep track of what role a user has in a network, such as 'member', 'moderator', 'admin' etc. I would also like to keep track of when he/she joined t...

7
голосов
4ответов
5985 просмотров

Opcode (APC/XCache), Zend, Doctrine, and Autoloaders

I am trying to use either APC or XCache as an opcode to cache my php pages. I am using it with Zend and Doctrine and it's having a problem with the autoloader. If I try with APC, I get the following: Fatal error: spl_autoload() [<a href='function.spl-autoload'>function.spl-autoload</a&...

4
голосов
5ответов
5329 просмотров

PHP Doctrine SoftDelete - Include deleted records?

If I have one of my PHP Doctrine objects act as a SoftDelete, is it possible to include deleted items in the results of certain queries? What I'm looking for is something like this... $q = Doctrine_Query::create() ->select('*') ->from('Test t') ->where('id < ?', 25) ...

2
голосов
2ответов
703 просмотров

Filters in Doctrine

nHibernate has a great feature called filters, so i can create criterias globally for my applications. I'm starting a project in PHP and i need to use an ORM, i'd like to know if Doctrine has a similar feature to manage query conditions. thanks

2
голосов
2ответов
4099 просмотров

Views in Doctrine ORM

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') ...

1
голосов
2ответов
1242 просмотров

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 s...

10
голосов
4ответов
8058 просмотров

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 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 ...

0
голосов
1ответов
167 просмотров

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 in...

3
голосов
2ответов
1448 просмотров

Custom error messages on doctrine validations

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

3
голосов
2ответов
757 просмотров

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 gr...

2
голосов
1ответов
1507 просмотров

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 sen...

1
голосов
1ответов
777 просмотров

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 ...

0
голосов
1ответов
2110 просмотров

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_...

1
голосов
2ответов
493 просмотров

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'); $userTab...