doctrine-1.2

Symfony sfDoctrineGuardPlugin custom login query

青春壹個敷衍的年華 提交于 2019-12-05 20:54:06
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? I think I found a better solution. sfDoctrineGuard plugin has its own post validator that checks for an optional callable for user retrival. //app.yml all: sf_guard_plugin: retrieve_by_username

Aggregate values in Doctrine_RawSql queries

╄→尐↘猪︶ㄣ 提交于 2019-12-05 19:27:21
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 . I've never used Doctrine_RawSql before, but I have done raw SQL queries through Doctrine using either of these two methods: Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAssoc("YOUR SQL QUERY HERE"); and $doctrine = Doctrine_Manager:

Why this schema is generating a relation n:m

99封情书 提交于 2019-12-04 05:56:43
问题 I've this schema.yml file (just relevant part): SdrivingMaquina: actAs: Timestampable: ~ columns: idmaquina: { type: integer(8), autoincrement: true, notnull: true, primary: true } idempresa: { type: integer(4), notnull: true } patente: { type: string(12), notnull: true } relations: Empresa: { local: idempresa, class: SdrivingEmpresa, type: one, foreignType: one, foreignAlias: MaquinaEmpresa, onDelete: CASCADE, onUpdate: CASCADE } SdrivingMaquinaEmisor: actAs: Timestampable: ~ columns:

Multiple Query in Doctrine with NAND,NOR,NOT,AND Operators

旧巷老猫 提交于 2019-12-04 02:15:44
问题 I am trying to design a doctrine query and I am new to doctrine but with the help of my other post I come up with a query which works when I run in my Mysql. But I want it to convert the query in Doctrine (2.3) can some one help me in this. MySQL Query: SELECT * FROM user WHERE (`user_name` like '%TOM%' OR `user_name` like '%AN%' and `login_datetime` BETWEEN '2013-01-01 00:00:00' and '2013-02-31 23:59:59') OR NOT ( --NOR (`user_name` like '%PHP%' OR `user_name` like '%BA%' and `login_datetime

Iterate Doctrine Collection ordered by some field

冷暖自知 提交于 2019-12-04 00:07:46
I need something like this: $products = Products::getTable()->find(274); foreach ($products->Categories->orderBy('title') as $category) { echo "{$category->title}<br />"; } I know is it not possible, but... How can I do something like this without creating a Doctrine_Query? Thanks. Chris Williams I was just looking at the same problem. You need to convert the Doctrine_Collection into an array: $someDbObject = Doctrine_Query::create()...; $children = $someDbObject->Children; $children = $children->getData(); // convert from Doctrine_Collection to array Then you can create a custom sort function

Breadcrumb navigation with Doctrine NestedSet

社会主义新天地 提交于 2019-12-02 22:22:21
问题 I have a model that implements NestedSet behaviour: Page: actAs: NestedSet: hasManyRoots: true rootColumnName: root_id columns: slug: string(255) name: string(255) Example fixtures: Page: NestedSet: true Page_1: slug: slug1 name: name1 Page_2: slug: slug2 name: name2 children: Page_3: slug: page3 name: name3 I am looking for the easiest way to implement breadcrumb navigation (trail). For example, for Page_3 navigation will look like this: <a href="page2">name2</a> > <a href="page2/page3>name3

Doctrine INNER/LEFT JOIN two tables

故事扮演 提交于 2019-12-02 16:38:10
问题 I am learning from this Question but facing issues with many operations in between: doctrine 2 query builder and join tables Below is my Questions. I am looking for help in my previous question too.. Thanks for those who helped me in solving the issues. I am creating a big Query in Doctrine 2.3, The operations are not familiar to me.But I learnt with the help of many persons. Currently I am facing issue with Inner Joint between 3 tables. My Joint: SELECT * FROM user AS u LEFT JOIN source AS s

Doctrine INNER/LEFT JOIN two tables

杀马特。学长 韩版系。学妹 提交于 2019-12-02 10:03:35
I am learning from this Question but facing issues with many operations in between: doctrine 2 query builder and join tables Below is my Questions. I am looking for help in my previous question too.. Thanks for those who helped me in solving the issues. I am creating a big Query in Doctrine 2.3, The operations are not familiar to me.But I learnt with the help of many persons. Currently I am facing issue with Inner Joint between 3 tables. My Joint: SELECT * FROM user AS u LEFT JOIN source AS s ON u.user_source_fk=s.source_id LEFT JOIN area AS a ON s.source_node_fk = a.area_id; The above Query

how to make Doctrine_Expression ( doctrine 1.2 ) try to get last 7 days

孤街醉人 提交于 2019-12-02 04:43:19
I try to make this query with doctrine 1.2: $q->where('date > ?', new Doctrine_Expression('DATE_SUB(CURDATE() , INTERVAL 7 DAY)')); but it's not return me any results. any idea ? thanks The reason why it doesn't return anything is because Doctrine escapes the expression - the generated SQL is WHERE (date > 'DATE_SUB(CURDATE(), INTERVAL 7 DAY)') rather than WHERE (l.action_time > DATE_SUB(CURDATE(), INTERVAL 7 DAY)) You could force it to work like this: $date = new Doctrine_Expression('DATE_SUB(CURDATE() , INTERVAL 7 DAY)'); $q->where('date > ' . $date); This isn't the safest option however, as

Symfony 1.4 improve doctrine save() method

China☆狼群 提交于 2019-12-01 10:58:36
问题 I have 500 entries in my db. In my backend I have action. For example: public function executeMyAction(sfWebRequest $request) { // Get some data from table $templates = Doctrine_Core::getTable('SeoTemplates')->findOneByEntity('training'); //Get data from other table(500 items) $trainings = Doctrine::getTable('Training')->getTraining(); // Make some operations with data foreach ($trainings as $training) { $training->setSomeValue1('some_data'); $training->setSomeValue2('some_data'); $training-