日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

PHP技術(shù):txtSQL安裝手冊中文版_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:初學(xué)PHP指導(dǎo):php.ini 配置詳細(xì)選項(xiàng)
php.ini 或 php3.ini 是 PHP 在啟動時會讀取的配置文件。該文件的存放路徑為 /usr/local/lib/。在 PHP 3.x 版的配置文件為 php3.ini;而在 PHP 4.x 版改為 php.ini。若 PHP 安裝成服務(wù)器的模塊,則在 Web 服務(wù)器啟動執(zhí)行時會讀取,之后就不再讀取,因此改動

txtsql的最大優(yōu)點(diǎn)之一是文檔很詳細(xì),可惜,我在網(wǎng)上找了半天也找不到中文版的文檔,所以只好自己動手,利人利已吧,不過自己的E文水平自己是很清楚的,希望大家看了不會笑掉大牙才好,還希望大家多多指教。

歡迎使用txtSQL 2.2快速安裝手冊。這頁將指引你如何開始安裝txtSQL。

1-解壓縮下載包
2-配置類文件
2.1-目錄結(jié)構(gòu)
3-包含類文件
3.1-類實(shí)例
3.2-連接到txtSQL
3.3- 更改密碼
3.4-選擇一個數(shù)據(jù)庫
4-執(zhí)行SQL指令
4.1-指令的列表
4.2-顯示結(jié)果
5-從斷開txtSQL連接
6-差錯處理
7-已發(fā)布的txtSQL函數(shù)

1、解壓縮下載包

當(dāng)你打開.zip文件時,你將注意到有兩個文件: txtSQL.class.php和txtSQL.core.php。提取兩個文件到相同的目錄。新建一個任意名字的新目錄; 通常,它名為data。這將是包含數(shù)據(jù)庫的目錄。它能可以放在服務(wù)器上的任何地方,但是它通常位于以上兩個文件的同一目錄下。確保這個目錄權(quán)限是0755或者更高。現(xiàn)在返回到.zip文件找到\'txtsql.MYI\'提取它到我們剛剛建立的數(shù)據(jù)庫目錄。(譯者注:其實(shí)不用這么麻煩,.zip文件已經(jīng)組織好了,全部解壓到服務(wù)器上的任意目錄,并設(shè)置權(quán)限就行了)

2、配置類文件

