symfony-1.4

Format date in the indexSuccess.php

a 夏天 提交于 2019-12-01 21:03:44
I want to format the created_at field date from the original for something like 03.May.2011 to be shown in the indexSuccess.php and in the showSuccess.php Could you help me? thanks You can make in symfony in your indexSuccess.php and showSuccess.php instead of for example: <?php $value->getCreatedAt() ?> next: <?php echo date('d.M.Y', strtotime($value->getCreatedAt())) ?> You can use other formats. The format of some data absolutely not belongs into controller context - so please use use_helper("date"); echo format_date($myDate); from symfony's date helper in your template (showSuccess.php,

Detecting a mime type fails in php

↘锁芯ラ 提交于 2019-12-01 18:57:56
I have the following PHP code that shows the mime type of an uploaded file. <?php if ($_POST) { var_dump($_FILES); $finfo = new finfo(FILEINFO_MIME_TYPE); var_dump($finfo->file($_FILES['file']['tmp_name'])); } else{ ?> <form method="POST" enctype="multipart/form-data"><input name="file" type="file"><input name="submit" value="send" type="submit"/></form> <?php } The result of uploading somefile.csv with this script is as follows. array (size=1) 'file' => array (size=5) 'name' => string 'somefile.csv' (length=12) 'type' => string 'text/csv' (length=8) 'tmp_name' => string '/tmp/phpKiwqtu'

Symfony: pass parameter between actions (with a redirect)

流过昼夜 提交于 2019-12-01 18:06:35
I am redirecting from one action (executeProcess) to another (executeIndex). I want to be able to pass a parameter/variable along, without using GET (e.g. $this->redirect('index', array('example'=>'true')) ) Is there a way I can directly pass parameters without having it directly displayed in the URL? (e.g. POST). thanks. Why dont you use sessions to store values before redirecting, and then getting them on the other action after you redirected? like: class ActionClass1 extendes sfActions { public function executeAction1(sfWebRequest $request) { [..]//Do Some stuff $this->getUser()-

Trouble creating MySQL query in Symfony containing JOIN and RAND()

冷暖自知 提交于 2019-12-01 14:26:07
How do I do this: SELECT t.id FROM table t JOIN (SELECT(FLOOR(max(id) * rand())) AS maxid FROM table) AS tt ON t.id >= tt.maxid LIMIT 1 in Symfony? (I know how to do basic stuff, but this is too much. $connection = Doctrine_Manager::getConnection()->getDbh(); won't work... Try this: $connection = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); Then: $stmt = $connection->query('SELECT * FROM some_table'); $stmt->execute(); $result = $stmt->fetchAll(); $connection = Doctrine_Manager::getConnection()->getDbh(); $result = $connection->query('SELECT ...'); 来源: https:/

Trouble creating MySQL query in Symfony containing JOIN and RAND()

拈花ヽ惹草 提交于 2019-12-01 13:10:20
问题 How do I do this: SELECT t.id FROM table t JOIN (SELECT(FLOOR(max(id) * rand())) AS maxid FROM table) AS tt ON t.id >= tt.maxid LIMIT 1 in Symfony? (I know how to do basic stuff, but this is too much. 回答1: $connection = Doctrine_Manager::getConnection()->getDbh(); won't work... Try this: $connection = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); Then: $stmt = $connection->query('SELECT * FROM some_table'); $stmt->execute(); $result = $stmt->fetchAll(); 回答2: $connection =

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-

Is it possible to run the task “symfony doctrine build --all” on only one table?

会有一股神秘感。 提交于 2019-12-01 10:30:38
If I run the folowing task, it builds everything and wipes out the database: php symfony doctrine build --all I would like this task to run only for the new table that I've put in schema.yml Is it possible ? 1ed I think you should use migration for that. First, you need to restore the initial state (when schema, model and db are in sync). Remove your changes form schema.yml rebuild your model php symfony doctrine:build --all-classes and import the original database. After that make your changes in schema.yml and run these commands: php symfony doctrine:generate-migrations-diff php symfony

How to query NOT NULL with Doctrine?

℡╲_俬逩灬. 提交于 2019-12-01 02:29:21
I have table Test: Test: id | name 1 | aaa 2 | 3 | ccc 4 | aaa 5 | 6 | ddd I want result where name is NOT NULL: aaa ccc aaa ddd How can i get with: Doctrine_Core::getTable('Test')->findBy('name', NOTNULL??) <-doesnt working and in model with: $this->createQuery('u') ->where('name = ?', NOTNULL ???) <- doesnt working ->execute(); Try this: $this->createQuery('u') ->where('name IS NOT NULL') ->execute(); which is standard SQL syntax. Doctrine doesn't convert Null values into proper sql. Do it in Doctrine way, from query builder and Expr class. $qb = $entityManager->createQueryBuilder(); $result

How to create/use custom classes and helper in symfony 1.4?

∥☆過路亽.° 提交于 2019-11-30 15:16:28
What is the best way to put custom library or helper methods in symfony? I am using doctrine with my project. One place I consider to put is under project_root/lib/vendor/MyClasses/ But if I want to create a class or helper function which will use some core symfony/doctrine methods and return a result then how to do that and where should I put it? I want it to call from different modules to avoid code duplication. As for the custom library part of the question, you might probably want to put your external library into the lib/vendor folder. Since symfony doesn't automatically load everything

Symfony 1.4 deprecated function in php

北城余情 提交于 2019-11-30 10:14:45
Anyone know what is this error? I need help with this Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\sfprojects\jobeet\lib\vendor\symfony\lib\response\sfWebResponse.class.php on line 409 . I'm using xampp 1.8.3 and symfony 1.4 . I couldn't get to step forward because of this a weeke a go :'(. Any help will be appreciated. Thank you. Radamanf In myproject/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 409 protected function normalizeHeaderName($name) { // return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')",