doctrine-1.2

Join queries in Doctrine on tables without specified relations

跟風遠走 提交于 2019-12-11 10:27:12
问题 I have two tables that do not have a relation defined with each other in the schema.yml. However, table 1 has a foreign key reference to the primary key of table 2. Clearly, I goofed up by not designing the database well, but now it's mitigation time. I must do a left join between the two tables coupled with a where clause that will retrieve the select rows I want. And to do this, I do: Doctrine_Query::create()->select('t.*, l.lid')->from('Taxonomy t')->leftJoin('t.Cid c') ->leftJoin('c

Zend Framework + Doctrine1.2 project structure with more modules

久未见 提交于 2019-12-11 00:56:01
问题 applications coupled with the realization ZendFramework + Doctrine 1.2 for some time, but now they have their first experience with the use of more modules. I requested a default module is visible to everyone with a certain layout and an admin module with a different layout. So far in my applications I have always used the following structure: /app /application /acls /configs /controllers /forms /layouts /models --> models by doctrine /generated --> base models by doctrine /plugins /views

Preventing Doctrine's query cache in Symfony

对着背影说爱祢 提交于 2019-12-10 12:50:57
问题 In my Symfony/Doctrine app, I have a query that orders by RANDOM(). I call this same method several times, but it looks like the query's result is being cached. Here's my relevant code: $query = $table->createQuery('p') ->select('p.*, RANDOM() as rnd') ->orderBy('rnd') ->limit(1) ->useQueryCache(null) ->useResultCache(null); $result = $query->fetchOne(); Unfortunately, the same record is returned every time, regardless of me passing null to both useQueryCache and useResultCache . I tried

Aggregate values in Doctrine_RawSql queries

Deadly 提交于 2019-12-10 08:14:30
问题 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 avg . 回答1: I've never used Doctrine_RawSql before, but I have done raw SQL queries through Doctrine using either of these two methods: Doctrine_Manager:

How do I find out which version of Doctrine I am running?

孤人 提交于 2019-12-09 05:14:04
问题 Have been using it for a while with CodeIgniter and I can't remember if I installed v2 or just copied the files from another project. Any ideas? 回答1: Check out the file lib/Doctrine/ORM/Version.php, there is a constant in there that shows the version. It's also accessible from a running app but this is easier. 回答2: If you are using the composer to handle dependencies on your project, then you should try with: php composer.phar show --installed OR php composer.phar show -i | grep doctrine And

Doctrine ORM - Prefixing Tables

纵然是瞬间 提交于 2019-12-08 02:15:17
问题 I'm using Doctrine 1.2, and would like to know how I can achieve mysql table prefixes with it. So for instance I would like for our system to be deployed twice on the same database, the first the tables can be prefixed with "one_" and the second can be prefixed with "two_". Anyone got any idea how to accomplish this? I would imagine it is a config setting but I just can't seem to find it. 回答1: I haven't tried it but.. from the docs: $manager = Doctrine_Manager::getInstance(); $manager-

Symfony sfDoctrineGuardPlugin custom login query

时光毁灭记忆、已成空白 提交于 2019-12-07 19:18:29
问题 I use symfony sfDoctrineGuardPlugin to manage authentication for both frontend users and backend users. It's fine, except that I don't want frontend users to be able to login to the backend app. I can setup credentials, but credentials are checked after a user gets authenticated. What I want is to have sigin in form to never validate for a user, that is not in a backend group. How can I do this? 回答1: I think I found a better solution. sfDoctrineGuard plugin has its own post validator that

Doctrine ORM - Prefixing Tables

ⅰ亾dé卋堺 提交于 2019-12-06 14:03:47
I'm using Doctrine 1.2, and would like to know how I can achieve mysql table prefixes with it. So for instance I would like for our system to be deployed twice on the same database, the first the tables can be prefixed with "one_" and the second can be prefixed with "two_". Anyone got any idea how to accomplish this? I would imagine it is a config setting but I just can't seem to find it. I haven't tried it but.. from the docs: $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT, 'one_%s'); Alternatively, you can manually define a table name in

Adding virtual columns to current table in Doctrine?

三世轮回 提交于 2019-12-06 01:27:08
问题 I'm using Doctrine 1.2 with Symfony 1.4. Let's say I have a User model, which has one Profile. These are defined as: User: id username password created_at updated_at Profile: id user_id first_name last_name address city postal_code I would normally get data like this: $query = Doctrine_Query::create() ->select('u.id, u.username, p.first_name, p.last_name') ->from('User u') ->leftJoin('Profile p') ->where('u.username = ?', $username); $result = $query->fetchOne(array(), Doctrine_Core::HYDRATE

Conditional IF statement in a PHP Doctrine 1.2 SET statement

心已入冬 提交于 2019-12-06 00:30:17
I would like find the correct syntax for the SET line: Doctrine_Query::create() ->update('Media m') ->set('m.fallback IF(m.id = ?, 1, 0)', $id) <-- not correct ->execute(); Thanks for any help! I think that could be done with two queries: Doctrine_Query::create() ->update('Media m') ->set('m.fallback', 1) ->where('m.id = ?', $id) ->execute(); Doctrine_Query::create() ->update('Media m') ->set('m.fallback', 0) ->where('m.id != ?', $id) ->execute(); I don't know if it suits you, but at least that will do what you want. May not work out of the box , as I don't have Doctrine 1.2 at hand, so can't