开发者

vendor *.php how to call Model function in cakephp 1.3

I have a Cart.php , It have to call some Model function But I try to in my Cart.php

app:import('model','Product') 

It's not work :(

thanks

cart.php is shopping cart class , It's can process shopping ,total ...Class My cart.php is the follow code :

<?php
class Cart_Dao {
    public function find($key){
        return array();
    }

    public function findAll($keyList){        
    }
}
?>


<?
include 'Cart_Dao.php';

class Cart_Dao_Product extends Cart_Dao{
    var $uses = array('Product');

    public function find($key){

         $this->load('Product');      

        return   $this->Product->find('all',array('conditions'=> array('Product.id'=>$key  )));    // I Can't any cakephp Model function in Here       
    }

    public function findAll($keyList) {

        $this->l开发者_如何学JAVAoad('Product');      
        return  $this->Product->find('all',array('conditions'=> array('Product.id'=>$keyList  )));  // I Can't any cakephp Model function in Here
    }
}

?>


The import function help to import any model,controller and Component class into any model,controller and Component file. So you can use the following way

App::import('model','Class_name');
$className=new class_name()

And with the help of $className object you can call any public function of Class_name class.


You can't. App::import is only defined inside Cake app. You will have to include the model file yourself in the vendor file. But I think what you are doing is not right. Are you writing your own vendor file? And what is its purpose? Maybe what you want is a Component or Behavior, not vendor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