重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

PHp调用数据库视图,php网页调用数据库

PHP调用三种数据库的方法(3)

Oracle(甲骨文)是世界上最为流行的关系数据库。它是大公司推崇的工业化的强有力的引擎。我们先看看其相关的函数:

从策划到设计制作,每一步都追求做到细腻,制作可持续发展的企业网站。为客户提供网站设计制作、成都网站制作、网站策划、网页设计、域名申请、网络空间、网络营销、VI设计、 网站改版、漏洞修补等服务。为客户提供更好的一站式互联网解决方案,以客户的口碑塑造优易品牌,携手广大客户,共同发展进步。

(1)integer

ora_logon(string

user

,

string

password)

开始对一个Oracle数据库服务器的连接。

(2)integer

ora_open(integer

connection)

打开给出的连接的游标。

(3)integer

ora_do(integer

connection,

string

query)

在给出的连接上执行查询。PHP生成一个指示器,解析查询,并执行之。

(4)integer

ora_parse(integer

cursor,

string

query)

解析一个查询并准备好执行。

(5)boolean

ora_exec(integer

cursor)

执行一个先前由ora_parse函数解析过的查询。

(6)boolean

ora_fetch(integer

cursor)

此函数会使得一个执行过的查询中的行被取到指示器中。这使得您可以调用ora_getcolumn函数。

(7)string

ora_getcolumn(integer

cursor,

integer

column)

返回当前的值。列由零开始的数字索引。

(8)boolean

ora_logoff(integer

connection)

断开对数据库服务器的链接。

以下是向ORACLE数据库插入数据的示例程序:

html

headtitle向ORACLE数据库中插入数据/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

?

//先设置两个环境变量ORACLE_HOME,ORACLE_SID

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

putenv("ORACLE_SID=ora8");

//设置网页显示中文

putenv("NLS_LANG=Simplified_Chinese.zhs16cgb231280");

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

{

//库表test有ID,name,Description三项

$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中如何调用数据库中的图片并且显示到页面

php是采用二进制形式存储图片及读取显示的,首先通过代码创建数据表,然后上传图片服务器再通过浏览器显示,具体编程代码举例:

1、首先需要创建数据表,具体代码如下图所示。

2、然后写上传图片到服务器的页面 upimage.html用来将图片上传数据库,如下图所示代码。

3、处理图片上传的php upimage.php文件,如下图所示图片已储存到数据库。

4、显示图片的php getimage.php文件,为了看一下效果提前把ID写入代码。

5、预览网站从数据库中提取了图片,并显示到页面上。

thinkphp怎么直接使用数据库中的视图

1、插入数据:insert into 视图名(视图列1,视图列2) values(值1、值2)

2、更新数据:update 视图名 set 列名=值 where 更新条件

3、删除数据:delete from 视图名 where 删除条件

4、查询数据:select 要查询的列1,要查询的列2 from 视图名 where 查询条件


本文标题:PHp调用数据库视图,php网页调用数据库
网址分享:http://cqcxhl.cn/article/dsgiogo.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP