$PDO=New PDO('mysql:host=localhost;dbname=test','root','') Or Die('Can not open the database!'); //添加 //IF($PDO->Exec("INSERT INTO (name,content) values ('".$."','".$."')")) { IF($PDO->Exec("INSERT INTO `{$Table}` SET ='{$}',='".$_ENV['DB1']->Quote($)."',addtime='".time()."'")) { Echo $PDO->lastInsertId(); } //刪除 $Rs=$PDO->Exec("DELETE FROM `{$Table}` WHERE id='{$id}'"); IF($Rs) { Echo '共刪除了',$Rs,'條數據.'; } //檢查 $Rs=$PDO->Query("SELECT * FROM WHERE id="); $Rs=$Rs->fetchall(); IF(Count($Rs)<1) { unSet($Rs); Die('沒有數據'); }unSet($Rs); $Rs=$PDO->Query("SELECT * FROM `{$Table}` ORDER BY id DESC"); Foreach($Rs as $k=>$v) { Echo '<textarea rows="5" style="border:1px gray solid;width:90%;overflow:auto;">【',$k,'】',Chr(10); Print_r ($v); Echo '</textarea>'; } unSet($Rs,$PDO);
参考http://www.w3school.com.cn/php/php_mysql_intro.asp
//IF($PDO->Exec("INSERT INTO (name,content) values ('".$."','".$."')")) {
IF($PDO->Exec("INSERT INTO `{$Table}` SET ='{$}',='".$_ENV['DB1']->Quote($)."',addtime='".time()."'")) {
Echo $PDO->lastInsertId();
} //刪除
$Rs=$PDO->Exec("DELETE FROM `{$Table}` WHERE id='{$id}'");
IF($Rs) {
Echo '共刪除了',$Rs,'條數據.';
} //檢查
$Rs=$PDO->Query("SELECT * FROM WHERE id=");
$Rs=$Rs->fetchall();
IF(Count($Rs)<1) {
unSet($Rs);
Die('沒有數據');
}unSet($Rs); $Rs=$PDO->Query("SELECT * FROM `{$Table}` ORDER BY id DESC");
Foreach($Rs as $k=>$v) {
Echo '<textarea rows="5" style="border:1px gray solid;width:90%;overflow:auto;">【',$k,'】',Chr(10);
Print_r ($v);
Echo '</textarea>';
}
unSet($Rs,$PDO);