使用txtSQL的第一步,配置類文件,這樣它才能被包含到可能要求它的php文件中。首先,你必須在文本編輯器中打開文件txtSQL.class.php 打開文件時將注意到一個版權(quán)聲明,其后是一些其它素材。隨后有這樣一行(缺省是第30行):
30. include_once(\'./txtSQL.core.php\');
這一行代碼使它包括txtSQL的的核心函數(shù)和類。方便php找到核心文件,你必須編輯單引號內(nèi)的內(nèi)容,讓它指向txtSQL.core.php文件。(譯者注:這個基本上也不用設(shè)置,源文件已經(jīng)配置好了!只有當(dāng)你的文件不在同一目錄時,才需要這么做)

2.1、目錄結(jié)構(gòu)

一個有效的數(shù)據(jù)庫目錄結(jié)構(gòu)應(yīng)該是這樣的:
+ datafolder (所有數(shù)據(jù)庫的保存目錄,比如上面新建的\'data\' )
+ database_name
+ table.FRM (列定義)
+ table.MYD (行數(shù)據(jù))
+ txtsql
+ txtsql.MYI (包含在壓縮包)
基本上,一個數(shù)據(jù)庫是主要的數(shù)據(jù)庫目錄下的一子目錄。
同時在數(shù)據(jù)庫目錄內(nèi)部是txtsql數(shù)據(jù)庫,壓縮包中的\'txtsql.MYI\'I。
在所有的數(shù)據(jù)庫內(nèi)部,一個數(shù)據(jù)表由兩個文件組成; table.FRM,和table.MYD。.FRM是列定義,另一個是數(shù)據(jù)行。

3、包含類文件

現(xiàn)在我們已經(jīng)配置完txtSQL2.2,我們能開始使用它。首先使用文本編輯器創(chuàng)造一個空白的php文件。保存為example.php。
為了簡單的說明,假設(shè)你把它保存在和\'txtSQL.class.php\'同樣的目錄下。
現(xiàn)在我們必須包括php類,在\'example.php中輸入:
<?php
include(\'./txtSQL.class.php\');
?>

3.1類實(shí)例

在面向?qū)ο缶幊? OOP)中,當(dāng)創(chuàng)建類時,一種特殊變量類型--個對象是自動地創(chuàng)造。
我們需要創(chuàng)造指向txtSQL類的一個對象,那么把這些添加到文件:
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
?>
在單引號中的文字,是包含所有數(shù)據(jù)庫的數(shù)據(jù)目錄的路徑。這個目錄下必須包含一個txtsql(大小寫敏感 )的目錄,目錄下應(yīng)該有一個\'txtsql.MYI\'的文件。這個文件包含操作數(shù)據(jù)庫所有用戶與和密碼。
這個目錄與文件已經(jīng)在txtSQL壓縮包中。一旦路徑是正確的,你可以繼續(xù)向前到下一段。

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

現(xiàn)在我們可以用正確的用戶名和密碼來連接數(shù)據(jù)庫了。
默認(rèn)的用戶名是root\',默認(rèn)的密碼是空。(強(qiáng)烈建議在下面的步驟中修改)
用下面的代碼來連接數(shù)據(jù)庫:
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // 默認(rèn)時是 sql->connect(\'root\', \'\');
?>

txtSQl這時會認(rèn)可你是它的用戶,準(zhǔn)許你訪問數(shù)據(jù)庫和表。
注意:參考手冊中有可用的命令清單。

3.3、更改密碼

如果你想更改管理員密碼(root),可以用grant_permissions() 函數(shù),grant_permissions() 函數(shù)這樣調(diào)用:
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->grant_permissions(action, user, pass [, newpass]);
?>
參數(shù) action(動作)可以是 add(添加), drop(刪除), or edit(編輯). newpass(新密碼)只有在你編輯(edit)用戶時才可用。user(用戶)是用你要操作的用戶名, pass是它的密碼。
例如, 如果你想改變用戶\'root\'的密碼為 \'bar\' (假設(shè)它還是空的), 我們可以這么做:
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->grant_permissions(\'edit\', \'root\', \'\', \'bar\');
?>

或者
新建一個用戶 \'foo\' 密碼為\'bar\'
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->grant_permissions(\'add\', \'foo\', \'bar\');
?>
或者
刪除一個用戶\'foo\' 密碼為 \'bar\'
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->grant_permissions(\'drop\', \'foo\', \'bar\');
?>
注意:你不用刪除用戶root\',如果沒有正確的密碼你也不能訪問任何數(shù)據(jù)。

3.4、選擇數(shù)據(jù)庫

像mySQL一樣, 在操作一個數(shù)據(jù)表之前,你必須先說明它在哪一個數(shù)據(jù)庫. 這個步驟不是必須的,因?yàn)槟憧梢栽诓僮鲿r指定使用哪一個數(shù)據(jù)庫.
我們使用下面的語句來選擇一個數(shù)據(jù)庫:
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->selectdb(\'test\'); //選擇了數(shù)據(jù)庫 \'test\'
?>


4、執(zhí)行指令

通常我們只要使用sql對象的各種方法下執(zhí)行指令。
例如:
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->selectdb(\'test\'); // 選擇了數(shù)據(jù)庫 \'test\'
results = sql->select(array(
\'db\' => \'test\', //這行不是必須的,因?yàn)槲覀円呀?jīng)選定了數(shù)據(jù)庫
\'table\' => \'test\',
\'where\' => array(\'id = 10\', \'and\', \'name =~ John Smith\'),
\'limit\' => array(0, 100)
));
?>


4.1、指令列表

txtSQL2.2支持的指令如下:
4.1- List of commands
showdbs()
createdb()
dropdb()
renamedb()
select()
insert()
update()
delete()
showtables()
createtable()
droptable()
altertable()
describe()
在執(zhí)行指令之前,你必須連接數(shù)據(jù)庫,不然會產(chǎn)生錯誤。手冊中會用詳細(xì)的指令說明和實(shí)例(隨后翻譯)。

4.2、顯示結(jié)果

results變量現(xiàn)在包含了表test\'中選中行的信息。
你可以用一個循環(huán)來實(shí)現(xiàn)顯示results中的所有結(jié)果。
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->selectdb(\'test\'); // database \'test\' is now selected
results=
sql->execute(\'select\',
array(\'select\' => array(\'id\', \'name\'),
\'db\' => \'test\',
\'table\' => \'test\',
\'where\' => array(\'id = 10\', \'and\', \'name =~ John Smith\'),
\'limit\' => array(0, 100))));
foreach ( results as key => row )
{
print \"ID: row[id], NAME: row[name]<BR>\n\";
}
?>


5-斷開txtSQL

用完之后斷開數(shù)據(jù)庫是一個好習(xí)慣。斷開用 disconnect()函數(shù)。
<?php
include(\'./txtSQL.class.php\');
sql = new txtSQL(\'./data\');
sql->connect(username, password); // default is sql->connect(\'root\', \'\');
sql->selectdb(\'test\'); // database \'test\' is now selected
results=
sql->execute(\'select\',
array(\'select\' => array(\'id\', \'name\'),
\'db\' => \'test\',
\'table\' => \'test\',
\'where\' => array(\'id = 10\', \'and\', \'name =~ John Smith\'),
\'limit\' => array(0, 100))));
foreach ( results as key => row )
{
print \"ID: row[id], NAME: row[name]<BR>\n\";
}
sql->disconnect();
?>


6-錯誤處理

txtSQL 包含錯誤處理能力。主要用以下的函數(shù):
strict()
get_last_error()
last_error()
errordump()

詳細(xì)瀏覽:txtSQL (2.2 Final)
http://txtsql.sourceforge.net/site/index.php

分享:smarty修改php模板教程
smarty,最得名,用之,配置語法都是菜鳥級別的,沒的說,先列一點(diǎn)我使用的: {foreach key=key item=MMSPAN from=TSortUrl} td align=left valign=bottom height=25 {if mysort eq key} img src=images/sort_{key}_1.gif height=25 border=0 /

來源:模板無憂//所屬分類:PHP教程/更新時間:2012-06-15
相關(guān)PHP教程