if (!$queryResult) {
$errorInfo = $this->conn->errorInfo();
$this->errorMessage = $errorInfo[2];
}
return $queryResult;
} else if ($this->method == "mysql") {
$queryResult = @mysql_query($queryText, $this->conn);
if (!$queryResult) {
$this->errorMessage = mysql_error();
}
return $queryResult;
} else if ($this->method == "sqlite") {
$queryResult = sqlite_query($this->conn, $queryText);
if (!$queryResult) {
$this->errorMessage = sqlite_error_string(sqlite_last_error($this->conn));
}
return $queryResult;
}
} else {
return false;
}
}
// Be careful using this function - when used with pdo, the pointer is moved
// to the end of the result set and the query needs to be rerun. Unless you
// actually need a count of the rows, use the isResultSet() function instead
function rowCount($resultSet) {
if (!$resultSet)
return false;
if ($this->conn) {
if ($this->method == "pdo") {
return count($resultSet->fetchAll());
} else if ($this->method == "mysql") {
return @mysql_num_rows($resultSet);
} else if ($this->method == "sqlite") {
return @sqlite_num_rows($resultSet);
}
}
}
function num_rows($res) {
return $this->rowCount($res);
}
function isResultSet($resultSet) {
if ($this->conn) {
if ($this->method == "pdo") {
return ($resultSet == true);
} else {
return ($this->rowCount($resultSet) > 0);
}
}
}
function fetch($res) {
return $this->fetchAssoc($res);
}
function fetchArray($resultSet) {
if (!$resultSet)
return false;
if ($this->conn) {
if ($this->method == "pdo") {
return $resultSet->fetch(PDO::FETCH_NUM);
} else if ($this->method == "mysql") {
return mysql_fetch_row($resultSet);
} else if ($this->method == "sqlite") {
return sqlite_fetch_array($resultSet, SQLITE_NUM);
}
}
}
function fetchAssoc($resultSet) {
if (!$resultSet)
return false;
if ($this->conn) {
if ($this->method == "pdo") {
return $resultSet->fetch(PDO::FETCH_ASSOC);
} else if ($this->method == "mysql") {
return mysql_fetch_assoc($resultSet);
} else if ($this->method == "sqlite") {
return sqlite_fetch_array($resultSet, SQLITE_ASSOC);
}
}
}
function affectedRows($resultSet) {
if (!$resultSet)
return false;
if ($this->conn) {
if ($this->method == "pdo") {
return $resultSet->rowCount();
} else if ($this->method == "mysql") {
return @mysql_affected_rows($resultSet);
} else if ($this->method == "sqlite") {
return sqlite_changes($resultSet);
}
}
}
function result($resultSet, $targetRow, $targetColumn = "") {
if (!$resultSet)
return false;
if ($this->conn) {
if ($this->method == "pdo") {
if ($targetColumn) {
$resultRow = $resultSet->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, $targetRow);
return $resultRow[$targetColumn];
} else {
$resultRow = $resultSet->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_ABS, $targetRow);
return $resultRow[0];
}
} else if ($this->method == "mysql") {
return mysql_result($resultSet, $targetRow, $targetColumn);
} else if ($this->method == "sqlite") {
return sqlite_column($resultSet, $targetColumn);
}
}
}
function listDatabases() {
if ($this->conn) {
if ($this->adapter == "mysql") {
return $this->query("SHOW DATABASES");
} else if ($this->adapter == "sqlite") {
return $this->db;
}
}
}
function listTables() {
if ($this->conn) {
if ($this->adapter == "mysql") {
return $this->query("SHOW TABLES");
} else if ($this->adapter == "sqlite") {
return $this->query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name");
}
}
}
function hasCharsetSupport()
{
if ($this->conn) {
if ($this->adapter == "mysql" && version_compare($this->getVersion(), "4.1", ">")) {
return true;
} else {
return false;
}
}
}
function listCharset() {
if ($this->conn) {
if ($this->adapter == "mysql") {
return $this->query("SHOW CHARACTER SET");