Source for file jSelectorDao.class.php

Documentation is available at jSelectorDao.class.php

  1. <?php
  2. /**
  3. * see jISelector.iface.php for documentation about selectors.
  4. @package     jelix
  5. @subpackage  core_selector
  6. @author      Laurent Jouanneau
  7. @contributor Loic Mathaud
  8. @copyright   2005-2011 Laurent Jouanneau, 2007 Loic Mathaud
  9. @link        http://www.jelix.org
  10. @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  11. */
  12.  
  13. /**
  14.  * Selector for dao file
  15.  * syntax : "module~daoName".
  16.  * file : daos/daoName.dao.xml
  17.  * @package    jelix
  18.  * @subpackage core_selector
  19.  */
  20. class jSelectorDao extends jSelectorModule {
  21.     protected $type = 'dao';
  22.     public $driver;
  23.     protected $_dirname = 'daos/';
  24.     protected $_suffix = '.dao.xml';
  25.     protected $_where;
  26.  
  27.     function __construct($sel$driver$isprofile=true){
  28.         if ($isprofile{
  29.             $p jProfiles::get('jdb'$driver);
  30.             if ($p['driver'== 'pdo'{
  31.                 $this->driver = substr($p['dsn']0strpos($p['dsn'],':'));
  32.             }
  33.             else {
  34.                 $this->driver = $p['driver'];
  35.             }
  36.         }
  37.         else {
  38.             $this->driver = $driver;
  39.         }
  40.         $this->_compiler='jDaoCompiler';
  41.         $this->_compilerPath=JELIX_LIB_PATH.'dao/jDaoCompiler.class.php';
  42.         parent::__construct($sel);
  43.     }
  44.  
  45.     protected function _createPath(){
  46.         global $gJConfig;
  47.         if(!isset($gJConfig->_modulesPathList[$this->module])){
  48.             throw new jExceptionSelector('jelix~errors.selector.module.unknown'$this->toString());
  49.         }
  50.  
  51.         // on regarde si le dao a été redéfini
  52.         $overloadedPath jApp::varPath('overloads/'.$this->module.'/'.$this->_dirname.$this->resource.$this->_suffix);
  53.         if (is_readable ($overloadedPath)){
  54.            $this->_path = $overloadedPath;
  55.            $this->_where = 'overloaded/';
  56.            return;
  57.         }
  58.         // et sinon, on regarde si le dao existe dans le module en question
  59.         $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.$this->_suffix;
  60.  
  61.         if (!is_readable ($this->_path)){
  62.             throw new jExceptionSelector('jelix~errors.selector.invalid.target'array($this->toString()"dao"));
  63.         }
  64.         $this->_where = 'modules/';
  65.     }
  66.  
  67.     protected function _createCachePath(){
  68.         // on ne partage pas le même cache pour tous les emplacements possibles
  69.         // au cas où un overload était supprimé
  70.         $this->_cachePath = jApp::tempPath('compiled/daos/'.$this->_where.$this->module.'~'.$this->resource.'~'.$this->driver.$this->_cacheSuffix);
  71.     }
  72.  
  73.     public function getDaoClass(){
  74.         return 'cDao_'.$this->module.'_Jx_'.$this->resource.'_Jx_'.$this->driver;
  75.     }
  76.     public function getDaoRecordClass(){
  77.         return 'cDaoRecord_'.$this->module.'_Jx_'.$this->resource.'_Jx_'.$this->driver;
  78.     }
  79. }

Documentation generated on Mon, 19 Sep 2011 14:13:33 +0200 by phpDocumentor 1.4.3