Lamp theory Finishing

Source: Internet
Author: User
Tags apc mysql client

About PHP

Official website: http://www.php.net

I. Introduction of PHP

PHP is a generic server-side scripting language, which is used primarily for web development to implement dynamic Web pages, and is one of the first server-side scripting languages to implement scripts embedded in HTML source documents. PHP also provides a command-line interface, so it can also be used as a standalone shell on most systems.

Rasmus Lerdorf began developing PHP in 1994 as a group of Perl scripts that were Rasmus Lerdorf called the "Personal Home Page Tool", which can be used to display the author's CV and record user access to his or her website. Later, Rasmus Lerdorf used the C language to rewrite these Perl scripts as CGI programs, adding the ability to run Web Forms and the characteristics of interacting with the database, and renaming them to "Personal Home page/forms Interpreter "or" PHP/FI ". At this point, php/fi can already be used to develop a simple dynamic Web application, which is PHP 1.0. In June 1995, Rasmus Lerdorf posted its php in the comp.infosystems.www.authoring.cgi usenet discussion group, where PHP began to come into view. In 1997, its version 2.0 was released.

In 1997, two Israeli programmers Zeev Suraski and Andi Gutmans rewritten PHP's parser (parser) as the basis for PHP's development to 3.0, and since then renamed PHP Php:hypertext preprocessor. Since then, the two programmers began rewriting the entire PHP core, and in 1999 released the Zend Engine 1.0, which also means the birth of PHP 4.0. In July 2004, Zend Engine 2.0 was released, which also brought PHP into the PHP5 era. PHP5 contains a number of important new features, such as enhanced object-oriented programming support, support for the PDO (PHP Data Objects) extension mechanism, and a series of improvements to PHP performance.

Second, PHP Zend Engine

Zend Engine is an open source, PHP scripting language interpreter, originally developed by the Technion Technion students Andi Gutmans and Zeev Suraski, and Zend is the name of this two-person collectively. Later, the two men jointly founded the Zend Technologies company.

Zend Engine 1.0 was released in 1999 with PHP 4, developed by the C language and highly optimized and can be used as a backend module for PHP. Zend Engine provides PHP with memory and resource management capabilities as well as other standard services, and its high performance, reliability, and scalability play an important role in promoting PHP as a popular language.

The advent of the Zend engine divides the process of PHP code into two stages: first, parsing the PHP code and converting it into a binary format called Zend opcode (Java-like bytecode) and storing it in memory; the second stage is using Zend Engine to perform these converted opcode.

Third, php's opcode

OpCode is a PHP script-compiled intermediate language, like Java's bytecode, or. Net of MSL. PHP executes PHP script code generally through the following 4 steps (to be exact, it should be PHP language engine Zend):
1, scanning (lexing)--Convert the PHP code to a language fragment (Tokens)
2. parsing--converts tokens into simple and meaningful expressions
3. compilation--compile the expression into Opocdes
4, execution--sequential execution of opcodes, one at a time, thus realizing the function of PHP script

iv. Accelerator for PHP

Special PHP-based extension mechanisms, such as opcode cache extensions, can also cache opcode in PHP's shared memory, allowing you to skip the compilation phase to improve performance when subsequent executions of the same piece of code are repeated. It can also be seen that these accelerators do not really improve the speed of the opcode, but only by analyzing the opcode and rearranging them to achieve the purpose of fast execution.

The common PHP accelerators are:

1. APC (alternative PHP Cache)
Following PHP License's open source framework, PHP opcode cache Accelerator, the current version is not available for PHP 5.4. Project address, Http://pecl.php.net/package/APC.

2, Eaccelerator
Originating from Turck MMCache, the earlier version included a PHP encoder and PHP loader, and currently encoder is not supported. Project address, http://eaccelerator.net/.

3, XCache
Fast and stable php opcode cache, rigorously tested and heavily used in production environments. Project Address, http://xcache.lighttpd.net/

4. Zend Optimizer and Zend Guard Loader
Zend Optimizer is not a opcode accelerator, it is a free, closed-source PHP extension provided by Zend Technologies for PHP5.2 and previous versions, capable of running encrypted PHP code or fuzzy code generated by Zend guard. The Zend Guard loader, however, is an extension that is designed for PHP5.3 similar to Zend Optimizer functionality. Project Address, Http://www.zend.com/en/products/guard/runtime-decoders

5, Nusphere phpexpress
Nusphere's Open source PHP accelerator, which supports loading PHP program files encoded by Nusphere PHP encoder, and enables faster execution of regular PHP files. Project Address, http://www.nusphere.com/products/phpexpress.htm

Five, PHP source directory structure

PHP's source code is structurally clear. Its code root contains a number of documentation and design scenarios, and provides the following subdirectories:

1, build--as the name implies, here are mainly to put some source code compilation related files, such as the beginning of the construction of the buildconf script and some check the environment of the script.
2, ext--official extension directory, including the vast majority of PHP functions of the definition and implementation, such as the array series, PDO series, SPL series, such as the implementation of functions. Personal development extensions can also be placed in this directory when testing, to facilitate testing and so on.
3, main--here is the most core PHP file, is to implement PHP infrastructure, here and Zend engine is not the same, Zend engine mainly to achieve the language of the most core language operating environment.
4, Zend--zend engine implementation directory, such as script lexical parsing, opcode implementation and extension mechanism implementation and so on.
5, Pear--php extension and application warehouse, including pear core files.
6, sapi--contains the various server abstraction layer code, such as Apache mod_php,cgi,fastcgi and FPM and so on interface.
7, tsrm--php thread safety is built on the TSRM Library, PHP implementation Common *G macros are usually TSRM encapsulation, TSRM (thread safe Resource manager) thread safety resource Manager.
8, tests--php test script collection, contains PHP various functions of the test files.
9, win32--This directory mainly includes some Windows platform related implementations, such as SOKCET implementation under Windows and the *nix platform is not the same, but also includes the Windows compiled PHP-related scripts.

About databases and MySQL

One, RDBMS (relational data Base Management system--relational database management system) should have the function

1. Creation, deletion and modification of database

2. Create a table, delete a table, modify a table

3. Creation and deletion of indexes

4. User and Rights Management

5, the data increase, delete, check, change

Second, the database language classification:

1. Dml:data manapulate language:--Data Manipulation language
INSERT, REPLACE, UPDATE, DELETE
2. Ddl:data defination lanuage--Data Definition language
CREATE, ALTER, DROP
3. Dcl:data control language--data controlling language
GRANT, REVOKE

4. SELECT

Third, the role of RDBMS

1. Data management Independence
2. Effectively complete data access
3. Data integrity and security
4. Centralized data management
5. Concurrent storage and failure recovery
6. Reduce Application Development time

Iv. Relational database objects:

1. Library

2. Table

3. Index

4. View

5. Constraints

6. Stored Procedures

7. Storage function

8. Trigger

9. Cursors

10. Users

11. Permissions

12. Business

Five, SQL interface:

Oracle:pl/sql

SQL Server T-SQL

Vi. MySQL (http://www.mysql.com/)

MySQL:
Community Edtion Community Version
Enterprise Edtion Corporate Edition

Package format:
1. Package Manager-specific format
RPM package, EXE format, etc.
2. Universal binary Format
3. SOURCE program

Running mode for MySQL client:
  1. Interactive mode

Note: the command category in interactive mode:
    Client commands : commands executed on the client itself, for example: quit
    server-side command : The command to be sent to the server driven by server to execute and return to the client must use the statement terminator, which defaults to a semicolon
  2. Batch mode --perform data operation by executing MySQL script

Basic MySQL statement:

Ddl:

Create a database
CREATE DATABASE db_name;
CREATE DATABASE [IF not EXISTS] db_name;

Deleting a database
DROP DATABASE [IF EXISTS] db_name;

Create a table
CREATE TABLE tb_name (col1,col2,...);

To view a table in a library

SHOW TABLES from Db_name;


View the structure of a table

DESC Tb_name;

To delete a table:

DROP TABLE Tb_name;

Modify Table
ALTER TABLE Tb_name
MODIFY modifying the properties of a field
Change the name and properties of a field
Add Field
Drop Delete Field

Note: Detailed usage can be queried by the help ALTER TABLE

Dml:

  Inserting data
INSERT into Tb_name (col1,col2,...) values| VALUE (' STRING ', NUM,...);
INSERT into Tb_name (col1,col2,...) values| VALUE (' string ', num,...), (' String ', num,...);


Change data
UPDATE tb_name SET Column=value WHERE

  

Delete data

DELETE from Tb_name WHERE CONDITION;

Querying data
SELECT field from Tb_name WHERE CONDITION
    *: All fields
WHERE: No condition indicates all rows are displayed;

Create user
CREATE USER ' USERNAME ' @ ' HOST ' [identified by ' PASSWORD '];

The host field may be: Host, IP, HOSTNAME, NETWORK, or wildcard

_: Matches any single character, 172.16.0._
%: matches any character;

Delete User
DROP USER ' USERNAME ' @ ' HOST ';

DCL:

Authorized
GRANT Pri1,pri2,... On Db_name. Tb_name to ' USERNAME ' @ ' HOST ' [identified by ' PASSWORD '];

Cancel Authorization
REVOKE Pri1,pri2,... On Db_name. Tb_name from ' USERNAME ' @ ' HOST ';

To view the user's authorization

SHOW GRANTS for ' USERNAME ' @ ' HOST ';

To set a password for a user:
1, Mysql>set PASSWORD for ' USERNAME ' @ ' HOST ' =password (' PASSWORD ');

2, # mysqladmin-uusername-hhost-p password ' password '

3. mysql> UPDATE user SET Password=password (' Password ') WHERE user= ' root ' and host= ' 127.0.0.1 ';

Note: Each time you change or set a password, you need to execute the flush privileges; let MySQL re-read the configuration file into memory, otherwise the new password does not take effect.

Lamp theory Finishing

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.