symfony-1.4

Ignore duplicates when using INSERT in a Database with Symfony and Doctrine

余生颓废 提交于 2019-12-06 00:12:54
问题 I have a table CREATE TABLE `sob_tags_articles` ( `tag_id` int(11) NOT NULL, `article_id` int(11) NOT NULL, `id` int(11) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=112 And triing to save an object with Doctrine: $sbTagsArticles = new SobTagsArticles(); $sbTagsArticles->article_id = $pubId; $sbTagsArticles->tag_id = $tagId; $sbTagsArticles->save(); But if record exists with the same $pubId and $tagId new record will be insertet with new PK. How to do INSERT

Orange Hrm 3.1- adding new menu title to tab

a 夏天 提交于 2019-12-05 21:51:44
i m new to symfony framework , i m using orangehrm-3.1.1 i have added a new menu title in the second level tab , but i dont know how to navigate to the particualar href link. Please help me out with the steps. Here is how I add menu item via database. To add a menu in orangehrm there are 3 tables you should check: ohrm_screen ohrm_menu_item (the menu hierarchy) ohrm_user_role_screen (the user role permissions to specific screen) First, add your link into ohrm_screen , specify your module_id and action_url (Check the module_id in ohrm_module ). After that add the screen into ohrm_menu_item

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

implementation of ajax status check

↘锁芯ラ 提交于 2019-12-05 19:18:55
I am battling with race condition protection in PHP. My application is written in symfony 1.4 and PHP locks session data until a page completes processing. I have a long running (~10 second) login script and I want to display a progress bar showing the user what is being done while they wait. (I want to actually display what is being done and not use a standard [faux] loading bar.) Whenever a script calls session_start() , PHP locks that user's session data until that script completes. This prevents my status check ajax calls from returning anything until the longer running script completes.

Force Exclude files from PHPUnit Code Coverage

强颜欢笑 提交于 2019-12-05 13:50:44
问题 Is it possible to forcefully exclude a folder from PHPUnit's code coverage? Problem I've got is, that I have a Symfony 1.4 project, which has folders at ./lib/vendor/symfony/* . I want to exclude anything that's inside ./lib/vendor/* - recursively. Now, I want to exclude them whether they were covered implicitly by my tests or not, i.e. I never want to see these folders. So, I've added this bit to my phpunit.xml config file, but it doesn't seem to exclude these folders, no matter what I do:

Execute custom SQL in symfony

纵然是瞬间 提交于 2019-12-05 01:41:57
问题 I'm trying to execute some custom SQL to retrieve some model objects in a Symfony application. I found a tutorial on the web that said something like this would allow me to execute the query although not populate the models (populating the model isn't a major issue, it's just for read only data). $pdo = Doctrine_Manager::getInstance()->connection()->getDbh(); $pdo->prepare("SELECT * from something complicated"); $pdo->execute(); $this->sensorReadings = $pdo->fetchAll(); But I'm getting an

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

我只是一个虾纸丫 提交于 2019-12-04 21:20:34
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? 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'));?> Since include_title() does not translate what it finds in view.yml, I made this very simple function in my custom helper:

Copy a Doctrine object with all relations

一笑奈何 提交于 2019-12-04 13:32:07
I want to copy a record with all his relations. I'm trying with: $o = Doctrine::getTable('Table')->Find(x); $copy = $object->copy(); $relations = $o->getRelations(); foreach ($relations as $name => $relation) { $copy->$relation = $object->$relation->copy(); } $copy->save(); This code doesn't works, but I think it's on the way. I never could get the deep copy function to operate correctly. I manually coded a deep copy function for one of my models like this public function copyAndSave () { $filters = array('id', 'created'); $survey = $this->copy(); $survey->Survey_Entries = new Doctrine

Rebuild model without loss data in MySQL for Symfony

倖福魔咒の 提交于 2019-12-04 13:10:19
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? denys281 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. I suggest you use @denys281 for Symfony1.4 ....in Symfony2 however its VERY simple ... just use the command : php app/console doctrine:schema:update --force It compares what your database

Rename “web” folder in Symfony 1.4

╄→гoц情女王★ 提交于 2019-12-04 10:06:26
I want to rename the "web" folder to "html" in symfony 1.4, unfortunately searching for documentation on this has lead me nowhere except for how this would be accomplished in 1.0, which does not seem to be working. Firstly, you don't have to rename it. You can just create a symbolic link (unless you're running windows): ln -s web html If you still want to change the web folder name than you could do it in your project's ProjectConfiguration class by overloading setRootDir(): class ProjectConfiguration extends sfProjectConfiguration { public function setRootDir($rootDir) { parent::setRootDir(