Exemple #1
0
 /**
  * Declares an association between this object and a Discipline object.
  *
  * @param                  Discipline $v
  * @return                 Recipe The current object (for fluent API support)
  * @throws PropelException
  */
 public function setDiscipline(Discipline $v = null)
 {
     if ($v === null) {
         $this->setDisciplineId(NULL);
     } else {
         $this->setDisciplineId($v->getId());
     }
     $this->aDiscipline = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Discipline object, it will not be re-added.
     if ($v !== null) {
         $v->addRecipe($this);
     }
     return $this;
 }
 /**
  * Exclude object from result
  *
  * @param   Discipline $discipline Object to remove from the list of results
  *
  * @return DisciplineQuery The current query, for fluid interface
  */
 public function prune($discipline = null)
 {
     if ($discipline) {
         $this->addUsingAlias(DisciplinePeer::ID, $discipline->getId(), Criteria::NOT_EQUAL);
     }
     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      Discipline $obj A Discipline object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         DisciplinePeer::$instances[$key] = $obj;
     }
 }
}
class NoIngredientItemException extends FailedImportException
{
}
require dirname(__FILE__) . '/../autoload.php';
Propel::disableInstancePooling();
if (!isset($argv[1]) || !($mapfilename = $argv[1])) {
    die('map file required.');
}
if (!file_exists($mapfilename)) {
    die('map file does not exist.');
}
if (DisciplineQuery::create()->count() == 0) {
    $disciplines = array(1 => 'Huntsman', 2 => 'Artificer', 3 => 'Weaponsmith', 4 => 'Armorsmith', 5 => 'Leatherworker', 6 => 'Tailor', 7 => 'Jeweler', 8 => 'Cook');
    foreach ($disciplines as $id => $name) {
        $d = new Discipline();
        $d->setId($id);
        $d->setName($name);
        $d->save();
    }
}
$data = json_decode(file_get_contents($mapfilename), true);
$cnt = count($data) - 1;
$failed = array();
$max = null;
foreach ($data as $i => $row) {
    try {
        echo "[{$i} / {$cnt}]: {$row['Name']}\n";
        $q = RecipeQuery::create()->findByDataId($row['DataID']);
        if ($q->count() == 0) {
            $r = new Recipe();