如何在内部使用doSearch()
函数来调用Titles
控制器中的getTitles()
函数?
In CakePHP, it seems like a lot of functions can take their arguments as nested, multidimensional arrays, or as dotted strings: $this->MyModel->contain(array( Something , Something.Else , ...
如何在内部使用doSearch()
函数来调用Titles
控制器中的getTitles()
函数?
简短的回答是,你不应该这样做。您应该将其转移到您的标题模型中,或者将其放在组件或帮助程序中以供重用。
如果你确定你想直接调用控制器,Cake确实提供了一个方法
http://book.cakephp.org/2.0/en/controllers.html#Controller::requestAction
没有理由去另一个控制器。
控制器应该主要从模型中调用方法。所以应该有一个包含您需要的方法的标题模型。
如果您需要更多帮助,请发布您的代码。
因此,答案是:
$this->requestAction( /controller/action/params );
制作想要重用组件的功能并不总是像Cakephp那样工作良好,没有引入Models和find(),并且设置->$另一种方法是将您的核心功能作为核心功能,然后返回$results,将此功能调用为$results=$this->;函数within_controller();因此您可以通过这种方式重用功能。我有时在尝试使用组件时也会遇到一些错误,在Cakephp中,组件非常适合使用独立的php脚本和代码。
In CakePHP, it seems like a lot of functions can take their arguments as nested, multidimensional arrays, or as dotted strings: $this->MyModel->contain(array( Something , Something.Else , ...
I ve got a cakephp app that I m trying to get to serve up the Pages::404 function (and corresponding view) whenever Cake encounters any error (missing controller, action, etc). What s the best way to ...
I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...
I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...
I am writing a CakePHP 1.2 app. I have a list of people that I want the user to be able to filter on different fields. For each filterable field, I have a drop down list. Choose the filter ...
In my CakePHP app, I m pulling in the results of a table called Timesheets . This table has an athlete_id and a few split times for a race. I need to do some calculations on one athlete s times ...
How would I represent the following in a CakePHP model? Product ======= product_id .... Cart ==== cart_id .... Carts_Products ============== cart_id product_id quantity
I am a beginning Cake user and trying to do some work on an already existing application. Running into a problem when I create a new controller. I have created StoreController and when I try to call ...