public function transformPhotographers() { $this->photogKeys = array(); $dom = DOMDocument::load("tuftsph_jm2db.xml"); $photogs = $dom->getElementsByTagName("photogs"); $total = $photogs->length; $count = 1; echo "Converting Photographers \n"; foreach ($photogs as $pr) { echo $count . "/" . $total . "\n"; $count += 1; $childNodes = $pr->childNodes; $i = array(); foreach ($childNodes as $child) { $i[$child->nodeName] = $child->textContent; } list($firstName, $lastName) = explode(" ", $i["name"]); if (strlen($i["email"]) == 0 || is_null($i["email"])) { $i["email"] = "NO_EMAIL_" . $count . "@TUFTS.EDU"; } $user = new sfGuardUser(); $user->setUsername($i["email"]); $user->setPassword(""); $user->setAlgorithm("sha1"); $user->save(); $profile = new sfGuardUserProfile(); $profile->setUserId($user->getId()); $profile->setUserTypeId(sfConfig::get("app_user_type_photographer")); $profile->setEmail($i["email"]); $profile->setFirstName($firstName); $profile->setLastName($lastName); $profile->save(); $ph = new Photographer(); $ph->setUserId($profile->getId()); $ph->setName($i["name"]); $ph->setPhone($i["phone"]); $ph->setEmail($i["email"]); $ph->setAffiliation($i["affiliation"]); $ph->save(); $this->photogKeys[$i["photog_id"]] = $ph->getId(); } }
/** * Declares an association between this object and a Photographer object. * * @param Photographer $v * @return JobPhotographer The current object (for fluent API support) * @throws PropelException */ public function setPhotographer(Photographer $v = null) { if ($v === null) { $this->setPhotographerId(NULL); } else { $this->setPhotographerId($v->getId()); } $this->aPhotographer = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Photographer object, it will not be re-added. if ($v !== null) { $v->addJobPhotographer($this); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Photographer $value A Photographer object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Photographer $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }