Professional Documents
Culture Documents
SUPERGLOBAL VARIABLES
$_SERVER
is an array containing information such as headers, paths, and script locations.
entries were created by the web server.
Index ‘PHP_SELF’ contains the filename of the currently executing script.
$_GET
an associative array variables passed to the current script via the URL parameters.
$_POST
an associative array of variables passed to the current script via the HTTP POST method.
$_REQUEST
an associative array that by default contains the contents of $_GET, $_POST, and $_COOKIE
$_COOKIE
an associative array of variables passed to the current script via HTTP Cookies
$_SESSION
an associative array containing session variables available to the script
$_ENV
an associative array of variables passed to the current script via the environment method
Example
Output: before button was clicked Output: submit get button was clicked
Output: submit post button was clicked
COOKIES
are mechanism for storing data in the remote browser and thus tracking or identifying return
users.
small amount of information containing variable=value pair (user’s computer).
users can refuse to accepts cookies.
Managing cookies can be done using setcookie() function
syntax: setcookie()
bool setcookie ( string $name [, string $value [, int
$expire = 0 [, string $path [, string $domain [, bool
$secure = false [, bool $httponly = false ]]]]]] )
Example: PHPUnsetSession.php
Example: PHPDisplaySession.php
Example: PHPDeleteSession.php
REGULAR EXPRESSION
Symbol Description
Example
Example Description
‘/hello/’ It will match the word hello
‘/^hello/’ It will match hello at the start of a string.
Possible matches are hello or helloworld,
but not worldhello
‘/hello$/’ It will match hello at the end of a string.
‘/he.o/’ It will match any character between he and
o. Possible matches are helo or heyo, but
not hello
‘/he?llo/’ It will match either llo or hello
‘/hello+/’ It will match hello on or more time. E.g.
hello or hellohello
‘/he*llo/’ Matches llo, hello or hehello, but not
hellooo
‘/hello|world/’ It will either match the word hello or world
‘/(A-Z)/’ Using it with the hyphen character, this
pattern will match every uppercase
character from A to Z. E.g. A, B, C…
‘/[abc]/’ It will match any single character a, b or c
‘/abc{1}/’ Matches precisely one c character after the
characters ab. E.g. matchesabc, but not
abcc
‘/abc{1,}/’ Matches one or more c character after the
characters ab. E.g. matches abcor abcc
‘/abc{2,4}/’ Matches between two and four c character
after the characters ab. E.g. matches abcc,
abccc or abcccc, but not abc
MODULE 6
Subtopic 1: DATABASE
INTODUCTION TO DATABASES
Database - is an ordered collection of information from which a computer program can quickly
access.
Information stored in computer databases is actually stored in tables similar to spreadsheet.
A record in a database is a single complete set of related information.
Fields - are the individual categories of information stored in a record.
RELATIONAL DATABASE
A BIT HISTORY
FEATURES OF SQL
According to the article of Ian Gilfillan in 2004, the following are the claimed features of MySQL:
High availability
High scalability
High performance
Console Base
mysql >
Go to the Command Window
Start\Run
Type command or cmd
Go to the MySQL path
C:\xampp\mysql\bin\mysql –u root –p
C:\xampp\mysql\bin\mysql –u root
**Enter password if there is any.
Type commands in MySQL prompt which looks like this:
mysql >
MYSQL LOG IN
MYSQL PROMPTS
PROMPT MEANING
mysql> Ready for a new command
-> Waiting for the next line of multiple line command.
‘> Waiting for next line, waiting for completion of a string that began with single
quote (‘ ‘ ‘).
“> Waiting for next line, waiting for completion of a string that began in double quote
(‘ “ ‘).
`> Waiting for next line, waiting for completion of an identifier that began with a
backtick (‘ ` ‘).
/*> Waiting for next line, waiting for completion of a comment that began with /*.
BASIC COMMANDS
To clear command:
mysql > \c
Get status from the server:
mysql > \s
Need help?:
mysql > \h
mysql > ?
mysql > \?
EXAMPLE
BASIC COMMANDS
Example
BASIC COMMANDS
To quit
mysql > \q
DATABASE CREATION
Syntax:
CREATE DATABASE ;
Example:
TABLE CREATION
Syntax
CREATE TABLE <table name> (field name field type(size) condition...);
SAMPLE SCREEN
mysql> create table primaryTable (id int not null auto_increment, name varchar(30), primary
key (id));
mysql> create table keyTable (id int not null auto_increment, name varchar(30), key (id));
mysql> create table uniqueTable (id int not null auto_increment, name varchar(30), unique key
(id));
Example
MODIFYING THE TABLE STRUCTURE
mysql > INSERT INTO tblStudent VALUES (10001, ‘Juan Dela Cruz’);
To view use ‘SELECT’ command:
Syntax: SELECT * FROM <table name>;
Example:
mysql> UPDATE tblStudent SET name=‘Juan Dela Peña’, gender=‘M’ WHERE id=‘10001’;
DELETING OF COLUMNS
Syntax: DELETE FROM <table name> WHERE <column name> = <value>;
TO DELETE A TABLE
Syntax: DROP TABLE <table name>;
TO DELETE DATABASE
Syntax: DROP DATABASE <database name>;