function delete() { if (!(int) $this->getId()) { throw new Exception(); } $identityMap = Elite_Vaf_Model_Level_IdentityMap_ByTitle::getInstance(); $identityMap->remove($this->getType(), $this->getId()); $this->deleteFits(); $this->deleteChildren(); $query = sprintf("DELETE FROM `" . $this->getTable() . "` WHERE `id` = %d", $this->getId()); $this->query($query); $query = sprintf("DELETE FROM `elite_definition` WHERE `" . $this->getType() . "_id` = %d", $this->getId()); $this->query($query); if ($this->getType() == $this->getSchema()->getLeafLevel() && file_exists(ELITE_PATH . '/Vafwheel')) { $query = sprintf("DELETE FROM `elite_definition_wheel` WHERE `leaf_id` = %d", $this->getId()); $this->query($query); } }
/** @return integer ID */ function findEntityIdByTitle($type, $title, $parent_id = 0) { $identityMap = Elite_Vaf_Model_Level_IdentityMap_ByTitle::getInstance(); if ($identityMap->has($type, $title, $parent_id)) { return $identityMap->get($type, $title, $parent_id); } if (!$this->getSchema()->isGlobal($type) && !$parent_id) { throw new Elite_Vaf_Model_Level_Finder_SchemaException('Please specify parent level to search under. If you want all possible matches use the vehicle finder, not the level finder.'); } $inflectedType = $this->inflect($type); $query = $this->getReadAdapter()->select()->from(array('l' => 'elite_level_' . $inflectedType))->where('`title` LIKE binary ?', $title); if (!$this->getSchema()->isGlobal($type) && is_numeric($parent_id) && $parent_id) { $parent_type = $this->getSchema()->getPrevLevel($type); $inflected_parent_type = $this->inflect($parent_type); $query->joinLeft(array('d' => 'elite_definition'), "l.id = d.{$inflectedType}_id", array()); $query->where('d.' . $inflected_parent_type . '_id = ?', $parent_id); } if (is_array($parent_id)) { $query->joinLeft(array('d' => 'elite_definition'), 'l.id = d.' . str_replace(' ', '_', $type) . '_id', array()); foreach ($parent_id as $level => $val) { $query->where('d.' . str_replace(' ', '_', $level) . '_id = ?', $val); } } $result = $this->query($query); $id = $result->fetchColumn(0); if (!$id) { return false; } $identityMap->add($id, $type, $title, $parent_id); return $id; }