/** * Retrieves all of the methods from the given files. Only resources that * are methods will be returned. * * @param Triumph_DatabaseTag[] the database tags to save * @param string $sourceDir the source directory for this database tag */ public function saveDatabaseTags($databaseTags, $sourceDir) { // delete all old database tags $sourceDbTable = new Triumph_SourceTable($this->getAdapter()); $sourceId = $sourceDbTable->getOrSave($sourceDir); $strWhere = $this->getAdapter()->quoteInto("source_id = ?", $sourceId); $this->delete($strWhere); // sqlite optimizes transactions really well; use transaction so that the inserts are faster $this->getAdapter()->beginTransaction(); foreach ($databaseTags as $databaseTag) { $this->insert(array('source_id' => $sourceId, 'label' => $databaseTag->label, 'schema' => $databaseTag->schema, 'driver' => $databaseTag->driver, 'host' => $databaseTag->host, 'port' => $databaseTag->port, 'user' => $databaseTag->user, 'password' => $databaseTag->password)); } $this->getAdapter()->commit(); }
/** * Saves all of the given config tags. * * @param Triumph_DatabaseTag[] the database tags to save * @param string $sourceDir the source directory for this database tag */ public function saveConfigTags($configTags, $sourceDir) { // delete all old config tags $sourceDbTable = new Triumph_SourceTable($this->getAdapter()); $sourceId = $sourceDbTable->getOrSave($sourceDir); $strWhere = $this->getAdapter()->quoteInto("source_id = ?", $sourceId); $this->delete($strWhere); // sqlite optimizes transactions really well; use transaction so that the inserts are faster $this->getAdapter()->beginTransaction(); foreach ($configTags as $configTag) { $this->insert(array('source_id' => $sourceId, 'label' => $configTag->label, 'full_path' => $configTag->fullPath)); } $this->getAdapter()->commit(); }
/** * saves the given Triumph_Urls into the database. * * @param Triumph_Url[] $arrUrls the urls to insert */ function saveUrls($arrUrls, $sourceDir) { // delete the old rows $sourceDbTable = new Triumph_SourceTable($this->getAdapter()); $sourceId = $sourceDbTable->getOrSave($sourceDir); $strWhere = $this->getAdapter()->quoteInto("source_id = ?", $sourceId); $this->delete($strWhere); if (!is_array($arrUrls)) { return; } // sqlite optimizes transactions really well; use transaction so that the inserts are faster $this->getAdapter()->beginTransaction(); foreach ($arrUrls as $url) { $this->insert(array('source_id' => $sourceId, 'url' => $url->url, 'full_path' => $url->fileName, 'class_name' => $url->className, 'method_name' => $url->methodName)); } $this->getAdapter()->commit(); }
public function saveTemplateFiles($templateFiles, $sourceDir) { // delete the old rows $sourceDbTable = new Triumph_SourceTable($this->getAdapter()); $sourceId = $sourceDbTable->getOrSave($sourceDir); $strWhere = $this->getAdapter()->quoteInto("source_id = ?", $sourceId); $this->delete($strWhere); if (!is_array($templateFiles)) { return; } // sqlite optimizes transactions really well; use transaction so that the inserts are faster $this->getAdapter()->beginTransaction(); foreach ($templateFiles as $templateFile) { $variables = join(',', $templateFile->variables); $this->insert(array('source_id' => $sourceId, 'full_path' => $templateFile->fullPath, 'variables' => $variables)); } $this->getAdapter()->commit(); }
/** * Saves all of the tags into the database * * @param Triumph_DetectedTag[] $allTags the tags to save */ public function saveTags($allTags, $sourceDir) { // remove all tags from previous detection. since there is no // easy way to tell of duplicates $sourceDbTable = new Triumph_SourceTable($this->getAdapter()); $sourceId = $sourceDbTable->getOrSave($sourceDir); $strWhere = $this->getAdapter()->quoteInto("source_id = ?", $sourceId); $this->delete($strWhere); if (empty($allTags)) { return; } // sqlite optimizes transactions really well; use transaction so that the inserts are faster $this->getAdapter()->beginTransaction(); foreach ($allTags as $tag) { // insert twice; once fully qualified and once // just the method name; that way qualified lookups // work $this->insert(array('source_id' => $sourceId, 'key' => $tag->className . '::' . $tag->identifier, 'type' => $tag->type, 'class_name' => $tag->className, 'method_name' => $tag->identifier, 'return_type' => $tag->returnType, 'namespace_name' => $tag->namespaceName, 'signature' => $tag->signature, 'comment' => $tag->comment, 'is_static' => $tag->isStatic)); $this->insert(array('source_id' => $sourceId, 'key' => $tag->identifier, 'type' => $tag->type, 'class_name' => $tag->className, 'method_name' => $tag->identifier, 'return_type' => $tag->returnType, 'namespace_name' => $tag->namespaceName, 'signature' => $tag->signature, 'comment' => $tag->comment, 'is_static' => $tag->isStatic)); } $this->getAdapter()->commit(); }