php抓取app的数据库,PHP数据采集-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

php抓取app的数据库,PHP数据采集

Php通过get post获取app上传的参数,那php怎么提供数据给app呢

app可以直接发送http请求给服务器,然后php程序处理完之后,输出数据到一个页面,app获得这个页面就可以解析里面的数据。关于这个页面数据交换格式有很多成熟的方式,比如 xml,json。

创新互联是一家从事企业网站建设、成都网站建设、成都做网站、行业门户网站建设、网页设计制作的专业网站制作公司,拥有经验丰富的网站建设工程师和网页设计人员,具备各种规模与类型网站建设的实力,在网站建设领域树立了自己独特的设计风格。自公司成立以来曾独立设计制作的站点1000多家。

参考:

在PHP中怎么接收来自app的JSON数据

根据你的代码,你是用的是POST方法。

要在PHP中整体接收POST数据,有两种方法。

注意,要使用以下两种方法,Content-Type不能为multipart/form-data。

方法一:

使用:

file_get_contents('php://input')

其中,php://input是一个流,可以读取没有处理过的POST数据(即原始数据)。相较于$HTTP_RAW_POST_DATA而言,它给内存带来的压力较小,并且不需要特殊的php.ini设置。

方法二:

使用此方法,需要设置php.ini中的always_populate_raw_post_data值为On。

使用$HTTP_RAW_POST_DATA,包含了POST的原始数据。但这不是一个超全局变量,要在函数中使用它,必须声明为global,或使用$GLOBALS['HTTP_RAW_POST_DATA']代替。

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

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

(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抓取app的数据库,PHP数据采集
网页URL:http://kswsj.cn/article/heejse.html

其他资讯