コード例 #1
0
ファイル: table.php プロジェクト: ravenlife/Ninja-Framework
 /**
  * Get the identifier for the table with the same name
  *
  * @return	KIdentifierInterface
  */
 public function getTable()
 {
     if (!$this->_table) {
         $identifier = clone $this->_identifier;
         $identifier->name = KInflector::tableize($identifier->name);
         $identifier->path = array('database', 'table');
         $this->_table = KFactory::get($identifier);
     }
     return $this->_table;
 }
コード例 #2
0
ファイル: table.php プロジェクト: janssit/www.reliancelaw.be
 /**
  * Constructor
  *
  * @param	array An optional associative array of configuration settings.
  */
 public function __construct(array $options = array())
 {
     //set the model dbo
     $this->_db = isset($options['dbo']) ? $options['dbo'] : KFactory::get('lib.joomla.database');
     parent::__construct($options);
     // set the table associated to the model
     if (isset($options['table'])) {
         $this->_table = $options['table'];
     } else {
         $table = KInflector::tableize($this->getClassName('suffix'));
         $component = $this->getClassName('prefix');
         $application = KFactory::get('lib.joomla.application')->getName();
         $this->_table = $application . '::com.' . $component . '.table.' . $table;
     }
 }
コード例 #3
0
 /**
  * Method to set a table object attached to the rowset
  *
  * @param	mixed	An object that implements KObjectServiceable, KServiceIdentifier object
  * 					or valid identifier string
  * @throws	KDatabaseRowException	If the identifier is not a table identifier
  * @return	KDatabaseRowsetAbstract
  */
 public function setTable($table)
 {
     if (!$table instanceof KDatabaseTableAbstract) {
         if (is_string($table) && strpos($table, '.') === false) {
             $identifier = clone $this->getIdentifier();
             $identifier->path = array('database', 'table');
             $identifier->name = KInflector::tableize($table);
         } else {
             $identifier = $this->getIdentifier($table);
         }
         if ($identifier->path[1] != 'table') {
             throw new KDatabaseRowsetException('Identifier: ' . $identifier . ' is not a table identifier');
         }
         $table = $identifier;
     }
     $this->_table = $table;
     return $this;
 }
コード例 #4
0
ファイル: document.php プロジェクト: raeldc/nooku-mongodb
 /**
  * Method to set a document object attached to the model
  *
  * @param   mixed   An object that implements KObject, an object that
  *                  implements KIdentifierInterface or valid identifier string
  * @throws  KDatabaseRowsetException    If the identifier is not a document identifier
  * @return  KModelDocument
  */
 public function setDocument($document)
 {
     if (!$document instanceof SDatabaseDocumentAbstract) {
         if (is_string($document) && strpos($document, '.') === false) {
             $identifier = clone $this->getIdentifier();
             $identifier->path = array('database', 'document');
             $identifier->name = KInflector::tableize($document);
         } else {
             $identifier = $this->getIdentifier($document);
         }
         if ($identifier->path[1] != 'document') {
             throw new KDatabaseRowsetException('Identifier: ' . $identifier . ' is not a document identifier');
         }
         $document = $identifier;
     }
     $this->_document = $document;
     return $this;
 }
コード例 #5
0
ファイル: table.php プロジェクト: ravenlife/Ninja-Framework
 /**
  * Get the identifier for the table with the same name
  * 
  * Function catches KDatabaseTableExceptions that are thrown for tables that don't exist.
  *
  * @return  KIdentifierInterface
  */
 public function getTable()
 {
     if (!isset($this->_table)) {
         try {
             $identifier = clone $this->_identifier;
             $identifier->name = KInflector::tableize($identifier->name);
             $identifier->path = array('database', 'table');
             $this->_table = KFactory::get($identifier);
         } catch (KDatabaseTableException $e) {
             //Set the table object to false
             $this->_table = false;
         }
     }
     return $this->_table;
 }