Test the PHP dream database operation

Source: Internet
Author: User
Tags mysql code

Download dm6.0 development for windows in http://www.dameng.com:
In addition to enterprise-level functions such as database clusters, the development edition provides complete functions that support GB-level data volumes and multi-user concurrent access capabilities to meet the needs of various medium and small applications.
The development edition is free for developers to learn, test, and develop purposes. It cannot be used for commercial or other purposes such as production or operation.

Although for Windows2000 is described in the description, under Windows Server 2003, double-click setup.exe to install it smoothly.

After the installation is complete, there are two files under the D:/dmdbms/bin directory: php4_dm.dll and php5_dm.dll, which are used to provide extension interfaces for DM database, php4.0, and php5.0 respectively.

However, Apache cannot be started after php5_dm.dll extension is configured in the PHP. ini file in my apache2.2.8 + php5.2.5 environment. You have to install php4_dm.dll in iis6.0 + php4.4.7 for testing.

Add the DM configuration in the PHP. ini file:

[DM]
DM. allow_persistent = 1
DM. max_persistent =-1
DM. max_links =-1
DM. default_host = localhost
DM. default_db = System
DM. default_user = sysdba
DM. default_pw = sysdba
DM. connect_timeout = 10
DM. defaultll = 4096
DM. defaultbinmode = 1
DM. check_persistent = on
DM. Port = 12345

During installation, test data is installed together, so there is a user database bookshop. In this database, a "Mode" mytest is created, and the table teabl1 is created in this mode. To export an SQL script, see table structure:

Create Table "Table1" at "bookshop"
(
"NID" integer identity (1, 1 ),
"Sname" varchar (50 ),
"Nage" smallint default 0,
"Bgender" Boolean,
"Ddatetime" timestamp (0 ),
Primary Key ("NID") Storage (initial 1, next 1, minextents 1, on "primary", fillfactor 0)

The test code is similar to the MySQL code. The function is to insert a record, select all records, and display them:

<? PHP
$ Dbhost = 'localhost ';
$ Dbuser = 'sysdba ';
$ Dbpass = 'abcde54321 ';
$ Dbname = 'bookshop ';
$ Connect = dm_connect ($ dbhost, $ dbuser, $ dbpass );

If ($ Connect)
{
Echo 'successfully connected to DM database system ';
}
Else
{
Echo 'Connection to DM Database System failed ';
Echo dm_error ();
Exit;
}

Dm_select_db ($ dbname) or die ("select dB error .");

$ SQL = "insert into mytest. Table1 (sname, Nage, bgender) values ('name', 80, true )";
Dm_query ($ SQL );

If (dm_affected_rows ()> 0)
Echo "insert OK .";
Else
Echo "insert failed .";

$ SQL = "select * From mytest. Table1 ";
$ Result = dm_query ($ SQL );

Echo "<br> ";
While ($ ROW = dm_fetch_assoc ($ result ))
{
Echo $ row ["NID"]. "& nbsp ;". $ row ["sname"]. "& nbsp ;". $ row ["Nage"]. "& nbsp ;". $ row ["bgender"]. "<br> ";
}

/* Release resources */
Dm_free_result ($ result );

/* Disconnect */
Dm_close ($ Connect );

In Windows, the DM database management interface is still very easy to operate, faster than the first time you contact Oracle. Compared with MySQL, the concept of "schema" is added, but after quickly understanding its meaning and understanding it as the table prefix, encoding is not affected at all.
The GUI of the DM database Client Management Program does not seem to have powerful functions. Some detailed and considerate operations are not supported. For example, you cannot drag between two databases to copy or move tables.

For PHP programmers, the operation of DM database is very similar to the operation of MySQL database. The operation function is similar to replacing "MySQL" with "dm", and the other operations are basically unchanged. PHP programmers can quickly get started with programming for DM databases.

I just don't know if I can operate on DM's transactions, locks, stored procedures, and other advanced features through the PHP language. I hope to provide more detailed technical documents for programmers. Without the support of programmers, no one knows how powerful the database is.

Appendix:
The PHP extension functions provided by DM briefly describe the functions of each function:
Dm_connect: open a connection to the DM Server
Dm_pconnect: open a persistent connection to the DM Server
Dm_close: Close the DM connection
Dm_set_connect: sets the connection.
Dm_error: returns the text error message generated by the previous DM operation.
Dm_errno: returns the numerical encoding of the error message in the previous DM operation.
Dm_query: sends a DM query.
Dm_unbuffered_query: a row that sends an SQL query to DM and does not obtain or cache the result.
Dm_more_query_no_result:
Dm_db_query: sends a DM query.
Dm_affected_rows: gets the number of records affected by the previous DM operation.
Dm_create_db: Create a New DM Database
Dm_drop_db: discard (delete) a DM Database
Dm_escape_string: escape a string for dm_query
Dm_fetch_array: Get a row from the result set as an associated array, or a number array, or both
Dm_fetch_assoc: obtains a row from the result set as an associated array.
Dm_fetch_field: obtains column information from the result set and returns it as an object.
Dm_num_fields: number of fields in the result set.
Dm_fetch_lengths: the length of each output in the result set.
Dm_fetch_object: Get a row from the result set as an object
Dm_fetch_row: obtains a row from the result set as an enumerated array.
Dm_field_flags: obtains the identifier associated with the specified field from the result.
Dm_field_len: returns the length of the specified field.
Dm_field_name: obtains the field name of the specified field in the result.
Dm_field_seek: Set the pointer in the result set to the specified field offset.
Dm_field_table: obtains the name of the table where the specified field is located.
Dm_field_type: Specifies the field type in the result set.
Dm_free_result: releases the result memory.
Dm_get_server_info: gets information about the DM server.
Dm_list_dbs: list all databases on the DM Server
Dm_list_fields: list fields in DM results
Dm_list_tables: list the tables in the DM Database
Dm_num_rows: number of rows in the result set
Dm_ping: ping a server connection. If there is no connection, reconnect.
Dm_result: Get result data
Dm_insert_id: Get the ID generated by the previous insert operation
Dm_insert_id_ex: Get the ID generated by the previous insert operation
Dm_select_db: select the DM Database
Dm_tablename: Get the table name
Dm_data_seek: Move internal result pointer
Dm_db_name: Get result data

Author: Zhang Qing (mesh) Xi'an PHP Education Training Center
From mesh horizon: http://blog.why100000.com
Author Weibo: http://t.qq.com/zhangking
Why 100,000 computer learning networks: http://www.why100000.com
 

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.