I want to be able to seperate my database tables, as i dont want the table getting too big.
when a company registers on my website i would like them to use there own db space.. so in zend i have my model file that connects to db but it will not allow me to make it dynamic. please could some one help me..
db model file to connect to departments that belong to a company
public function company_id(){
$auth = Zend_Auth::getInstance();
$company_id = $auth->getIdentity()->comp;
return $company_id;
}
protected $_comp = $this->company_id();
//$name = '2_departments';
protected $_name = $this->_comp."_departments";
protected $_rowClass = 'Application_Model_Department';
when i use the above code it crashes without error. But if manually code it in and create a php file for every db table it will work file.
protected $_name = "2_departments";
protected $_rowClass = 'Application_Model_Department';
if someone could assign that would be awesome.
I have another example
Main class
class Application_Model_Table_Departments extends Teabag_Db_Table {
public function fetchdepartments() {
$auth = Zend_Auth::getInstance();
$company_id = $auth->getIdentity()->comp;
$select = $this->select()
->from(array('deps'=>$this->_name), array('*'))
->where('deps.is_deleted = 0');
return $this->fetchAll($select);
}
}
but then ive extented the class with two other files custom1department.php custom2department.php
class Application_Model_Table_Custom1Departments extends Application_Model_Table_Departments {
protected $_name = "1_departments";
protected $_rowClass = 'Application_Model_Department';
}
and
class Application_Model_Table_Custom2Departments extends Application_Model_Table_Departments {
protected $_name = "2_departments";
protected $_rowClass = 'Application_Model_Department';
}
any ideas on how to make a class dynamic and the class name dynamic?