新聞中心
PHP中有幾種主要的數(shù)據(jù)類型,通俗的解釋一下他們
數(shù)據(jù)類型有三種:
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了江漢免費(fèi)建站歡迎大家使用!
1.標(biāo)量數(shù)據(jù)類型
標(biāo)量數(shù)據(jù)類型包括以下幾種。
(1)boolean:布爾型
布爾變量是PHP變量中最簡單的。它保存一個(gè)True或者False值。其中True或者False是PHP的內(nèi)部關(guān)鍵字。設(shè)定一個(gè)布爾型的變量,只需將True或者False賦值給該變量
(2)string:字符串
字符串是連續(xù)的字符序列,字符串中的每個(gè)字符只占用一個(gè)字節(jié)。在PHP中,定義字符串有3種方式:
單引號(hào)方式,
雙引號(hào)方式,
Heredoc方式。
(3)integer:整數(shù)
整數(shù)數(shù)據(jù)類型只能包含整數(shù)。這些數(shù)據(jù)類型可以是正數(shù)或負(fù)數(shù)。在32位的操作系統(tǒng)中,有效的范圍是?2 147 483 648~+2 147 483 647。
(4)double:浮點(diǎn)數(shù)
浮點(diǎn)數(shù)據(jù)類型可以用來存儲(chǔ)數(shù)字,也可以保存小數(shù)。它提供的精度不整數(shù)大得多。在32位的操作系統(tǒng)中,有效的范圍是1.7E-308~1.7E+308。
2.復(fù)合數(shù)據(jù)類型
復(fù)合數(shù)據(jù)類型包括以下兩種。
(1)array:數(shù)組
可以是二維、三維或者多維,數(shù)組中的各元素可以是string、integer或double,也可以是array。
(2)object:對象類型
3.特殊數(shù)據(jù)類型
特殊數(shù)據(jù)類型包括以下兩種。
(1)resource:資源
資源是PHP內(nèi)的幾個(gè)函數(shù)所需要的特殊數(shù)據(jù)類型,由編程人員來分配。
(2)null:空值
空值是最簡單的數(shù)據(jù)類型。表示沒有為該變量設(shè)置任何值,另外,空值(NULL)不區(qū)分大小寫。
php如何關(guān)聯(lián)兩個(gè)或者多個(gè)數(shù)據(jù)表?
至少三個(gè)方法可以實(shí)現(xiàn):
一、使用視圖來實(shí)現(xiàn)多表聯(lián)合查詢,
例如:創(chuàng)建視圖:create view userstoposts as select u.name,u.qq,p.post_id,p.title, p.contents, p.contents from users as u,posts as p where u.name=p.name
二、直接使用表聯(lián)合查詢
例如:select u.name,u.qq,p.* from users as u,posts as p where u.name=p.name
三、結(jié)合PHP語言實(shí)現(xiàn)
例:1、
?php
$Sql="select *from posts";
$Result=@mysql_query($Sql);
while($rows=mysql_fetch_assoc($Result)){
$sql1="select name,qq from users where name='".$rows['name']."'";
$result1=@mysql_query($sql1);
$rows1=mysql_fetch_assoc($result1);
$OUTPUT[]=array(
'name'=$rows['name'],
'qq'=$rows1['qq'],
'post_id'=$rows['post_id'],
'title'=$rows['title'],
'contents'=$rows['contents']
);
}
print_r($OUTPUT);//可以你需要的結(jié)果輸出
?
php同時(shí)調(diào)用兩個(gè)表公共數(shù)據(jù) 怎么寫?
你得說清楚兩表情況,另外目的是什么.這樣問,沒有人能回答你.
我只能告訴你用sql的表連接.
select a.*,b.* from table_a a,table_b b where a.id = b.id
=====================
我假定你attid是兩表連接的關(guān)系字段
select a.*,b.* from A a,B b where a.attid=b.attid and uid='27528' order by a.itemid
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)
開始對一個(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)
斷開對數(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調(diào)用多表數(shù)據(jù)類型 php對接數(shù)據(jù)庫的表
路徑分享:http://www.dlmjj.cn/article/doehosi.html