예제 #1
0
 public function postAdd(array $methodArgs, array $requestArgs)
 {
     // Check params
     $longLink = $this->getAndCheckLongLink($methodArgs);
     // Generate and insert short link
     $shortLink = $this->generateRandomString(7);
     $statement = Database::prepareStatementFromResource("links-write", __NAMESPACE__, "links.insert-link.sql");
     $statement->bindValue(':shortLink', $shortLink, \PDO::PARAM_STR);
     $statement->bindValue(':longLink', $longLink, \PDO::PARAM_STR);
     if (!$statement->execute()) {
         throw new ServerErrorHttpException("Cannot insert link to database.");
     }
     // Print XML
     $this->printResponseXml($shortLink);
     exit;
 }
예제 #2
0
 private function queryWithoutPluginId($operatingSystem, $architecture, $includeSnapshots)
 {
     $sqlQueryFile = $includeSnapshots ? "plugins.select-all-with-snapshots.sql" : "plugins.select-all-release-only.sql";
     $statement = Database::prepareStatementFromResource("plugins-read", __NAMESPACE__, $sqlQueryFile);
     $statement->bindParam(':pluginOperatingSystem', $operatingSystem, \PDO::PARAM_STR);
     $statement->bindParam(':pluginArchitecture', $architecture, \PDO::PARAM_STR);
     return $this->fetchPlugins($statement);
 }
예제 #3
0
 public static function prepareStatementFromResource($configContext, $namespaceContext, $sqlFile)
 {
     $database = Database::createInstance($configContext);
     $sqlQuery = FileUtil::readResourceFile($namespaceContext, $sqlFile);
     return $database->prepare($sqlQuery);
 }