symfony1

Use of Propel's addMultipleJoin

烈酒焚心 提交于 2019-12-23 04:41:31
问题 Following on from a previous question about sub-selects, I have an SQL statement with multiple criteria on the join, like so: SELECT * FROM person LEFT OUTER JOIN group_membership ON person.id = group_membership.person_id AND group_id = 1 WHERE group_membership.person_id is null; Unfortunately, Propel, the ORM I am using with Symfony, doesn't seem very adept using multiple joins, and previous people have tried to hack criteria together to achieve results. Doing this confused Propel, and it

Use of Propel's addMultipleJoin

寵の児 提交于 2019-12-23 04:41:04
问题 Following on from a previous question about sub-selects, I have an SQL statement with multiple criteria on the join, like so: SELECT * FROM person LEFT OUTER JOIN group_membership ON person.id = group_membership.person_id AND group_id = 1 WHERE group_membership.person_id is null; Unfortunately, Propel, the ORM I am using with Symfony, doesn't seem very adept using multiple joins, and previous people have tried to hack criteria together to achieve results. Doing this confused Propel, and it

Join and multiple and conditions

心已入冬 提交于 2019-12-23 04:37:23
问题 I have users table ID NAME 1 John 2 Mike 3 Jack and table with attributes and user IDs USER ATTRIBUTE 1 1 1 2 2 4 I need to select all users with attribute 1 AND 2 (so, in this example user #1 John). Attributes can be more than two. I'v tried SELECT * FROM user u LEFT JOIN attributes a ON u.id = a.user WHERE a.attribute = 1 AND a.attribute = 2 but of course it not working.. 回答1: You will need to use a combination of IN() and GROUP BY ... HAVING to achieve this. Also no need for a join if all

Passing values from action class to model class in symfony

北城以北 提交于 2019-12-23 03:19:18
问题 I have a action class for saving some data to a database.In action class iam getting a id through url.I have to save the id in table. I am getting the id by $request->getParameter('id') I used this code for saving $this->form->bind($request->getParameter('question_answers')); if ($this->form->isValid()) { $this->form->save(); $this->redirect('@homepage'); } in model class i used a override save method to save extra field public function save(Doctrine_Connection $conn = null) { if ($this-

What is the best place for a template that can be used in multiple apps? [closed]

点点圈 提交于 2019-12-23 01:43:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I have 2 apps in my Symfony framework: backend and frontend. is it possible to have templates that are being used by both apps? And if

How to simulate an error 500 in Symfony 1.4?

穿精又带淫゛_ 提交于 2019-12-22 18:16:08
问题 I created an error500.php file in web/errors/ and would now like to test it. I tried to put this line in one of my actions: $this->getResponse()->setStatusCode(500); Unfortunately it looks like it's ignored. Do you guys have any idea of what's happening here? I'm using Symfony 1.4. Edit: Firebug is telling me that the error is actually fired but the page is still loading afterwards. And I'm in the prod env. 回答1: I'm pretty sure throwing any exception should trigger the error page: throw new

How to include multiple php libraries in Symfony?

孤者浪人 提交于 2019-12-22 11:37:11
问题 so, I have some php files in my apps/myprogram/lib folder. e.g. apps/myprogram/lib/myLibA.class.php When I run in my modules/actions/ scripts, and try to use the functions in myLibA, I cannot. because symfony complains that the myLibA class is not defined. do I need to specify anywhere in the symfony framework that myLibA.class.php is a required library? 回答1: Symfony's autoloader looks by default for your classes in the top-level <project>/lib directory. Any file in that directory or below

how to set the selected option in Symfony forms select box

◇◆丶佛笑我妖孽 提交于 2019-12-22 08:46:49
问题 I have a form created with Symfony forms. and in the template i have this selectbox, displayed on the page with the render method. <?php echo $form['field']->render() ?> is it possible to set the selected option of this select box? Or does this have to be done in the class that creates this form? There is the creation of the field done: public function configure() { $this->widgetSchema['field'] = new sfWidgetFormSelect( array("choices" => array('1' => 'test1','2' => 'test2') ) ); } 回答1: yes,

Symfony 1.4: Storing an array in session with SetAttribute

戏子无情 提交于 2019-12-22 08:26:02
问题 I'm wondering if someone knows how to store an array into a user session? This is the method to store a single attribute: $this->getUser()->setAttribute('something', $something); And the documentation says: "User attributes can store any type of data (strings, arrays, and associative arrays)" ... but doesn't say anything more. The API documentation doesn't have a "SetAttributes" or something similarly obvious. Thank you. 回答1: Uh, as I'd written the question out, it became obvious: $something

How to add canonical tag the pages that are derived from same link?

北慕城南 提交于 2019-12-22 08:02:36
问题 I am using symfony 1.0.6. In my site I have two URLs. http://newe4s.com/news/articles/view/033/job-news-and-information and http://newe4s.com/news/articles/view/033/job-news-and-information/graduate/Connections-help-graduates-get-jobs Now, all the new articles are using same layout and both above links get same data from database. Google is reporting duplication of contents since it is getting multiple URLs for same content. When I searched for a solution, I got that using "canonical"