cakephp

cakephp remove controller name from url

爷,独闯天下 提交于 2020-01-07 07:36:44
问题 i am working on a cakephp 2.x .. right now i have a function called forgetpassword and resetpassword in my userscontroller .. i am sending an email to a user.. i am sending a url like this ..this code is written in the forgetpassword function $url = Router::url( array('controller'=>'users','action'=>'resetpassword'), true ).'/'.$key.'#'.$hash; and i receive this url in my inbox like this https://www.myweb.com/resetpassword/y2273727372jhgdfjjd2434dff#23232323 when i click the url which is on

Foreign key definition in cakePhp: Lazy loading?

你说的曾经没有我的故事 提交于 2020-01-07 07:11:07
问题 I'm starting to use cakePhp to make a small website. I defined relationship between table, and I want to know: will those related data loaded every time? Because depending of the current view, some linked table will never be used, and actually they are queried every time. It's a big cost for what it brings to us, no? So how to have this kind of relationship and activate it only when we need it? Some kind of lazy loading which loads the related table only if I need it? 回答1: Cake facilates to

cakephp3 load plugin for special prefix

主宰稳场 提交于 2020-01-07 06:43:01
问题 I have Cakephp 3 application and i want to load this plugin and the event listener below it just for admin prefix. ( not the entire project ) . how can i achive this? this is my config/bootstrap.php where i load this plugin . (I load these at end of the file ) ... Plugin::load('Josegonzalez/Upload'); \Cake\Event\EventManager::instance()->on(new \App\Controller\Event\AppEventListener()); i want these to line only run on admin prefix 回答1: You can't conditionally run code based upon routing

Cakephp 1.3 HABTM issue! :D

北城以北 提交于 2020-01-07 06:25:17
问题 Hey, im having this issue with cakephp, bascially i have a Has And Belongs To Many (HABTM) model relationship. My models are Categroy and Project bring all project data is fine, it comes out as [0]['Project'] , [1]['Project'] ...etc but when i use the relationship and pull out projects with certain categories in the categories controller i get these tpye of results [0] (all project data in [0] instead of [0]['Project']), [1] (project data and related model info) this is really messing my code

CakePHP Query - Conditional Based on Contain Field

折月煮酒 提交于 2020-01-07 05:37:09
问题 I am developing a system that holds reports from customer's computers and displays failures in a list. I am attempting to write a query that locates all systems that have currently failed or have failures in the past. My model for Computers has a field that says last_report_pass that allows me to quickly find computers that failed on the current day. My Reports are associated with a computer ID and has a field called status that says whether it was a pass or fail. I am attempting to write a

CakePHP find with “contain”

十年热恋 提交于 2020-01-07 05:28:19
问题 My model has many relationships to other tables/models, if i use contain parameter, for example to order by field in results of one model, all other tables in query results are missing, and must manually written in contain parameter, how can i get all related models data without manually writing it? $data = $this->Cv->find('first', array( 'contain' => array('Cv_experience' => array('order' => 'Cv_experience.start_year desc')))); 回答1: It sounds like you've been relying on the Model's recursive

Sending Encrypted Email S/MIME with PHP

久未见 提交于 2020-01-07 04:49:09
问题 I have been looking a lot online but I didn't find an answer, is it possible to send encrypted emails S/MIME using PHP? if it is, how? (im using cakephp 2.x) Thank you very much in advance 回答1: I managed to find a solution to this using PHPMailer, It applies to regular PHP as well. It will sign and encrypt the email, I couldn't find a way to do both with PHPMailer (sign and encrypt) only sign so I added some code to class.phpmailer.php. It stills need to add some error handling in case of an

getting value from string array in cake php

妖精的绣舞 提交于 2020-01-07 03:56:09
问题 If I have this output of an array : $array_to_delete = [ (int) 3 => (int) 4, (int) 4 => (int) 5 ] And i want to get 4 and 5 and so on at where condition , Like that : $warehouseItemsData = $this->WarehouseEmployers->WarehouseItems->find() ->where(['id', $array_to_delete]) ->all(); How can i do that ? in cake php 回答1: use IN $warehouseItemsData = $this->WarehouseEmployers->WarehouseItems->find() ->where(['id IN', $array_to_delete]) ->all(); 来源: https://stackoverflow.com/questions/45481414

CakePhp 3.x Continue session from out of the app

笑着哭i 提交于 2020-01-07 03:51:23
问题 I'm building a new version of a website in cakephp 3.x . Since I rebuild in phases,I need interaction between parts of the new site and the old site. The best way to do this at this moment is with the use of $_SESSION . My problem is that the cakephp part makes a new session instead of using the active one from the native PHP part. It writes it next to it in the same folder. this is my app.php setting in cakephp 'Session' => [ 'defaults' => 'php', 'timeout' => '2000', 'ini' => [ 'session

How to prevent showing/receiving untranslated content?

喜你入骨 提交于 2020-01-07 03:48:29
问题 This is my Distance Cell public function display() { $this->loadModel('Distances'); $distances = $this->Distances->find('all',[ 'order' => 'Distances.id ASC', ])->toArray(); $this->set('distances',$distances); }} Problem, if content is not yet translated and stored in db, original untranslated content is displayed on the page. How to prevent this, and show only translated content in current language? 回答1: The onlyTranslated option This is unfortunately not documented yet, but the Translate