php三種數(shù)據(jù)庫操作 php7數(shù)據(jù)庫操作

thinkphp數(shù)據(jù)庫操作

要先create再add,create可以根據(jù)表單自動(dòng)創(chuàng)建數(shù)據(jù)庫數(shù)據(jù),也可以對(duì)傳入的參數(shù)進(jìn)行驗(yàn)證和過濾(在model里用_validate指定規(guī)則)。add直接插入create之后的數(shù)據(jù),或者把傳入的數(shù)組直接插入數(shù)據(jù)庫

創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司一直秉承“誠信做人,踏實(shí)做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個(gè)客戶多一個(gè)朋友!專注中小微企業(yè)官網(wǎng)定制,成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站,塑造企業(yè)網(wǎng)絡(luò)形象打造互聯(lián)網(wǎng)企業(yè)效應(yīng)。

PHP調(diào)用三種數(shù)據(jù)庫的方法(3)

Oracle(甲骨文)是世界上最為流行的關(guān)系數(shù)據(jù)庫。它是大公司推崇的工業(yè)化的強(qiáng)有力的引擎。我們先看看其相關(guān)的函數(shù):

(1)integer

ora_logon(string

user

,

string

password)

開始對(duì)一個(gè)Oracle數(shù)據(jù)庫服務(wù)器的連接。

(2)integer

ora_open(integer

connection)

打開給出的連接的游標(biāo)。

(3)integer

ora_do(integer

connection,

string

query)

在給出的連接上執(zhí)行查詢。PHP生成一個(gè)指示器,解析查詢,并執(zhí)行之。

(4)integer

ora_parse(integer

cursor,

string

query)

解析一個(gè)查詢并準(zhǔn)備好執(zhí)行。

(5)boolean

ora_exec(integer

cursor)

執(zhí)行一個(gè)先前由ora_parse函數(shù)解析過的查詢。

(6)boolean

ora_fetch(integer

cursor)

此函數(shù)會(huì)使得一個(gè)執(zhí)行過的查詢中的行被取到指示器中。這使得您可以調(diào)用ora_getcolumn函數(shù)。

(7)string

ora_getcolumn(integer

cursor,

integer

column)

返回當(dāng)前的值。列由零開始的數(shù)字索引。

(8)boolean

ora_logoff(integer

connection)

斷開對(duì)數(shù)據(jù)庫服務(wù)器的鏈接。

以下是向ORACLE數(shù)據(jù)庫插入數(shù)據(jù)的示例程序:

html

headtitle向ORACLE數(shù)據(jù)庫中插入數(shù)據(jù)/title/head

body

form

action="?echo

$PHP_SELF;?"

method="post"

table

border="1"

cellspacing="0"

cellpadding="0"

tr

thID/th

thname/th

thDescription/th

/tr

tr

tdinput

type="text"

name="name"

maxlength="50"

size="10"/td

tdinput

type="text"

name="email"

maxlength="255"

size="30"/td

tdinput

type="text"

name="Description"

maxlength="255"

size="50"/td

/tr

tr

align="center"

td

colspan="3"input

type="submit"

value="提交" input

type="reset"

value="重寫"/td

/tr

/table

/form

?

//先設(shè)置兩個(gè)環(huán)境變量ORACLE_HOME,ORACLE_SID

putenv("ORACLE_HOME=/oracle/app/oracle/product/8.0.4");

putenv("ORACLE_SID=ora8");

//設(shè)置網(wǎng)頁顯示中文

putenv("NLS_LANG=Simplified_Chinese.zhs16cgb231280");

if($connection=ora_logon("scott","tiger"))

{

//庫表test有ID,name,Description三項(xiàng)

$sql

=

'insert

into

test(ID,name,Description)

values

';

$sql

.=

'(''

.

$ID

.

'',''

.

$name

.

'',''.

$Description

.

'')';

if($cursor=ora_do($connect,$sql))

{

print("insert

finished!");

}

$query

=

'select

*

from

test';

if($cursor=ora_do($connect,$query))

{

ora_fetch($cursor);

$content0=ora_getcolumn($cursor,0);

$content1=ora_getcolumn($cursor,1);

$content2=ora_getcolumn($cursor,2);

print("$content0");

print("$content1");

print("$content2");

ora_close($cursor);

}

ora_logoff($connection);

}

?

/body

/html

php怎么操作數(shù)據(jù)庫

//鏈接數(shù)據(jù)庫

$db=mysql_connect("localhost", "root","123456");

$sqlname="database";

mysql_select_db($sqlname,$db);

session_start();

mysql_query("SET NAMES 'utf8'",$db);

?

?

//創(chuàng)建結(jié)果集

$sql = "SELECT * FROM kecheng";

$result = mysql_query($sql);

$rs= mysql_fetch_array($result);

?

?

//修改數(shù)據(jù)

$sql = "UPDATE news SET title='1111' where news_id=1";

$result = mysql_query($sql);

?

?

//刪除數(shù)據(jù)

$sql = "DELETE from news where news_id=1";

$result = mysql_query($sql);

?

?

//添加數(shù)據(jù)

$sql = "INSERT INTO news (title,fenshu) VALUES ('a',1)"

$result = mysql_query($sql);

?

php連接access數(shù)據(jù)庫代碼

php教程

連接access數(shù)據(jù)庫教程代碼

下面提供三種php連接access數(shù)據(jù)庫方法,一種是利用php的pdo,一種是odbc,com接口來與access數(shù)據(jù)庫連接哦。

*/

//利用pdo與access數(shù)據(jù)庫連接

$path

="f:font";

$conn

=

new

pdo("sqlite:$path");

if(

$conn

)

{

echo

('connection

pdo

success');

}

else

{

echo

('cnnection

pdo

fail

,plase

check

database

server!');

}

//利用

odbc_connect連接數(shù)據(jù)庫

$conn

=

odbc_connect("dbdsn","admin","123");

//連接數(shù)據(jù)源

$doquery=odbc_exec($conn,"select

*

from

表名

where

條件");//執(zhí)行查詢

//利用com接口連接access數(shù)據(jù)庫

$conn=new

com("adodb.connection");

$dsn="driver={microsoft

access

driver

(*.mdb)};dbq=".realpath("path/db1.mdb");

$conn-open($dsn);

新聞名稱:php三種數(shù)據(jù)庫操作 php7數(shù)據(jù)庫操作
鏈接分享:http://muchs.cn/article36/doshpsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、Google、動(dòng)態(tài)網(wǎng)站App設(shè)計(jì)、ChatGPT網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司