define('DB_DSN','mysql:dbname=数据库名;charset=UTF8');
define('DB_USER','root');
define('DB_PASSWORD','');
function dbInsert($sql,$data=null){
$pdo = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$stat = $pdo->prepare($sql);
return $stat->execute($data);
}
function dbSelect($sql,$data=null){
$pdo = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$stat = $pdo->prepare($sql);
$stat->execute($data);
return $stat->fetch(PDO::FETCH_NAMED);
}
function dbSelectAll($sql,$data=null){
$pdo = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$stat = $pdo->prepare($sql);
$stat->execute($data);
return $stat->fetchAll(PDO::FETCH_NAMED);
}
function dbUpdate($sql,$data=null){
$pdo = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$stat = $pdo->prepare($sql);
return $stat->execute($data);
}
function dbDelete($sql,$data=null){
$pdo = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$stat = $pdo->prepare($sql);
return $stat->execute($data);
}