1
TagController創建和保存組件,從不同的控制器不同勢model.non對象錯誤
public function view($id = null) {
if ($this->request->data != null) {
$this->Common->replyarticleAdd($this);
}
}
CommonComponent /*
App::uses('Link', 'Model');
App::uses('User', 'Model');
App::uses('AppController', 'Controller');*/
我想,我應該寫它,它加載模型但不起作用。
ClassRegistry::init('Article');
App::uses('Article', 'Model');
ClassRegistry::init('Article');
App::uses('Article', 'Model');
class CommonComponent extends Component {
var $uses = array('Article');
public function replyarticleAdd($that = null) { // $this error can not re-assign.
debug($that->request->params['pass'][0]);
if ($that->request->params['pass'][0] != null) {
$this->Article->create(); // that is no effect
錯誤Call to a member function create() on a non-object
文件:G:\昴\ XAMPP \ htdocs中\ cakephp的\應用\控制器\元器件\ CommonComponent.php Line: 13 = $this->Article->create();
在控制器創建是確定,但在組分它傾斜。我怎樣才能做到這一點?
由於它的工作原理 –