cakephp-2.2

grouping contained models

为君一笑 提交于 2019-12-24 07:13:03
问题 PresentationView hasMany SlideView SlideView model has field duration. The presentation_duration = sum of all SlideView.duration fields from slide views that belong to the presentation. I want to get list (paged) of presentations with presentation_duration for each presentation. So far I am trying like this: $this->paginate['contain'] = array( 'PresentationView' => array( 'SlideView' => array( 'group' => 'SlideView.presentation_view_id', // 'conditions' => array('group' => 'SlideView

Getting names to show in dropdown list with cakephp

我的未来我决定 提交于 2019-12-22 14:42:10
问题 I want to show the names of all our project leaders in a dropdown list. The project leaders are only some of the employees that work in the company. Here are my tables: project_leaders ,----,----------------, | id | hr_employee_id | |----|----------------| | 1 | 18 | '----'----------------' projects ,----,------,-------------------, | id | name | project_leader_id | |----|------|-------------------| | 1 | cake | 1 | '----'------'-------------------' hr_employees ,----,------,---------, | id |

URL Rewrite create subdomain in cakephp

丶灬走出姿态 提交于 2019-12-22 04:18:09
问题 I am using Cakephp framework 2.2.2. I want to create a personalized URL for the user. For example, if a user enters username=pragnesh , then they can access my site like: http://pragnesh.mylocalhost.com, same as in blinksale.com My URL: http://mylocalhost.com/test/users/front_home I want to access it at: http://test.mylocalhost.com/users/front_home My URL: http://mylocalhost.com/test/setting/pages can be accessed at: http://test.mylocalhost.com/setting/pages any URL: http://mylocalhost.com

Triggering event manually in JS Helper CakePHP

♀尐吖头ヾ 提交于 2019-12-21 04:48:40
问题 I stuck in a situation. I am using JS Helper. I used the following code. <?php $this->Js->get('#client_id') ->event('change', $this->Js->request(array('action' => '../ajax/get_client_location_and_process'), array('update' => '#client_location_process', 'async' => false, 'dataExpression' => true, 'method' => 'post', 'evalScripts' => true, 'data' => $this->Js->serializeForm(array('isForm' => True, 'inline' => True)) ) ) ); I want to trigger the change event on page load. If I am using document

CakePHP Error: Unable to configure the session, setting session.auto_start failed

柔情痞子 提交于 2019-12-20 08:59:51
问题 I'm getting this error: Error: [CakeSessionException] Unable to configure the session, setting session.auto_start failed. I'm using Cakephp 2.2.4. EDIT It seems this guy had the same issue: Cakephp Session error on live site and using this if(!isset($_SESSION)) session_start(); inside beforefilter method of AppController fix the error. So my question is: why this happened? Everything was working fine and then suddendly this error appeared. Additionally I've realized that the folder app/tmp

Global variable in controller cakephp 2

人走茶凉 提交于 2019-12-19 09:59:19
问题 What's the way to have a global variable inside a controller? I have tried to do it using beforeFilter but it is not accessible from the others functions. Can it only be done using Configure::read and Configure::write 回答1: you can set variable accessible in any controller in your AppController class AppController extends Controller { public $myGlobalVar; public function beforeFilter() { //this can be anything array, object, string, etc ..... $this->myGlobalVar = "test2"; } } then in your

Global variable in controller cakephp 2

让人想犯罪 __ 提交于 2019-12-19 09:58:13
问题 What's the way to have a global variable inside a controller? I have tried to do it using beforeFilter but it is not accessible from the others functions. Can it only be done using Configure::read and Configure::write 回答1: you can set variable accessible in any controller in your AppController class AppController extends Controller { public $myGlobalVar; public function beforeFilter() { //this can be anything array, object, string, etc ..... $this->myGlobalVar = "test2"; } } then in your

Using PHPExcel in CakePHP

白昼怎懂夜的黑 提交于 2019-12-19 04:39:09
问题 Background Well I tried to ask this question, but it got closed down faster than a horrible security leak. I want to write an excel file using PEAR's Spreadsheet Excel Writer. I Google'd endlessly for a easy way to do this, and finally found a helper that might actually do the job. But it uses PHPExcel, so I'll have to rewrite that script, which is the least of my worries. I just don't want to start now, and then still not be able to get it working. I have also downloaded PHPExcel as required

CakePHP Xml utility library triggers DOMDocument warning

不想你离开。 提交于 2019-12-17 07:52:23
问题 I'm generating XML in a view with CakePHP's Xml core library: $xml = Xml::build($data, array('return' => 'domdocument')); echo $xml->saveXML(); View is fed from the controller with an array: $this->set( array( 'data' => array( 'root' => array( array( '@id' => 'A & B: OK', 'name' => 'C & D: OK', 'sub1' => array( '@id' => 'E & F: OK', 'name' => 'G & H: OK', 'sub2' => array( array( '@id' => 'I & J: OK', 'name' => 'K & L: OK', 'sub3' => array( '@id' => 'M & N: OK', 'name' => 'O & P: OK', 'sub4' =

PHPUnit_Util_Skeleton_Test not found in CakePHP

北城以北 提交于 2019-12-14 02:27:16
问题 I'm able to run my individual tests for each model in a plugin called Agg, but when I try to run a CakeTestSuite, then I get an error. class ModelsTest extends CakeTestSuite { public static function suite() { $suite = new CakeTestSuite('All model tests'); $suite->addTestDirectory(TESTS . 'Case' . DS . 'Model'); return $suite; } } Running that suite generates this error. Fatal error: Class 'PHPUnit_Util_Skeleton_Test' not found in C:\work\zend\cake\Cake\TestSuite\CakeTestSuiteCommand.php on