会员登录 | 会员注册 | 意见建议 | 网站地图

站长资源综合门户

当前位置:首页 > 站长学院 > 编程程序 > 同时支持三个MySQL+SQLite+PDO的PHP数据库类

同时支持三个MySQL+SQLite+PDO的PHP数据库类

时间:2012-08-16 20:39:14   作者:   来源:   点击:

}

$output .= '{"name":"' . $table['TABLE_NAME'] . '","rowcount":' . $rowCount . '},';

}

if (substr($output, -1) == ",")

$output = substr($output, 0, -1);

$output .= ']';

}

$output .= '},';

}

$output = substr($output, 0, -1);

}

} else if ($this->adapter == "mysql") {

$schemaSql = $this->listDatabases();

if ($this->rowCount($schemaSql)) {

while ($schema = $this->fetchArray($schemaSql)) {

$output .= '{"name": "' . $schema[0] . '"';

$this->selectDB($schema[0]);

$tableSql = $this->listTables();

if ($this->rowCount($tableSql)) {

$output .= ',"items": [';

while ($table = $this->fetchArray($tableSql)) {

$countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table[0] . "`");

$rowCount = (int)($this->result($countSql, 0, "RowCount"));

$output .= '{"name":"' . $table[0] . '","rowcount":' . $rowCount . '},';

}

if (substr($output, -1) == ",")

$output = substr($output, 0, -1);

$output .= ']';

}

$output .= '},';

}

$output = substr($output, 0, -1);

}

} else if ($this->adapter == "sqlite") {

$output .= '{"name": "' . $this->db . '"';

$tableSql = $this->listTables();

if ($tableSql) {

$output .= ',"items": [';

while ($tableRow = $this->fetchArray($tableSql)) {

$countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $tableRow[0] . "'");

$rowCount = (int)($this->result($countSql, 0, "RowCount"));

$output .= '{"name":"' . $tableRow[0] . '","rowcount":' . $rowCount . '},';

}

if (substr($output, -1) == ",")

$output = substr($output, 0, -1);

$output .= ']';

}

$output .= '}';

}

}

return $output;

}

function error() {

return $this->errorMessage;

}

}

分享到:

网友评论

热门编程程序