Learn PHP Technology: txtSQL Installation Manual Chinese version _php tutorial

Source: Internet
Author: User
Tags learn php
txtSQL one of the greatest advantages of the document is very detailed, unfortunately, I found on the internet for half a day can not find the Chinese version of the document, so have to do their own hands, profit has it, but their e-level is very clear, I hope you see not laughed just good, but also hope that we have a lot of advice.

Welcome to the txtSQL 2.2 quick installation manual. This page will guide you on how to start installing txtSQL.

1-Unzip the download package
2-Configuration class file
2.1-Directory structure
3-Include class file
3.1-class instance
3.2-Connect to txtSQL
3.3-Change Password
3.4-Select a database
4-Execute SQL command
4.1-List of instructions
4.2-Show Results
5-Connection from disconnect txtSQL
6-Error handling
7-Published txtSQL function

1. Unzip the download package

When you open a. zip file, you will notice that there are two files: txtSQL.class.php and txtSQL.core.php. Extract two files to the same directory. Create a new directory of any name, usually named data. This will be the directory containing the database. It can be placed anywhere on the server, but it is usually located in the same directory as the two files above. Make sure that the directory permissions are 0755 or higher. Now return to the. zip file to find xtsql.myi extract it to the database directory we just created. (Translator Note: In fact, not so troublesome,. zip files have been organized, all extracted to any directory on the server, and set permissions on the line)

2. Configuration class file

Using the first step of txtSQL, configure the class file so that it can be included in the PHP file that may require it. First, you must open the file in a text editor txtSQL.class.php a copyright notice when you open the file, followed by some other material. Then there is this line (the default is line 30th):
Include_once (./txtsql.core.php);
This line of code makes it include the core functions and classes of txtsql. To facilitate PHP to find the core file, you must edit the contents of the single quotation mark to point to the txtSQL.core.php file. (Translator Note: This basically does not have to set up, the source file has been configured!) You only need to do this if your file is not in the same directory)

2.1. Directory Structure

A valid database directory structure should look like this:
+ datafolder (save directory for all databases, such as the new data above)
+ database_name
+ table. FRM (column definition)
+ table. MYD (Row data)
+ txtSQL
+ txtSQL. MYI (included in the compressed package)
Basically, a database is a subdirectory under the primary database directory.
Also inside the database directory is the TXTSQL database, which compresses the xtsql in the package. Myii.
Within all databases, a data table consists of two files; FRM, and table. MYD. The frm is a column definition and the other is a data row.

3. Include class file

Now that we have finished configuring txtSQL2.2, we can start using it. First use a text editor to create a blank php file. Save As example.php.
For the sake of simple explanation, suppose you keep it in the same directory as xtSQL.class.php.
Now we must include the PHP class and enter it in the example.php:
Include (./txtsql.class.php);
?>

3.1 class Instances

In object-oriented programming (OOP), when creating a class, a special variable type-an object is created automatically.
We need to create an object that points to the txtSQL class, then add these to the file:
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
?>
The text in single quotation marks is the path to the data directory that contains all the databases. This directory must contain a txtsql (case-sensitive) directory, the directory should have a xtsql. The Myi file. This file contains all users and passwords for manipulating the database.
This directory and the file are already in the txtSQL archive package. Once the path is correct, you can continue forward to the next paragraph.

3.2 Connecting the database

Now we can connect to the database with the correct username and password.
The default user name is root, and the default password is empty. (It is strongly recommended to modify it in the following steps)
Use the following code to connect to the database:
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); The default is $sql->connect (oot, \);
?>
txtSQL will then recognize you as its user, allowing you to access the database and tables.
Note: A list of commands is available in the reference manual.

3.3. Change your password

If you want to change the administrator password (root), you can use the Grant_permissions () function, which is called by the Grant_permissions () function:
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->grant_permissions ($action, $user, $pass [, $newpass]);
?> parameters $action (Actions) can be add (add), drop (delete), or edit. $newpass (new password) is available only when you edit the user. $user (user) is the user name you want to manipulate, $pass is its password.
For example, if you want to change the user oot's password to AR (assuming it's still empty), we can do this:
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->grant_permissions (edit, oot, \, AR);
?>
Or
Create a new user foo password for AR
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->grant_permissions (Add, foo, AR);
?> or
Delete a user foo password for AR
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->grant_permissions (drop, foo, AR);
?> Note: You do not have to delete the user root, if you do not have the correct password you can not access any data.

3.4. Select Database

Like MySQL, before you can manipulate a data table, you must first indicate which database it is in. This step is not required because you can specify which database to use during the operation.
We use the following statement to select a database:
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->selectdb (EST); Database was selected EST
?>

4. Execution Instructions

Usually we just use the various methods of the $sql object to execute the instruction.
For example:
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->selectdb (EST); Database was selected EST
$results = $sql->select (Array (
db = Est,//This line is not required because we have selected the database
Able = EST,
where = = Array (id = ten, and, Ame =~ John Smith),
Limit = = Array (0, 100)
));
?>

4.1. Instruction List

txtSQL2.2 supports the following directives:
4.1-list of commands
Showdbs ()
Createdb ()
Dropdb ()
Renamedb ()
Select ()
Insert ()
Update ()
Delete ()
Showtables ()
CreateTable ()
Droptable ()
Altertable ()
Describe ()
You must connect to the database before executing the instruction, or you will generate an error. Detailed instruction instructions and examples will be used in the manual (translated later).

4.2. Display results

The $results variable now contains the information for the row in the table test.
You can use a loop to implement all the results shown in $results.
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->selectdb (EST); Database EST is now selected
$results =
$sql->execute (SELECT,
Array (select + = Array (ID, AME),
db = Est,
Able = EST,
where = = Array (id = ten, and, Ame =~ John Smith),
Limit = = Array (0, 100)));
foreach ($results as $key = $row)
{
Print "ID: $row [id], name: $row [Name]
";
}
?>

5-Disconnecting txtSQL

It is a good habit to disconnect the database after it is exhausted. Disconnect with the disconnect () function.
Include (./txtsql.class.php);
$sql = new TxtSQL (./data);
$sql->connect ($username, $password); Default is $sql->connect (oot, \);
$sql->selectdb (EST); Database EST is now selected
$results =
$sql->execute (SELECT,
Array (select + = Array (ID, AME),
db = Est,
Able = EST,
where = = Array (id = ten, and, Ame =~ John Smith),
Limit = = Array (0, 100)));
foreach ($results as $key = $row)

http://www.bkjia.com/PHPjc/531661.html www.bkjia.com true http://www.bkjia.com/PHPjc/531661.html techarticle one of the greatest advantages of txtsql is that the document is very detailed, unfortunately, I found on the internet for half a day can not find the Chinese version of the document, so have to do their own hands, Lee has it, but their e-text level ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.