function createStations($stationCount, $tag, $typeId) { for ($j = 0; $j < $stationCount; $j++) { $station = new Station(); $tmp = sprintf("%s%02d", $tag, $j + 1); $station->set("tag", $tmp); $station->set("typeId", $typeId); if ($station->create() === false) { echo "Create Station {$tag} failed"; } } }