Mysql.class.php をダウンロードします
"; }else {
echo '
エラーが発生しました!
';
}
}
// 取得query実行成功否の情報
public function get_query_info($info){
if ($this->query_id) {
echo $info;
}
}
// すべて
public function findall ($table_name) {
$this->query("select * from $table_name");
}
// mysql_fetch_array
public function fetch_array () {
if ($this->query_id) {
$this->result = mysql_fetch_array($this->query_id);
$this->結果を返す;
}
}
// ......
public function fetch_assoc () {
if ($this->query_id) {
$this->result = mysql_fetch_assoc($this->query_id);
$this->結果を返す;
}
}
public function fetch_row () {
if ($this->query_id) {
$this->result = mysql_fetch_row($this->query_id);
$this->結果を返す;
}
}
public function fetch_object () {
if ($this->query_id) {
$this->result = mysql_fetch_object($this->query_id);
$this->結果を返す;
}
}
// 取得 num_rows
public function num_rows () {
if ($this->query_id) {
$this->num_rows = mysql_num_rows($this->query_id);
return $this->num_rows;
}
}
// 获取 insert_id
public function insert_id () {
return $this->insert_id = mysql_insert_id();
}
// 共有数张表を表示
public function show_tables () {
$this->query("show tables");
if ($this->query_id) {
echo "数据库 $this->db_name 共有 ".$this->num_rows($this->query_id)." 张表
";
$i = 1;
while ($row = $this->fetch_array($this->query_id)){
echo "$i -- $row[0]
";
$i++;
}
}
}
// 共通のデータを表示
public function show_dbs(){
$this->query("show Databases");
if ($this->query_id) {
echo "共有数据库 ".$this->num_rows($this->query_id)." 个
";
$i = 1;
while ($this->row = $this->fetch_array($this->query_id)){
echo "$i -- ".$this->row[データベース]。"
";
$i++;
}
}
}
// 删除数据库:返删除结果
public function drop_db ($db_name='') {
if ($db_name == '') {
$db_name = $this->db_name;/ /默认删除当前データベース库
$this->query("DROP DATABASE $db_name");
}else {
$this->query("DROP DATABASE $db_name");
}
if ($this->query_id) {
return "データベース库 $db_name 删除成功";
}else {
$this->show_error("数据库 $db_name 删除失败");
}
}
// 删除データベース表:返删除结果
public function drop_table ($table_name) {
$this->query("DROP TABLE $table_name");
if ($this->query_id) {
return "データベース表 $table_name 删除成功";
}else {
$this->show_error("データベース表 $table_name 删除失败");
}
}
// 创建データベース库
public function create_db ($db_name) {
$this->query("CREATE DATABASE $db_name");
if($this->query_id){
return "データベース库 $db_name 创建成功";
}else {
$this->show_error("データベース库 $db_name 创建失败");
}
}
// 获取データベース库バージョン
public function get_info(){
echo mysql_get_server_info();
}
// 释放内存
public function free_result () {
if ( @mysql_free_result($this->query_id) )
unset ($this->result);
$this->query_id = 0;
}
} // 授業を終了します
?>