Optimised Company() Setup() Config() and changed method_directory into URL

This commit is contained in:
Deon George
2013-02-12 22:14:59 +11:00
parent 97d894d472
commit 288d974cfa
63 changed files with 422 additions and 346 deletions

View File

@@ -64,7 +64,7 @@ abstract class ORM extends Kohana_ORM {
return (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found'))
->from($this->_has_many[$alias]['through'])
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
->where('site_id', '=', Config::siteid())
->where('site_id', '=', Company::instance()->site())
->execute($this->_db)->get('records_found');
}
@@ -81,14 +81,17 @@ abstract class ORM extends Kohana_ORM {
->from($this->_has_many[$alias]['through'])
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys)
->where('site_id', '=', Config::siteid())
->where('site_id', '=', Company::instance()->site())
->execute($this->_db)->get('records_found');
// Rows found need to match the rows searched
return (int) $count;
}
/** OSB SPECIFIC ENHANCEMENTS **
/** OSB SPECIFIC ENHANCEMENTS **/
// Tables that do not have a site_id column
public static $no_site_id_tables = array('setup','country','currency','language','tax');
/**
* Add our OSB site_id to each SELECT query
@@ -96,8 +99,8 @@ abstract class ORM extends Kohana_ORM {
*/
final protected function _build($type) {
// Exclude tables without site ID's
if (! in_array($this->_table_name,Config::$no_site_id_tables))
$this->where($this->_object_name.'.site_id','=',Config::siteid());
if (! in_array($this->_table_name,ORM::$no_site_id_tables))
$this->where($this->_object_name.'.site_id','=',Company::instance()->site());
return parent::_build($type);
}