cakephp-2.0

How should HTTP Post look like for saving model and associated model data?

断了今生、忘了曾经 提交于 2020-01-17 00:28:37
问题 I am using Cakephp 2.4.5. I have 2 tables with a one-to-many relationship. Table B belongs to Table A. I want a controller in Table A that can save records in Table A and Table B. The controller code should be simple and looks like this; public function add_tableA($id=null) { if ($this->request->is('post')) { $this->layout = null ; $this->TableA->create(); $this->TableA->saveAll($this->request->data, array('deep' => true)); } } My problem comes when trying to send the right HTTP POST format

How I can retrieve and play audio file in cakephp

回眸只為那壹抹淺笑 提交于 2020-01-16 18:32:30
问题 I am uploading audio files using cakephp app. I can move file successfully to folder and can update its path in database too. But I can not retrive that file successfully. server reply with 206 Partial Content AND some times with 304 Not Modified status. can anyone help me to figure out why server respondig with such status? 回答1: You are using chromium. Mp3 is not supported in both chromium and firefox for ubuntu. You can convert mp3 to ogg to play them in chromium and firefox. Or you can

CakePHP file upload errors

谁说胖子不能爱 提交于 2020-01-16 12:01:46
问题 I'm running into this error with my database saying that I have some issue with an array: Database Error Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Array' in 'field list' SQL Query: UPDATE `mongexc_cake214`.`configurations` SET `id` = 1, `username` = 'bill clinton', `profession` = 'president', `description` = 'Ob Jones-D is a Thai Massage and Electronic Acupuncture Specialist. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam, repellat optio officiis neque ea

CakePHP file upload errors

蹲街弑〆低调 提交于 2020-01-16 12:01:03
问题 I'm running into this error with my database saying that I have some issue with an array: Database Error Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Array' in 'field list' SQL Query: UPDATE `mongexc_cake214`.`configurations` SET `id` = 1, `username` = 'bill clinton', `profession` = 'president', `description` = 'Ob Jones-D is a Thai Massage and Electronic Acupuncture Specialist. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam, repellat optio officiis neque ea

Sending email with CakeEmail

若如初见. 提交于 2020-01-14 05:30:12
问题 In my CakePHP application I have an email form I have made myself that opens when an email hyperlink is clicked. How do I then pass the data from the form so that it can be sent using CakeEmail? Sorry, I've tried this for ages and checked through all the documentation on http://book.cakephp.org/2.0/en/core-utility-libraries/email.html, still can't figure it out. Here is my code... email.ctp <?php $this->Html->addCrumb('New Email', '#'); ?> <div id="email_page" class="span12"> <div class="row"

Cakephp REST API remove the necessity of .format

℡╲_俬逩灬. 提交于 2020-01-13 08:23:29
问题 I am working on creating a REST api that will only get and return JSON data. I'm following the cake guide and my default routes are like this: GET /recipes.format GET /recipes/123.format POST /recipes.format PUT /recipes/123.format DELETE /recipes/123.format POST /recipes/123.format However, I really dislike the necessity of using the ".format" (".json" in my case) since I will only ever be accepting json. I feel like there has to be a way to remove this necessity. I could use .htaccess to

Render View from AppExceptionHandler

时光怂恿深爱的人放手 提交于 2020-01-13 03:44:09
问题 I'm working with CakePHP 2.0 and want to handle a ForbiddenException. I've followed the example explained at the CakePHP Cookbook. My exception is now caught at the AppExceptionHandler but I don't know how to move from here. I want to render a relevant View but $this is not available. Does anyone have a starting point for me? Edit: My code so far is identical to the Cookbook example: In app/Config/core.php Configure::write('Exception.handler', 'AppExceptionHandler::handle'); In app/Config

CakePHP passing arguments in Controller::redirect

自古美人都是妖i 提交于 2020-01-12 09:09:59
问题 In controller actions to make redirect I use this: $this->redirect(array('controller' => 'tools', 'action' => 'index')); or this $this->redirect('/tools/index'); And when I pass data with redirect I use this: $this->redirect('tools/index/?myArgument=12'); But I couldn't find how to pass "myargument" by "this-redirect-array" notation. I don't want to use this because some routing issues: $this->redirect(array('controller' => 'tools', 'action' => 'index', "myArgument")); I need something like

CakePHP passing arguments in Controller::redirect

有些话、适合烂在心里 提交于 2020-01-12 09:09:05
问题 In controller actions to make redirect I use this: $this->redirect(array('controller' => 'tools', 'action' => 'index')); or this $this->redirect('/tools/index'); And when I pass data with redirect I use this: $this->redirect('tools/index/?myArgument=12'); But I couldn't find how to pass "myargument" by "this-redirect-array" notation. I don't want to use this because some routing issues: $this->redirect(array('controller' => 'tools', 'action' => 'index', "myArgument")); I need something like

Migrating from Cake 1.3 to 2.0 and beyond - migrate existing, or only use for new?

耗尽温柔 提交于 2020-01-12 06:59:33
问题 I'm nearling completion of my first CakePHP-driven website and just saw they're already working on CakePHP 2.0 (not the stable release yet). My questions: Is it incredibly time consuming to move to a new version of CakePHP (when it becomes the "stable" release that is)? I know they have migration guides, but - I've never used a framework before, so I've never had to migrate anything. Do you migrate your code for existing projects, or leave it as is and use the new stable version for future