예제 #1
0
 /**
  * Loads associated objects into appropriate objects.
  */
 function _loadAssociatedObjects()
 {
     for ($i = 0, $count = count($this->_relationships); $i < $count; ++$i) {
         $mapper =& Piece_ORM_Mapper_Factory::factory($this->_relationships[$i]['table']);
         if (Piece_ORM_Error::hasErrors()) {
             return;
         }
         $this->_associatedObjectLoaders[$this->_relationships[$i]['type']]->loadAll($mapper, $i);
         if (Piece_ORM_Error::hasErrors()) {
             return;
         }
     }
 }
예제 #2
0
 /**
  * Removes associated objects from a table.
  *
  * @param array $relationship
  */
 function delete($relationship)
 {
     if (!array_key_exists($relationship['mappedAs'], $this->_subject)) {
         return;
     }
     if (!is_null($this->_subject->{$relationship}['mappedAs']) && !is_object($this->_subject->{$relationship}['mappedAs'])) {
         return;
     }
     $mapper =& Piece_ORM_Mapper_Factory::factory($relationship['table']);
     if (Piece_ORM_Error::hasErrors()) {
         return;
     }
     $mapper->delete($this->_subject->{$relationship}['mappedAs']);
 }
예제 #3
0
 /**
  * Creates an object from the metadata.
  *
  * @param string $mapperName
  * @return stdClass
  * @throws PIECE_ORM_ERROR_INVALID_OPERATION
  */
 function &createObject($mapperName)
 {
     if (!$GLOBALS['PIECE_ORM_Configured']) {
         Piece_ORM_Error::push(PIECE_ORM_ERROR_INVALID_OPERATION, __FUNCTION__ . ' method must be called after calling configure().');
         $return = null;
         return $return;
     }
     $mapper =& Piece_ORM_Mapper_Factory::factory($mapperName);
     if (Piece_ORM_Error::hasErrors()) {
         $return = null;
         return $return;
     }
     return $mapper->createObject();
 }
예제 #4
0
 /**
  * Removes associated objects from a table.
  *
  * @param array $relationship
  */
 function delete($relationship)
 {
     $property = Piece_ORM_Inflector::camelize($relationship['through']['referencedColumn'], true);
     if (!array_key_exists($property, $this->_subject)) {
         return;
     }
     $mapper =& Piece_ORM_Mapper_Factory::factory($relationship['through']['table']);
     if (Piece_ORM_Error::hasErrors()) {
         return;
     }
     $mapper->executeQuery("DELETE FROM {$relationship['through']['table']} WHERE {$relationship['through']['column']} = " . $mapper->quote($this->_subject->{$property}, $relationship['through']['column']), true);
 }