symfony1

doctrine how to write WhereIn() with another sql query inside

一笑奈何 提交于 2019-12-24 00:12:32
问题 i have the folowing query in SQL ... where group_id IN (select group_id from alert where monitor_id = 4); I want to write it in Doctrine but i don't know how to add the IN select into WHEREIN() clause ! any idea ? this is what i did $q = $this->createQuery('u') ->select('u.email_address') ->distinct(true) // ->from('sf_guard_user u') ->innerJoin('u.sfGuardUserGroup ug') ->where('ug.group_id IN(select group_id from alert where monitor_id=?',$monitor); $q->execute(); In the sfGuardUserTable

Language switcher, redirect to current page with symfony

笑着哭i 提交于 2019-12-23 18:36:09
问题 What is the best way to do a language switcher in symfony that redirects to the same page in the chosen language? Jobeet simply redirects on the homepage. 回答1: Something like so should do the trick: <?php class myActions extends sfActions { public function executeLanguageSwitch(sfWebRequest $request) { $new_language = $request->getParameter('lang',false); $this->forward404unless($new_language); // You should probably insert stuff here check that the new culture passed in is valid $this-

Symfony Admin Generator Doctrine executeCreate

不问归期 提交于 2019-12-23 12:44:42
问题 Thanks for any help with this, I'm very new to the Symfony framework so just trying to get my head around it. I want to be able to intercept a submitted form from the admin area and modify the data. Here's what I've got so far (in basic form).. /apps/backend/modules/proposition/actions/action.class.php class propositionActions extends autoPropositionActions { public function executeCreate(sfWebRequest $request) { // modify the name $name = $request->getParameter('name'); $name = $name . ' is

doctrine join without relation [duplicate]

眉间皱痕 提交于 2019-12-23 09:56:36
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is this possible to join tables in doctrine ORM without using relations? I have 2 classes Month and Vegetable. They don't have any relation together. I would like to play the SQL : SELECT * FROM month, vegetable In MySQL it works perfectly. I try it like that in Doctrine: $months = Doctrine_Query::create() ->select('m.*, v.*') ->from('month m, vegetable v') ->execute(); When I try it, I get : "vegetable" with an

doctrine join without relation [duplicate]

梦想与她 提交于 2019-12-23 09:55:46
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is this possible to join tables in doctrine ORM without using relations? I have 2 classes Month and Vegetable. They don't have any relation together. I would like to play the SQL : SELECT * FROM month, vegetable In MySQL it works perfectly. I try it like that in Doctrine: $months = Doctrine_Query::create() ->select('m.*, v.*') ->from('month m, vegetable v') ->execute(); When I try it, I get : "vegetable" with an

How to download a file on clicking thefile path using PHP-Symfony?

99封情书 提交于 2019-12-23 05:58:11
问题 I'm creating a website using symfony for blogging. Users can upload their posts to the site. when a user add a file it will save inside web/upload/file_upload and the file path will save in add_post table. When a admin view a add_post table template he can see the path of the downloaded file of each and every user, what i want to do is through this file path download the file. How can i do this? edit 1: Model - Blog_user Module - post Table Structre - table name- Blog_user 1 user_id bigint(20

Symfony: using $this->widgetSchema->setFormFormatterName('list')

自古美人都是妖i 提交于 2019-12-23 05:25:25
问题 im using $this->widgetSchema->setFormFormatterName('list'); this way below to render my form as a list but it is still a table. Any idea? public function configure() { parent::configure(); $this->widgetSchema->setFormFormatterName('list'); } } Any idea? Javi 回答1: to apply a formatter to all the forms use the following line in the setup() of your config\ProjectConfiguration.class.php class ProjectConfiguration extends sfProjectConfiguration { public function setup() { sfWidgetFormSchema:

Symfony business logic

空扰寡人 提交于 2019-12-23 05:12:06
问题 In symfony, I see some coders put business logic in the actions ( controllers that is ), and some coders put it in the models ( Doctrine ). Where should the business logic belong, in the controller or model? What if I didn't use Doctrine, and it was just plain text files? 回答1: Put the business logic in the controller is a bad pratice, the model is home for it. If you don't have Doctrine, you can still have entities, model classes of your own (you should). Your files can be abstracted, and

symfony 1.4 using post validator in New action throws error

你。 提交于 2019-12-23 05:09:25
问题 I have the following action for a form. In the MyForm definition, I added post validator, so I can validate two fields at a time by certain condition. The problem comes when, after passing validation, symfony sends me an error, and also stores null values in a new record in the database. I post my code here... My form just has two fields, and the user most select each of them from two lists to create a new record. By schema restrictions, the combination of both fields is unique. Also, I need

nestedSet - parent/child nodes

对着背影说爱祢 提交于 2019-12-23 04:53:33
问题 I am currently working on outputting a heirarchy in terms of a navigation menu from a nestedSet in Doctrine. I have a number of parents that then have several children. At the moment in time, there are only 2 levels: Parent and Child (no grandchildren). I have the following code: //actions: public function executeShow(sfWebRequest $request) { $this->tree = Doctrine::getTable('Model')->getMenuTree(); } //lib: class ModelTable extends Doctrine_Table { /** * Gets tree element in one query */