/** * @param unknown $data */ function addFilament($data) { $existing = DAOFactory::getFilamentDAO()->queryByKeys($data[self::FILAMENT_NAME], $data[self::FILAMENT_TYPE], $data[self::COLOUR], floatval($data[self::DIAMETER])); echo " \n name : " . $data[self::FILAMENT_NAME] . ' type : ' . $data[self::FILAMENT_TYPE] . ' color : ' . $data[self::COLOUR] . ' dia : ' . floatval($data[self::DIAMETER]); $filament = new Filament(); if ($existing == NULL) { // add new filament. $material = $this->addMaterial($data); $supplier = $this->addSupplier($data); $filament->materialId = $material->materialId; $filament->supplierId = $supplier->supplierId; $filament->name = $data[self::FILAMENT_NAME]; $filament->color = $data[self::COLOUR]; $filament->size = floatval($data[self::DIAMETER]); $filament->filamentId = DAOFactory::getFilamentDAO()->insert($filament); } else { $filament = $existing[0]; } echo " \n fil : " . $filament->name . ' color ' . $filament->color; // will need to check existing filament and material. // safe bet, if the filament already exists then we can skip a material check/add }
public static function getFilament() { $filament = DAOFactory::getFilamentDAO()->queryAll(); return $filament; }