/** * @brief * The purpose of this function is to return an array of * _ars records for an agent so that the latest agent_pk(s) * can be determined. * This is for _ars tables only, for example, nomos_ars and bucket_ars. * The _ars tables have a standard format but the specific agent ars table * may have additional fields. * @param string $tableName - name of the ars table (e.g. nomos_ars) * @param int $uploadId * @param int $limit - limit number of rows returned. 0=No limit, default=1 * @param int $agentId - ARS table agent_fk, optional * * @return mixed * assoc array of _ars records. * or FALSE on error, or no rows */ public function agentARSList($tableName, $uploadId, $limit = 1, $agentId = 0, $agentSuccess = TRUE) { //based on common-agents.php AgentARSList if (!$this->dbManager->existsTable($tableName)) { return false; } $arguments = array($uploadId); $statementName = __METHOD__ . $tableName; $sql = "SELECT * FROM {$tableName}, agent WHERE agent_pk=agent_fk AND upload_fk=\$1 AND agent_enabled"; if ($agentId) { $arguments[] = $agentId; $sql .= ' AND agent_fk=$' . count($arguments); $statementName .= ".agent"; } if ($agentSuccess) { $sql .= " AND ars_success"; $statementName .= ".suc"; } $sql .= " ORDER BY agent_ts DESC"; if ($limit > 0) { $arguments[] = $limit; $sql .= ' limit $' . count($arguments); $statementName .= ".lim"; } $this->dbManager->prepare($statementName, $sql); $result = $this->dbManager->execute($statementName, $arguments); $resultArray = $this->dbManager->fetchAll($result); $this->dbManager->freeResult($result); return $resultArray; }
private function checkExistsTable($tableName) { $error = intval(!$this->dbManager->existsTable('license_candidate')); if ($error) { echo "(-) table {$tableName} does not exists"; } else { if ($this->verbose) { echo "(+) table {$tableName} exists"; } } $this->errors += $error; }
function applyInheritedRelations() { if (empty($this->schema['INHERITS'])) { return; } foreach ($this->schema['INHERITS'] as $table => $fromTable) { if (empty($table)) { continue; } if (!$this->dbman->existsTable($table) && $this->dbman->existsTable($fromTable)) { $sql = "CREATE TABLE \"{$table}\" () INHERITS (\"{$fromTable}\")"; $this->applyOrEchoOnce($sql, $stmt = __METHOD__ . $table); } } }
/** * @expectedException \Exception */ function testExistsDb_hack() { $this->dbManager->existsTable("goodTable' OR 3<'4"); }