public function formObject() { $model = new Genre($this->data->id); $this->data->forUpdate = $this->data->id != ''; $this->data->object = $model->getData(); $this->data->title = $this->data->forUpdate ? $model->getDescription() : _M("New Genre"); $this->data->save = "@fnbr20/admin/genre/save/" . $model->getId() . '|formObject'; $this->data->delete = "@fnbr20/admin/genre/delete/" . $model->getId() . '|formObject'; $this->render(); }
/** * Add a custom genre to the database or get its key if it exists * @param name str: the name of the genre to add * @return int: the primary key added or found */ public function addGenre($name) { //trim whitespace $name = trim($name); if (empty($name)) { $name = 'Uncategorized'; } //is this name already in the collection? if (is_numeric($name) && $name < 127) { $result = $this->find($name); } if (is_numeric($name) && $name > 126) { $name = 'Uncategorized'; } $q = Doctrine_Query::create()->select('g.id')->from('Genre g')->where('g.name = ?', $name); $result = $q->fetchOne(); if (is_object($result) && $result->id > 0) { $retId = $result->id; unset($q, $result); return $retId; } else { $item = new Genre(); $item->name = $name; $item->save(); $id = $item->getId(); $item->free(); unset($item, $q, $result); return $id; } }
public static function getPlannedEvents($date = null, Genre $oGenre = null, Gender $oGender = null) { $query = "SELECT Event.id\n\t\t\t\t\tFROM Event\n\t\t\t\t\tWHERE Event.season_nefub_id = '" . Season::getInstance()->nefub_id . "'\n\t\t\t\t\t "; if ($oGender) { $query .= " AND Event.gender_id " . $oGender->getId(); } if ($oGenre) { $query .= " AND Event.genre_id " . $oGenre->getId(); } if ($date) { $query .= " AND Event.date = '" . str_replace("'", '', $date) . "'"; } else { $query .= ' AND DATE(Event.date) >= CURDATE()'; } $query .= ' GROUP BY gender_id'; $query .= ' ORDER BY Event.date ASC'; return self::getAllFromQuery($query); }
protected static function convertEvent($nefubName, $date, Genre $oGenre, Gender $oGender) { $oEvent = Event::getByNefubName($nefubName, $date, $oGender); if (!$oEvent) { $oEvent = new Event(); $oEvent->nefub_name = $nefubName; $oEvent->season_nefub_id = Season::getInstance()->nefub_id; $oEvent->date = $date; $oEvent->genre_id = $oGenre->getId(); if ($oGender) { $oEvent->gender_id = $oGender->getId(); } } $oEvent->save(); return $oEvent; }
/** * Declares an association between this object and a Genre object. * * @param Genre $v * @return Moviesgenres The current object (for fluent API support) * @throws PropelException */ public function setGenre(Genre $v = null) { if ($v === null) { $this->setGenreid(NULL); } else { $this->setGenreid($v->getId()); } $this->aGenre = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Genre object, it will not be re-added. if ($v !== null) { $v->addMoviesgenres($this); } return $this; }
if ($xmlItem->hasAttributes()) { $genre = new Genre(); // obtengo valores de los atributos que necesito foreach ($xmlItem->attributes as $attrName => $attrValue) { if ($attrName == "id") { $genre->setId($attrValue->nodeValue); } // if ($attrName == "name") { $genre->setName($attrValue->nodeValue); } // } // estos grupos no se guardan en la database // deberian guardarse con activo=0 pero voy a skippear porque no se si la web lo toma en cuenta... je :S if ($genre->getId() != "15680" && $genre->getId() != "15679") { $saved = $genre->save($dbc, "generos"); if ($saved === TRUE) { $ok++; } else { $error++; $log->add("ERROR SQL: " . mysql_error()); } } else { $skipped++; $log->add("Skipping group #" . $genre->getId()); } } else { // no se pudo leer los datos del genero $log->add("ERROR: no se pudieron obtener datos del genero en: {$xmlName}"); }
/** * Filter the query by a related Genre object * * @param Genre|PropelCollection $genre The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return MoviesgenresQuery The current query, for fluid interface */ public function filterByGenre($genre, $comparison = null) { if ($genre instanceof Genre) { return $this->addUsingAlias(MoviesgenresPeer::GENREID, $genre->getId(), $comparison); } elseif ($genre instanceof PropelCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(MoviesgenresPeer::GENREID, $genre->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByGenre() only accepts arguments of type Genre or PropelCollection'); } }
/** * Exclude object from result * * @param Genre $genre Object to remove from the list of results * * @return GenreQuery The current query, for fluid interface */ public function prune($genre = null) { if ($genre) { $this->addUsingAlias(GenrePeer::ID, $genre->getId(), Criteria::NOT_EQUAL); } return $this; }