public function testMe() { $I = $this->tester; $sql = "INSERT INTO `reg_schema_property_element` (`id`, `created_at`, `updated_at`, `deleted_at`, `created_user_id`, `updated_user_id`, `schema_property_id`, `profile_property_id`, `is_schema_property`, `object`, `related_schema_property_id`, `language`, `status_id`) VALUES (110489,'2014-01-19 03:45:21','2014-01-18 22:45:21',NULL,422,422,14603,1,1,'respondentOf',NULL,'en',1);"; $data = $I->getArrayFromSql($sql); //$I->haveInDatabase('reg_schema_property_element', $data); /** @var SchemaPropertyElement $element */ $element = SchemaPropertyElementPeer::retrieveByPK(110489); $element->importId = $this->importId; $element->updateReciprocal("deleted", 422, 81); }
function run_import_repair($task, $args) { //xdebug_break(); if (count($args) < 1) { throw new Exception('You must provide a batch ID.'); } $batchId = $args[0]; //get the import history for the batchid $criteria = new Criteria(); $criteria->add(\FileImportHistoryPeer::BATCH_ID, $batchId); $batch = \FileImportHistoryPeer::doSelect($criteria); if (empty($batch)) { throw new Exception('Not a valid batch ID.'); } $criteria = new \Criteria(); $criteria->add(\ProfilePropertyPeer::NAME, "isSameAs"); /** @var $profileProperty \ProfileProperty */ $profileProperty = \ProfilePropertyPeer::doSelectOne($criteria); $sameasId = $profileProperty->getId(); //for each one in the list /** @var $history FileImportHistory */ foreach ($batch as $history) { //get result array $results = $history->getResults(); $rows = $results['success']['rows']; $userId = $history->getUserId(); //for each row foreach ($rows as $row) { //get the references /** @var $property \SchemaProperty */ $property = \SchemaPropertyPeer::retrieveByPK($row['id']); /** @var $ref \SchemaProperty */ $ref = \SchemaPropertyPeer::retrieveByUri($property->getParentUri()); if ($property and $ref) { $property->setIsSubpropertyOf($ref->getId()); $property->saveSchemaProperty($userId); } //update the parent property if (isset($row['statements'])) { //for each statement foreach ($row['statements'] as $statement) { //get the references if ($sameasId != $statement['propertyId']) { /** @var $ref \SchemaProperty */ $ref = \SchemaPropertyPeer::retrieveByUri($statement['object']); } else { //ref = the parent $ref = $property; } /** @var $propertyElement \SchemaPropertyElement */ $propertyElement = \SchemaPropertyElementPeer::retrieveByPK($statement['id']); if ($propertyElement and $ref) { $propertyElement->setSchemaPropertyRelatedByRelatedSchemaPropertyId($ref); $propertyElement->save(); } } } } } }
/** * Get the associated SchemaPropertyElement object * * @param Connection Optional Connection object. * @return SchemaPropertyElement The associated SchemaPropertyElement object. * @throws PropelException */ public function getSchemaPropertyElement($con = null) { if ($this->aSchemaPropertyElement === null && $this->schema_property_element_id !== null) { // include the related Peer class include_once 'lib/model/om/BaseSchemaPropertyElementPeer.php'; $this->aSchemaPropertyElement = SchemaPropertyElementPeer::retrieveByPK($this->schema_property_element_id, $con); /* The following can be used instead of the line above to guarantee the related object contains a reference to this object, but this level of coupling may be undesirable in many circumstances. As it can lead to a db query with many results that may never be used. $obj = SchemaPropertyElementPeer::retrieveByPK($this->schema_property_element_id, $con); $obj->addSchemaPropertyElements($this); */ } return $this->aSchemaPropertyElement; }
if (!isset($schema)) { if ($schema_property) { $objectId = $schema_property->getId(); $schema = $schema_property->getSchema(); } } break; case 'schemapropel': $showBc = true; $showSchemaBc = true; $showSchemaPropBc = true; $showSchemaPropelBc = true; if (!isset($schema_property_element)) { $id = 'show' == $action ? $sf_params->get('id') : $paramId; if ($id) { $schema_property_element = SchemaPropertyElementPeer::retrieveByPK($id); } } if (!isset($schema_property)) { if ($schema_property_element) { $schema_property = $schema_property_element->getSchemaPropertyRelatedBySchemaPropertyId(); } } if (!isset($schema)) { if ($schema_property) { $schema = $schema_property->getSchema(); } } if ($schema_property_element) { $objectId = $schema_property_element->getId(); }
/** * * @return Schema */ private static function getSchema() { $currentPropertyId = sfContext::getInstance()->getRequest()->getParameter('schema_property_id', ''); if ($currentPropertyId) { $schema = SchemaPropertyPeer::retrieveByPK($currentPropertyId)->getSchema(); } else { $schema = sfContext::getInstance()->getUser()->getAttribute('schema'); } if (!$schema) { $id = sfContext::getInstance()->getRequest()->getParameter('id', ''); if ($id) { if ("schemapropel" == sfContext::getInstance()->getModuleName()) { $schema = SchemaPropertyElementPeer::retrieveByPK($id)->getSchemaPropertyRelatedBySchemaPropertyId()->getSchema(); } else { $schema = self::retrieveByPK($id)->getSchema(); } } } return $schema; }