cakephp-2.0

Safe to use cakephp 3.0 for production?

独自空忆成欢 提交于 2019-12-20 04:50:48
问题 We are starting a new project and it won't be done for 2-3 months. Should I build on version 3.0 since beta 3 was just released or continue with 2.5 and convert over when 3.0 stable is finally out? 回答1: You will need to define what "safe" means to your standards. Safe as to security? I'd say pretty much yes. The project has 10 years on its back, potent programmers, several eyes that scrutinize it since early alphas, so I wouldn't expect anything major to slip there because of the beta status.

Including style sheets in a PDF in cakePHP

半世苍凉 提交于 2019-12-20 03:54:18
问题 I am using dompdf to generate PDFs for some of the views and that is working just fine. The problem is that I cannot include the css files anywhere, and only css included in the <style> tags inside the view itself is taken into consideration. Here is the controller action: public function view_pdf($id=null){ ini_set('memory_limit','512M'); $event = $this->Event->findById($id); $evt_data=new \DateTime($event['Event']['date']); $this->set('event', $event); $this->layout='event'; } Here is the

cakephp - How to handle integrity constraint violation errors

一曲冷凌霜 提交于 2019-12-20 01:46:32
问题 Am at a loss here. I need to know how to handle error messages in case of integrity constraint violations. Meaning i want to show users some meaningful message instead displaying error messages like Error: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails I need to capture these databse errors and just show messages like say The item you are trying to delete is associated with other records How do we deal with this. i

How can I capture output from a CakePHP Shell

£可爱£侵袭症+ 提交于 2019-12-19 10:14:47
问题 Is there any way to capture a shell's output in CakePHP? I've written some shells that generates reports for a CakePHP 2.x application. I'm able to run the shells on a command line and view the output, however, now I'd like to email out the results of those shells. I thought about using another shell as a wrapper and then using $this->dispatchShell('shellname') to capture its output, but it seems dispatchShell just runs the shell and dumps it's output to the CLI. 回答1: To have Shell output to

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

Cakephp 2.0 Authentication using email instead of username

喜你入骨 提交于 2019-12-19 07:30:09
问题 In my view I have: <?php echo $this->Form->create('User', array("controller" => "Users", "action" => "login", "method" => "post")); echo $this->Form->input('User.email', array("label" => false)); echo $this->Form->input('User.password', array("label" => false, 'class' => 'password-input')); echo $this->Form->end(); ?> In my AppController: public $components = array( 'Session', 'Auth' ); function beforeFilter(){ $this->Auth->fields = array( 'username' => 'email', 'password' => 'password' ); }

Cakephp 2.0 Authentication using email instead of username

≡放荡痞女 提交于 2019-12-19 07:30:09
问题 In my view I have: <?php echo $this->Form->create('User', array("controller" => "Users", "action" => "login", "method" => "post")); echo $this->Form->input('User.email', array("label" => false)); echo $this->Form->input('User.password', array("label" => false, 'class' => 'password-input')); echo $this->Form->end(); ?> In my AppController: public $components = array( 'Session', 'Auth' ); function beforeFilter(){ $this->Auth->fields = array( 'username' => 'email', 'password' => 'password' ); }

CakePHP database table, missing datasource default

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 06:30:33
问题 I found this similar question but my problem is different. I moved my CakePHP 2.2 application to another server. There exists no problem before migration. Most of the things works fine after migration. I can reach most of my database tables etc. But when I try to reach one of my table I get this error: "Error 500: Table stats for model Stat was not found in datasource default." To solve this, I checked this folder: "/app/tmp/cache/models" In that folder there is a file for each of my tables

How do I properly save data to the database?

佐手、 提交于 2019-12-18 17:38:27
问题 I normally save new data to the database like this: $this->MyTable->set(array( 'id' => $id, 'code' => $temp_code, 'status' => $status, 'age' => $age, 'location' => $location, 'money' => $money )); $this->MyTable->save(); If the ID already exists in the database I update its corresponding fields like this: $this->Adtweet->id = $id; $this->Adtweet->saveField('code', $temp_code); $this->Adtweet->saveField('status', $status); Is there a better or 'proper' way to do this? When I attempt to enter