I have created a namespace outside my models folder in ZF1. Now I want to establish the db connection in the created namespace and for that I want to use the existing model classes.
While creating the object of model class its throwing error "class not found".
below is the sample
Model file:
class Application_Model_Fetchdetails extends Zend_Db_Table_Abstract
{
public function getDetails(){
// model code here to fetch the data from database
}
}
namespace file:
namespace Product\Fetch;
class fetchData {
function __construct() {
$this->Obj = new Application_Model_Fetchdetails();
}
/**
* function will fetch the data
*/
public function getData()
{
try {
$data = $this->Obj->getDetails("col","id='A1'");
return $data;
} catch(Zend_Exception $e) {
echo "error".$e->getMessage(); die;
}
}
its showing error in getData function and in the constructor while creating object saying class not found
Because you namespaced the class with
Product\Fetch
, it is automatically namespacing your model. You need to add the following: