cakephp-2.0

Containable to do show deeper data or join table

橙三吉。 提交于 2019-12-13 04:37:51
问题 I have 3 tables: projects, project_reminder_users, project_types. The relations is as follow: Project => belong to => ProjectType hasMany => ProjectReminderUser ProjectReminderUser => belong to => Project ProjectType => hasMany => Project I get all data based on who assigned(ProjectReminderUser) by this $this->Project->ProjectReminderUser->Behaviors->load('Containable'); $this->paginate = array( 'ProjectReminderUser' => array( 'limit' => $limit, 'contain' => array( 'Project' => array(

missing Load plugin [closed]

怎甘沉沦 提交于 2019-12-13 03:48:33
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I already upgrade my cakephp in to the latest one. I also already make some changes due to the migration. But I have this error Missing Plugin Error: The application is trying to load a file from the forums

Form is submitting the Array instead of the wanted field in CakePHP

落花浮王杯 提交于 2019-12-13 03:35:42
问题 I am new to cake and I am trying to learn its philosophy. So I am trying to create a form "Movie" as follows and my database accepts movie_id, title, year, and description. When I run the code it tries to store the "array" as the year input. This is the error I get => movie_id , title , year , description ) VALUES (NULL, 'Movie1', Array, 'some text') THE VIEW: <?php echo $this->Form->create('Movie'); ?> <?php echo __('Add Movie'); ?> <?php echo $this->Form->hidden('movie_id'); echo $this-

How to retrive data in cakephp when change the options of a <select> fields?

a 夏天 提交于 2019-12-13 01:53:58
问题 I am really new in cakephp. I have two controllers named 'questions' and 'answers' . In answers view i have a admin_add.ctp file which includes a select box that show the list of questions. But the problem is when someone select the question then it will show all the answers in different input fields depending on the selected question_id though my admin_add.ctp contains a single input fields. So the fields have to be added when dynamically to the admin_add ctp when someone make a change. My

How to disable cache on logout in CakePHP

三世轮回 提交于 2019-12-13 01:16:24
问题 I am using cakephp 2.3 version. I need to disable cache only when the user logs out. This is to prevent login in case the back button is pressed. But for all other scenarios I don't want to disturb caching mechanism. Right now i use the following function in AppController: public function beforeRender() { $this->response->disableCache(); } But I doubt that it disables the caching process completely. Please help! 回答1: I don't believe the user is automatically logged back into your site if they

virtual field are not working in cakephp

寵の児 提交于 2019-12-13 00:33:29
问题 my controller . $times=$this->Time->find('list',array('fields'=>$this->Time->virtualFields['name_price'] )); $this->set('time',compact($times)); and i added below line in my model Time public $virtualFields = array('name_price' => 'concat(Time.varaddress1, "-", Time.varaddress2)'); and my ctp file is below <?echo $this->Form->input('intaddressid', array( 'options' => $time,'label'=>false,'empty' => '(Select Information)' ,'class' => 'form-control border_none' ));?> but now in output i got

Saving data to User model from Profile model Cakephp

假如想象 提交于 2019-12-12 20:17:43
问题 Iam trying to save value '1' to the 'profile_created' field of my user table when the currently logged in user creates/adds a profile, my current implementation doesnt change this value, any suggestions? Thanks in advance. Current profile adding code: public function add() { if ($this->request->is('post')) { $this->Profile->create(); $this->request->data['Profile']['user_id'] = $this->Auth->user('id'); // code implemented below $this->loadModel('User'); $data = array( 'Profile' => array('user

Cake 2.X retrive data from rawQuery

眉间皱痕 提交于 2019-12-12 20:12:52
问题 As show at CakePHP 2.1.x - Run a query without any models in AppController I have a query, $q = "select id from table where id=123"; $db = ConnectionManager::getDataSource('default'); $qr = $db->rawQuery($q); ok (!), it works... But, how to get my data?? Where the tutorial examples? I need something like $data = $qr->fetchAll() method or $id = getMyData($qr) function. 回答1: I believe this may be the solution or at least a point in the right direction. $q = "select id from table where id=123";

Cakephp: Multiple files upload field sets to required automatically

无人久伴 提交于 2019-12-12 20:05:27
问题 Simple problem, but can't find my solution. I have a gallery upload field with multiple files like this: echo $this->Form->input('Item.gallery.', array( 'label' => __('Gallery'), 'type' => 'file', 'multiple' => 'multiple', )); And i got the validation rules like this: 'gallery' => array( 'fileSize' => array( 'rule' => array('fileSize', '<=', '1MB'), 'message' => 'Image must be less than 1MB', 'allowEmpty' => true, 'last' => false, ), 'extension' => array( 'rule' => array('extension', array(

How do I use datasources in CakePHP 2?

允我心安 提交于 2019-12-12 19:49:47
问题 My MongoDB datasource is located in plugins/mongodb . According to the new class loader in 2.0 I should do this: App::uses('MongodbSource', 'Mongodb.Model/Datasource'); But how do I initiate it? Or is it best practice to use the ConnectionManager? If so, how do I import it? 回答1: If you WANT to use your way and loading this datasource "by hand" and not like Matt said, you would initiate it like this: # /path/to/your/datasource class MongoDbDatasource {...} //check how this class is named!