cakephp-2.3

CakePHP 2.3 - cron dispatcher

冷暖自知 提交于 2019-12-02 06:37:57
问题 I followed instructions from this website: http://colorblindprogramming.com/cronjobs-in-cakephp-2-in-5-steps , but my cronjob does not work. This is my /app/cron_dispatcher.php: <?php if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!defined('ROOT')) { define('ROOT', dirname(dirname(__FILE__))); } if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(__FILE__))); } if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); } if (!defined('WWW_ROOT

CakePHP - paginate and sort 2nd level association

三世轮回 提交于 2019-12-01 08:47:06
I understand that this has been asked 100,000 times but I've pretty much read all 100,000 replies and none of them seem to match what I'm after. I've tried every possible combination (obviously not) and I'm afraid I'm getting beat at something so relatively simple. This is my 2nd Cake project, so I'm by no means an expert. Profile -> BelongsTo -> Store, Store -> BelongsTo -> Region, Region -> HasMany -> Stores Profile .php class Profile extends AppModel { public $belongsTo = array( 'Store' => array( 'className' => 'Store', 'foreignKey' => 'store_id'.... Store .php class Store extends AppModel

CakePHP - paginate and sort 2nd level association

て烟熏妆下的殇ゞ 提交于 2019-12-01 06:23:51
问题 I understand that this has been asked 100,000 times but I've pretty much read all 100,000 replies and none of them seem to match what I'm after. I've tried every possible combination (obviously not) and I'm afraid I'm getting beat at something so relatively simple. This is my 2nd Cake project, so I'm by no means an expert. Profile -> BelongsTo -> Store, Store -> BelongsTo -> Region, Region -> HasMany -> Stores Profile .php class Profile extends AppModel { public $belongsTo = array( 'Store' =>

CakePHP 2.3 - Unit testing User Login

谁都会走 提交于 2019-12-01 05:26:01
I thought I have to ask here some help to my problem. I've spend whole evening with this. I have a login method in UsersController like this: public function login() { if ( $this->request->is( 'post' ) ) { if ( $this->Auth->login() ) { $this->redirect( array( 'controller' => 'reservations', 'action' => 'index' ) ); } else { $this->Session->setFlash( __( 'Login error.' ), 'flashError' ); } } } I trying to test this with PHPUnit , so I can be sure that only valid users can login → after a successful login they will be redirected to a specific page. Here's my testLogin method in

CakePHP 2.3 - Unit testing User Login

為{幸葍}努か 提交于 2019-12-01 03:31:59
问题 I thought I have to ask here some help to my problem. I've spend whole evening with this. I have a login method in UsersController like this: public function login() { if ( $this->request->is( 'post' ) ) { if ( $this->Auth->login() ) { $this->redirect( array( 'controller' => 'reservations', 'action' => 'index' ) ); } else { $this->Session->setFlash( __( 'Login error.' ), 'flashError' ); } } } I trying to test this with PHPUnit , so I can be sure that only valid users can login → after a

file upload in cakephp 2.3

泪湿孤枕 提交于 2019-11-30 08:30:54
问题 I'm new in cakephp and i'm trying to create a simple file upload with cakephp 2.3 here is my controller public function add() { if ($this->request->is('post')) { $this->Post->create(); $filename = WWW_ROOT. DS . 'documents'.DS.$this->data['posts']['doc_file']['name']; move_uploaded_file($this->data['posts']['doc_file']['tmp_name'],$filename); if ($this->Post->save($this->request->data)) { $this->Session->setFlash('Your post has been saved.'); $this->redirect(array('action' => 'index')); }

how to use common function in helper and component In Cakephp

依然范特西╮ 提交于 2019-11-29 10:12:44
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'); public function UsaStateList() { /********/} Helper class LabHelper extends AppHelper { public

CakePHP 2.x sessions behaving inconsistently between local dev and production

柔情痞子 提交于 2019-11-29 08:53:44
I have a CakePHP 2.x site I'm working on which performs as intended locally. Login works, session flash messages work, etc. When I push the code to my staging/prod server it's breaking. Logins no longer work, no session flash messages appear, some controller actions that should be redirecting to /user/login are displaying nothing (empty document), etc. I'm at a loss as to what the problem would be. Based on the issues I'm experiencing and some searching I've done I believe I've ruled out problems like whitespace after the closing ?> in a code-only PHP file (controllers). I'm using DB sessions,

Cakephp 2.3: How to not use 'id' as the label of $belongsTo <select> options

 ̄綄美尐妖づ 提交于 2019-11-28 13:17:02
问题 I run into this dilemma a lot with Cakephp, and I'm prettty sure it's a consequence of my not following/understanding a convention somewhere. In any kind of belongsTo (hasAnd or otherwise), I generally find that since id tends to be the foreign key, it also ends up being what is displayed in dropdown menus, and this is of course semantically useless. Here's an example of what I've generally done; I'm hoping someone can set me straight: (I'm just making up these tables because they make a good

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

ぐ巨炮叔叔 提交于 2019-11-28 13:14:53
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' = lskjaflasi, 'User'.'pincode' = 867567 WHERE 'User'.'id' = 1 My code is if($this->request->data) {$User=$this