symfony1

How to format dates based on locale?

大兔子大兔子 提交于 2019-12-22 06:03:24
问题 In a template I display the day and month of a specific date : <div class="jour"><?php echo date('d',strtotime($content->getCreatedAt())) ?></div> <div class="mois"><?php echo date('M',strtotime($content->getCreatedAt())) ?></div> This works fine, problem is the month name is in English. Where do I specify that I want the month names in another locale, French for instance ? 回答1: Symfony has a format_date helper among the Date helpers that is i18n-aware. The formats are unfortunately badly

Symfony+Doctrine: Correct YAML syntax for default value of boolean field

孤人 提交于 2019-12-22 05:59:14
问题 I am working on the schema for my Symfony app, and I need to set the default value of two boolean fields to false. However, with all the ways I've tried to do it, when the sql gets generated, it comes out with the default keyword, but no default value after it. my last attempt was: negotiable: type: bool default: "false" complete: type: bool default: "false" but I have also tried default: false , default: 'false' , default: 0 since false is just an alias for 0 in MySQL, and default: '0'

Doctrine Subquery in InnerJoin

本小妞迷上赌 提交于 2019-12-22 03:44:30
问题 i have functional query in MySql: select t.won,e.etot, s.username,s.country,r.points,r.rank FROM sf_guard_user s INNER JOIN marks r ON r.user_id = s.id inner join (select t.user_id,count(t.user_id)as won from topper t group by t.user_id) t on t.user_id=s.id inner join (select e.user_id,count(e.user_id)as etot from exams e group by e.user_id) e on e.user_id=s.id ORDER BY r.rank asc i wrote doctrine code in sfGuardUserTable Class: $q= $this->createQuery('u'); $wq =$q->createSubquery() ->select(

How to internationalize metas such as title in view.yml?

风格不统一 提交于 2019-12-22 00:24:26
问题 I'd like to internationalize the strings of my view.yml, I can't find how to do this. I have a solution that is bad, in my opinion: metas: title: <?php echo sfContext::getInstance()->getI18n()->__('TITLE'); ?> I'd like to find a way to do it without calling "sfConfig::getInstance()". Is it possible? 回答1: Never ever use sfContext for I18n in Configuration-Files! In such a case use the setTitle function in the View (not the controller) <?php $sf_response->setTitle(__('TITLE'));?> 回答2: Since

Lighttpd configuration, . (dots) in my query string cause 404

房东的猫 提交于 2019-12-21 23:47:18
问题 I have an address on my site like so: http://www.example.com/lookup?q=http%3A%2F%2Fgigaom.com%2F2010%2F10%2F10%2Fangry-birds-for-windows7-phone-dont-count-on-it%2F In this example, the dot in the 'gigaom.com' part of the query string is screwing with lighttpd and my rewrite rules. I get a 404 with the dot in, no 404 if I take the dot out. My rewrite rules are below. In case it makes a difference, I'm using symfony 1.4. If anyone could shed some light on this problem it would be much

Rebuild model without loss data in MySQL for Symfony

这一生的挚爱 提交于 2019-12-21 20:22:38
问题 What is the best way to rebuild a model without loss data in MySQL for Symfony? What if I have a big site, and a lot of data in the database and I would like after six months to add few new fields to database? 回答1: You can use migration. Doctine manual Symfony task for migrations Slideshare presentation Slideshare presentation So you need write migrations, migrate, and build your models, forms, etc. 回答2: I suggest you use @denys281 for Symfony1.4 ....in Symfony2 however its VERY simple ...

symfony: setHttpHeader() doesn't work, header() does

旧巷老猫 提交于 2019-12-21 13:08:07
问题 I built a simple action in symfony which generates a PDF-file via wkhtmltopdf and outputs it to the browser. Here's the code: $response = $this->getResponse(); $response->setContentType('application/pdf'); $response->setHttpHeader('Content-Disposition', "attachment; filename=filename.pdf"); $response->setHttpHeader('Content-Length', filesize($file)); $response->sendHttpHeaders(); $response->setContent(file_get_contents($file)); return sfView::NONE; That works fine in my local development

Use of closing database connection in php

此生再无相见时 提交于 2019-12-21 11:05:52
问题 I was always in assumption that it is always a good practice to close database connection, regardless of database/ORM, like mysql_close(), Propel::close() etc. With reference to one of my other question and some other research on Internet, I came to know a surprising face that most people recommends it doesn't really matter if you close connection as connection always gets closed after the request. However I'm finding those answers little difficult to digest. Reason is, why all DB lib, ORM

How to format a getUpdatedAt() kind of date in Symfony?

隐身守侯 提交于 2019-12-21 04:54:10
问题 I'd like to change the formatting of a date in Symfony 1.4 The default one being: <?php echo $question->getUpdatedAt(); // Returns 2010-01-26 16:23:53 ?> I'd like my date to be formatted like so: 26/01/2010 - 16h23 I tried using the format_date helper DateHelper class. Unfortunately the API is rather empty (something really needs to be done about it.) Browsing the helper's source code, I found that a second argument, format, can be passed. I assumed it was using the same syntax as PHP's date

Is there an OpenID 2.0 plugin for Symfony?

天涯浪子 提交于 2019-12-20 20:11:11
问题 I am using sfOpenID plugin for Symfony, which doesn't support OpenID 2.0. That means, for example, that people using Yahoo! OpenID can't login to my site. There is an OpenID 2.0 plugin that works with sfGuard, but I am not using nor planning to use sfGuard. Plus, it requires to install Zend framework, too, which is an overkill in my scenario. So I've got two questions, really: is there another OpenID plugin for Symfony supporting OpenID 2.0? what would be the hack required to make sfOpenID