cakephp-2.3

Using virtual fields in cakePHP 2.x

人走茶凉 提交于 2019-12-19 02:50:23
问题 I've read through the documentation and struggled to understand what to do. Also, I've read through the questions here on stackoverflow, and nothing that I tried helped. I've got a drop down that I want to list all employees in the company. The list should be displayed like this: Name Surname (Job Title) In my Model, I have this piece of code: public $virtualFields = array( 'fullname' => 'CONCAT(HrEmployee.name, " ", HrEmployee.surname, " (", HrEmployee.jobTitle, ")")' ); And in my controller

how to use common function in helper and component In Cakephp

落爺英雄遲暮 提交于 2019-12-18 05:54:39
问题 We are familiar with Components and Helpers in CakePHP. I have an ABC Component and XYZ helper and both have same function (around 2000 lines total 4000 lines). there is any way to use same function in Controller and .CTP files. it's not good to use same function 2 time. any method so i can use Component/Helper function in Helper/Component without rewrite ? same method into component and helper >> Component class DATAComponent extends Component { public $components = array('Session', 'THmail'

CakePHP 2.3.8: Calling Another Controller function in CronController.php

百般思念 提交于 2019-12-18 04:15:22
问题 For CakePHP 2.3.8 How can I call Another Controller function in CronController.php Any ideas? 回答1: Below is the code: App::import('Controller', 'Products'); // mention at top // Instantiation // mention within cron function $Products = new ProductsController; // Call a method from $Products->ControllerFunction(); Hope it helps some one ! 回答2: Use the $this->requestAction(); method in your controller action. It's not the most recommended pattern, but it can be useful and can return data or

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual

被刻印的时光 ゝ 提交于 2019-12-17 20:42:43
问题 Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@g.com, 'User'.'phone' = 87665r5, 'User'.'address' = 23lsdhf, 'User'.'location' ' at line 1 SQL Query: UPDATE 'cake'.'users' AS 'User' SET 'User'.'username' = paul, 'User'.'password' = eben, 'User'.'email' = paul@g.com, 'User'.'phone' = 87665r5, 'User'.'address' = 23lsdhf, 'User'.'location' =

After uploading image,create thumb images [closed]

半腔热情 提交于 2019-12-14 04:22:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . i have done image uploading .in my webroot folder. how to upload image in cakephp2.5+ and store it in webroot folder echo $this->Form->input('varbigimg', array('type' => 'file')); this is my add image in view file if i write same in edit.ctp then it will not display name. it will ask browse image again. so i

Make Select Options Static to Dynamic

蹲街弑〆低调 提交于 2019-12-13 08:15:59
问题 Select's Option Values are static & i want it dynamic Right now is static. as per below line <?echo $this->Form->input('intaddressid', array( 'options' => array('add1static,add1static' => 'add1static,add1static', 'addres2static,add2stattic'=>'addres2static,add2stattic'), 'label'=>false, 'empty' => '(Select hotel and time)', 'class' => 'form-control border_none' ) ); ?> My static field output https://www.dropbox.com/s/6133d4e9aorpo33/Selection_047.png?dl=0 And if i set for each then my dynamic

JQuery1.8.0: Sending files from forms via AJAX

早过忘川 提交于 2019-12-13 06:15:50
问题 I develop with CakePHP and initially thought this problem was Cake-related; it wasn't. I've re-written the question to make the answer I received more widely applicable I have a form <form action""> <fieldset> <!---- bunch of fields-----> <input type="file" name="data[Upload][file]" id="UploadFile"> <button id="ajaxUploadSubmit"> Submit </button> </fieldset> </form> And the submit function I've written looks like: $( "#ajaxUploadSubmit" ).click(function() { $.ajax({ url:"uploads/add", data: $

CakePHP redirect routing

被刻印的时光 ゝ 提交于 2019-12-13 01:00:24
问题 In my CakePHP 2.3 application, I want example.com/come/Harry to redirect example.com/myworks/people/Harry . This works, but this connects. Router::connect ('/come/:myname', array('controller' => 'myworks', 'action' => 'people'), array( 'pass' => array('myname') ) ); I need a 301 redirection. I tried this: Router::redirect ('/come/:myname', array('controller' => 'myworks', 'action' => 'people'), array( 'pass' => array('myname') ) ); But it redirected to example.com/myworks/people/ . How can I

Order by doesn't work with custom model find while paginating

爷,独闯天下 提交于 2019-12-12 16:31:13
问题 I've custom find type method in User model: protected function _findStats($state, $query, $results = array()) { if ($state === 'before') { debug($query); $query['fields'] = array('User.id', 'User.username', 'Click.clicks', 'Click.unique', 'Sale.sales_1', 'Sale.sales_2'); $query['joins'] = array( array( 'table' => '(' . $this->__buildSubQueryClicks() . ')', 'alias' => 'Click', 'type' => 'LEFT', 'conditions' => array('User.id = Click.id') ), array( 'table' => '(' . $this->__buildSubQuerySales()

Saving spatial data in CakePHP

谁都会走 提交于 2019-12-12 09:40:03
问题 I have a problem saving spatial data in CakePHP with saveAll(). I really dont want to write the query manually (Handling spatial data in CakePHP) because there are number of models being saved. Also I read this CakePHP and MySQL Spatial Extension but when I try to do the same, $db->expression() returns an stdClass. This is the returned object printed out: stdClass Object ( [type] => expression [value] => GeomFromText('POINT(48.18879 18.527579999999944)') ) If I use this object the way it is