国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? php教程 PHP源碼 Php Mysql PDO

Php Mysql PDO

May 26, 2016 am 08:18 AM

Php Mysql PDO

<?php
header("Content-type:text/html; charset=utf8");

class Mysql{
	protected $mysql;
	
	function __construct(){
		$this->mysql=new PDO("mysql:host=localhost;dbname=mytest","root","root");
		if(!$this->mysql) { throw new Exception("Can&#39;t connect to Mysql");exit(0);}
		
		$this->mysql->query("set names utf8");
	}
	
	function  getItem($id){
		$result=$this->mysql->prepare("select * from table01 where id=:id");
		$result->bindParam(&#39;:id&#39;,$id,PDO::PARAM_INT);        //bindValue:不接受php參數(shù)
		$result->execute();
		
		$resultArray=array();
		while($row=$result->fetch(PDO::FETCH_ASSOC)){
			array_push($resultArray,array($row[&#39;number&#39;],$row[&#39;name&#39;]));
		}
		
		return $resultArray;
	}
	
	function removeItem($name){
		$delete=$this->mysql->prepare("delete from table01 where name=:name");
		$delete->bindParam(&#39;:name&#39;,$name,PDO::PARAM_STR);
		$delete->execute();
		
		if($delete) return true;
		else return false;
	}
	
	function addItem($number,$name){
		$insert=$this->mysql->prepare("insert into table01(number,name) values (:number,:name)");
		$insert->bindParam(&#39;:number&#39;,$number,PDO::PARAM_INT);
		$insert->bindParam(&#39;:name&#39;,$name,PDO::PARAM_STR);
		$insert->execute();
		
		if($insert) return true;
		else return false;
	}
}
try{
	$mysql=new Mysql();
	//添加條目
    if($mysql->addItem(5,"five")) echo "addItem(5,&#39;five&#39;) is success<br>";
    else echo "addItem(5,&#39;five&#39;) is wrong<br>";
	
	//刪除條目
	if($mysql->removeItem("five")) echo "removeItem(&#39;five&#39;) is success<br>";
	else echo "removeItem(&#39;five&#39;) is wrong<br>";
	
	//查找條目
	$result=$mysql->getItem(1);
	echo $result[0][0]."<br>".$result[0][1];
	
}catch(Exception $e){
	echo $e->getMessage()."<br>";
}

以上就是Php Mysql PDO的內(nèi)容,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)(m.miracleart.cn)!


? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
PHP? ?? ?? ?? (ORM) ?? ?? PHP? ?? ?? ?? (ORM) ?? ?? Jul 29, 2025 am 05:00 AM

N 1 ?? ??? ??? ?? ???? ?????? ?????? ?? ?? ????. 2. ???? ???? ???? ?? ??? ???????? ??? ??? ?? ? ??????. 3. ??? 2 ? ?? ?? Redis ?? ??? ?? ??? ?? ?? ??? ????? ??????. 4. ??? ????? ????? ????? Clear ()? ???? ???? ?????? ??? ????? ?????. 5. ?????? ??? ????? ???? ???? ? ??? ??? ?? ?? ? SQL ?? ??????. 6. ?? ??? ???? ?? ?????? ?? ?? ??? ?????? ?? ?? ?? ??? ???? ??? ??????. ORM? ???? ????? ?? ??? ????? ?? ???? ??? ???? ?? SQL ????, ??, ?? ?? ? ??? ???? ???????.

vscode settings.json ?? vscode settings.json ?? Aug 01, 2025 am 06:12 AM

settings.json ??? ??? ?? ?? ?? ?? ?? ??? ??? VSCODE ??? ??? ???? ? ?????. 1. ??? ?? ?? : Windows? C : \ Users \\ AppData \ Roaming \ Code \ User \ Settings.json, MacOS IS /users//library/applicationsupport/code/user/settings.json, linux? /home//.config/code/user/settings.json; 2. Workspace ?? ?? : .vscode/settings project root ????

PHP? ?? ??? ?? ????? ?? ?? ??? PHP? ?? ??? ?? ????? ?? ?? ??? Jul 28, 2025 am 04:44 AM

PHP? ??? ?? ????? ?? ??? ??????????? ?? ??? ???? ?? ?? ??? ????????. 1. ?? ??? ??? ?? ??? ?? ? ?? ???? ?????. 2. ?? ???? ???? ???? ?? ? ? ???? GC? ?? ????? ???? ?????. 3. "??? ??"zval? ?? ?? ????? ???? GC_COLLECT_CYCLES ()? ?? ? ? GC? ??????. 4. ?? ?? PHP ?? ????? ??? ??? ??? ?? GC_STATUS ()? ?????? GC_COLLECT_CYCLES ()? ? ??? ???????. 5. ?? ???? ?? ??? ??? GC_DISABLE ()? ???? ?? ? ??? ????? ORM? CLER () ???? ?? DeReeference ??? ?????.

Serverless Revolution : BREF? ???? ?? ??? PHP ?? ????? ????? Serverless Revolution : BREF? ???? ?? ??? PHP ?? ????? ????? Jul 28, 2025 am 04:39 AM

BREF? ?? PHP ???? ??? ???? ?? ?? ???? ?? ???? ?? ????? ?? ? ? ????. 1. Bref? ??? ? PHP ??? ???? ???? PHP8.3 ? ?? ??? ???? Laravel ? Symfony? ?? ??? ??? ???? ???? PHP? Awslambda? ?????. 2. ?? ???? ??? ????? : Composer? ???? BREF ??, HTTP ?? ??? ? ?? ??? ?? ?? ? ???? ???? ?? Serverless.yml ??; 3. ServerlessDeploy ??? ???? ??? ???? APIGINGWARE? ???? ???? ??? URL? ?????. 4. Lambda ??? ?? Bref? ???? ?????.

Readonly ???? PHP? ??? ??? ????? Readonly ???? PHP? ??? ??? ????? Jul 30, 2025 am 05:40 AM

readOnlyPropertiesInphp8.2CanonlyBeassignedOnedOneDonceIntheConstructorAratDeclarationandCannotBemodififificificificifified

?? ?? ??? PHP? ????? ?? ?? ??? PHP? ????? Jul 28, 2025 am 04:37 AM

usearestapitobridgephpandmlmodelsbyrunningthemodelinpythonviaflaskorfastapiandcallingitffuspusingcurlorguzz.2.runpythonscriptsdirectlyfromphpusingexec () orshell_exec () orshell_exec () orshell_exec ()???, ??? ??? ?? ??? hassecurity and somancelitat

CSS ?? ?? ?? ? CSS ?? ?? ?? ? Jul 30, 2025 am 05:28 AM

?? JavaScript? ???? ??? ??? ?? ??? ??? ??? ?? ??? ?? ??? ??? ???????. 1. HTML ???? ?? ???? ????? ??? ???? ????. 2. CSS ?? : ??? ?? ?? ??? ???? ?? ??, .dark-mode ???? ??? ?? ??? ???? var ()? ?? ??? ??? ?????. 3. JavaScript? ??? ???? ?? ???? ?? ??? ???? ?? LocalStorage? ????. 4. ??? ?? ? ? HTML ???? Dark-Mode ???? ???? ?? ??? LocalStorage? ?????. 5. ?? ?? ?? ??? 0.3 ? ?? ?????? ???? ???? ??????.

Java ?? ??? ? ???? ? ?? Java ?? ??? ? ???? ? ?? Jul 31, 2025 am 03:58 AM

?? ?? ??? ???? ?? ??? ?? ?? ? ??? ???? VisualVM ?? JProfiler? ???? ?? ???? Async-Profiler? ?? ??? ?????. 2. ?? ??? ???, ??? ?????, StringBuilder? ???? ??? ? ??? ?? ????, ??? GC ??? ??????. 3. ??? ?? ?? ??? ????? ?? ??? ???? ?? ?????. 4. ??? ???, ?? ???? ????, ?? ???? ???, ??? ?? ????? ??????. 5. JVM ?? ?? ??, ???? ? ?? ? ?? ??? ???? ???? GC ??? ??????. 6. ?? ???? ??? ???, ?? ???? ?? ???? ???, ???? ?????, ?? ? ??? ??????. 7. JMH? ?? ? ???? ?? ??? ? ????

See all articles