protected function add(array $directions) { $insertCnt = 0; $version = TableUpdate::getVersion(); foreach ($directions as $d) { $boundParams = array($this->route->getId(), $d->getTitle(), $this->getPrettyTitle($d->getTitle()), $d->getName(), $this->getPrettyName($d->getName()), $d->getTag(), $d->getUseForUi() ? 1 : 0, $d->getShow() ? 1 : 0, $version); //var_dump($boundParams); $this->dbObj->bindParams($boundParams); $query = "INSERT INTO direction (route_id, title, pretty_title,\n name, pretty_name, tag, use_for_ui, show, version, created_date)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())"; $this->dbObj->query($query); //$this->dbObj->debug(); //print $query; if ($this->dbObj->rows_affected != 1) { throw new DBException("Addition of direction failed [agency:" . $this->route->getAgency()->getId() . "] [route tag:" . $this->route->getTag() . "] [route title:" . $this->route->getTitle() . "]"); } $insertCnt++; } //TODO: Add a log for the total number of directions added //Write the changes to the change log $this->saveChangesToFile(); }