Fungsi-Fungsi Pada PHP dan MYSQL

Posted on Updated on

Fungsi-fungsi pada PHP dan MYSQL antara lain:

MySQL Functions di PHP

· int mysql_affected_rows ([int link_identifier]);

jumlah baris yang terpengaruh oleh query terakhir

· int mysql_close ([int link_identifier]);

menutup koneksi MySQL

· int mysql_connect ([string hostname], [string username], [string password]);

membuka koneksi ke server MySQL

· int mysql_create_db (string database_name, int link_identifier);

membuat database MySQL

· int mysql_data_seek (int result_identifier, int row_number);

memindahkan pointer baris internal

· string mysql_dbname (string result, int I);

mengambil nama database MySQL saat ini

· int mysql_db_query (string database, string query, int link_identifier);

mengirim query MySQL

· int mysql_drop_db (string database_name, int link_identifier);

menghapus database MySQL

· int mysql_errno ();

mengembalikan nomor error pada pemanggilan (call) MySQL terakhir

· string mysql_error ();

mengembalikan pesan error dari pemanggilan MySQL terakhir

· array mysql_fetch_array (int result);

mengambil (fetch) baris sebagai array

· object mysql_fetch_field (int result, [int field_offset]);

mengambil informasi field

· array mysql_fetch_lengths (int result);

mengambil panjang dari hasil untuk tiap field-nya

· int mysql_fetch_object (int result);

mengambil baris sebagai object

· array mysql_fetch_row (int result);

mengabil baris sebagai array item

· string mysql_field_name (string result, int field_index);

mengambil nama field

· int mysql_field_seek (int result, int field_offset);

mengeset offset field

· string mysql_field_table (int result, int field_offset);

mengambil nama tabel untuk sebuah field dalam himpunan hasil query

· string mysql_field_type (string result, int field_offset);

mengambil tipe field

· string mysql_field_flags (string result, int field_offset);

mengambil atribut field

· int mysql_field_len (string result, int field_offset);

mengambil panjang field

· int mysql_free_result (int result);

membebaskan memori untuk penyimpanan hasil query

· int mysql_insert_id (void);

mengambil id yang dibangkitkan dari INSERT terakhir

· int mysql_list_fields (string database, string tablename, [int link_identifier]);

daftar field hasil query

· int mysql_list_dbs (void);

daftar database MySQL di server

· int mysql_list_tables (string database);

daftar tabel dalam sebuah dtabase MySQL

· int mysql_num_fields (int result);

mengambil jumlah field dalam hasil query

· int mysql_num_rows (string result);

mengambil jumlah baris dari hasil query

· int mysql_pconnect (string hostname, string username, string password);

membuka koneksi MySQL yang persisten

· int mysql_query (string query, [int link_identifier]);

mengirim query MySQL

· int mysql_result (int result, int row, mixed field);

mengambil data hasil query

· int mysql_select_db (string database_name, [int link_identifier]);

memilih database MySQL

· string mysql_tablename (int result, int i);

mengambil nama tabel dari field

PostgreSQL Functions di PHP

· bool pg_close (int connection);

menutup koneksi PostgreSQL

· int pg_cmdtuples (int result_id);

mengembalikan jumlah tuple yang terpengaruh

· int pg_connect (string host, string port, string options, string tty, string dbname);

membuka sebuah koneksi

· string pg_dbname (int connection);

mengembalikan nama database

· string pg_errormessage (int connection);

mengembalikan pesan error

· int pg_exec (int connection, string query);

mengeksekusi sebuah query

· array pg_fetch_array (int result, int row);

mengambil baris sebagai array terasosiasi

· object pg_fetch_object (int result, int row);

mengambil baris sebagai object

· array pg_fetch_row (int result, int row);

mengambil baris sebagai sebuah array

· int pg_fieldisnull (int result_id, int row, mixed field);

menguji apakah sebuah field kosong (null)

· string pg_fieldname (int result_id, int field_number);

mengembalikan nama sebuah field

· string pg_fieldnum (int result_id, int field_name);

mengembalikan nomor kolom bernama tertentu

· int pg_fieldprtlen (int result_id, int row_number, string field_name);

mengembalikan panjang yang dicetak

· int pg_fieldsize (int result_id, string field_name);

mengembalikan ukuran penyimpanan internal dari sebuah field

· int pg_fieldtype (int result_id, int field_number);

mengembalikan tipe field tertentu

· int pg_freeresult (int result_id);

membebaskan memori

· int pg_getlastoid (int result_id);

mengembalikan identifier object terakhir

· string pg_host (int connection_id);

mengembalikan nama host

· void pg_loclose (int fd);

menutup object besar

· int pg_locreate (int conn);

membuat object besar

· int pg_loopen (int conn, int objoid, string mode);

membuka sebuah object besar

· string pg_loread (int fd, int len);

membaca sebuah object besar

· void pg_readall (int fd);

membaca seluruh object besar

· void pg_lounlink (int conn, int lobjid);

menghapus object besar

· int pg_lowrite (int fd, string buf);

menulis object besar

· int pg_numbfields (int result_id);

mengembalikan jumlah field

· int pg_numrows (int result_id);

mengembalikan jumlah baris

· string pg_options (int connection_id);

mengembalikan option

· int pg_pconnect (string host, string port, string options, string tty, string dbname);

membuat koneksi database persisten

· int pg_port (int connection_id);

mengembalikan nomor port

· mixed pg_result (int result_id, int row_number, mixed fieldname);

mengembalikan nilai dari identifier hasil query

· string pg_tty (int connection_id);

mengembalikan nama tty

Sintaks MySQL

· CREATE DATABASE db_name

· DROP DATABASE [IF EXISTS] db_name

· CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,…)] [ table_options] [select_statement]

create_definition:

col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [PRIMARY KEY] [reference_definition]

or PRIMARY KEY (index_col_name,…)

or KEY [index_name] (index_col_name,…)

or INDEX [index_name] (index_col_name,…)

or UNIQUE [INDEX] [index_name] (index_col_name,…)

or [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,…)

[reference_definition]

or CHECK (expr)

type:

TINYINT[(length)] [UNSIGNED] [ZEROFILL]

or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]

or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]

or INT[(length)] [UNSIGNED] [ZEROFILL]

or INTEGER[(length)] [UNSIGNED] [ZEROFILL]

or BIGINT[(length)] [UNSIGNED] [ZEROFILL]

or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]

or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]

or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]

or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]

or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]

or CHAR(length) [BINARY]

or VARCHAR(length) [BINARY]

or DATE

or TIME

or TIMESTAMP

or DATETIME

or TINYBLOB

or BLOB

or MEDIUMBLOB

or LONGBLOB

or TINYTEXT

or TEXT

or MEDIUMTEXT

or LONGTEXT

or ENUM(value1,value2,value3,…)

or SET(value1,value2,value3,…)

index_col_name:

col_name [(length)]

reference_definition:

REFERENCES tbl_name [(index_col_name,…)]

[MATCH FULL | MATCH PARTIAL]

[ON DELETE reference_option]

[ON UPDATE reference_option]

reference_option:

RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT

table_options:

TYPE = {ISAM | MYISAM | HEAP}

or AUTO_INCREMENT = #

or AVG_ROW_LENGTH = #

or CHECKSUM = {0 | 1}

or COMMENT = “string”

or MAX_ROWS = #

or MIN_ROWS = #

or PACK_KEYS = {0 | 1}

or PASSWORD = “string”

or DELAY_KEY_WRITE = {0 | 1}

or ROW_FORMAT= { default | dynamic | static | compressed }

select_statement:

[IGNORE | REPLACE] SELECT … (Some legal select statement)

· ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec … ]

alter_specification:

ADD [COLUMN] create_definition [FIRST | AFTER column_name ]

or ADD INDEX [index_name] (index_col_name,…)

or ADD PRIMARY KEY (index_col_name,…)

or ADD UNIQUE [index_name] (index_col_name,…)

or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}

or CHANGE [COLUMN] old_col_name create_definition

or MODIFY [COLUMN] create_definition

or DROP [COLUMN] col_name

or DROP PRIMARY KEY

or DROP INDEX index_name

or RENAME [AS] new_tbl_name

or table_options

· OPTIMIZE TABLE tbl_name

· DROP TABLE [IF EXISTS] tbl_name [, tbl_name, … ]

· DELETE [LOW_PRIORITY] FROM tbl_name [WHERE where_definition] [LIMIT rows]

· SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [HIGH_PRIORITY] [DISTINCT | DISTINCTROW | ALL]

select_expression,…

[INTO {OUTFILE | DUMPFILE} ‘file_name’ export_options]

[FROM table_references

[WHERE where_definition]

[GROUP BY col_name,…]

[HAVING where_definition]

[ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,…]

[LIMIT [offset,] rows]

[PROCEDURE procedure_name] ]

· INSERT [LOW_PRIORITY | DELAYED] [IGNORE] [INTO] tbl_name [(col_name,…)] VALUES (expression,…),(…),…

or INSERT [LOW_PRIORITY | DELAYED] [IGNORE] [INTO] tbl_name [(col_name,…)] SELECT …

or INSERT [LOW_PRIORITY | DELAYED] [IGNORE] [INTO] tbl_name SET col_name=expression, col_name=expression, …

· REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name [(col_name,…)] VALUES (expression,…)

or REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name [(col_name,…)] SELECT …

or REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name SET col_name=expression, col_name=expression,…

· LOAD DATA [LOW_PRIORITY] [LOCAL] INFILE ‘file_name.txt’ [REPLACE | IGNORE] INTO TABLE tbl_name

[FIELDS

[TERMINATED BY ‘\t’]

[OPTIONALLY] ENCLOSED BY ”]

[ESCAPED BY ‘\\’ ]]

[LINES TERMINATED BY ‘\n’]

[IGNORE number LINES]

[(col_name,…)]

· UPDATE [LOW_PRIORITY] tbl_name SET col_name1=expr1,col_name2=expr2,… [WHERE where_definition] [LIMIT #]

· USE db_name

· FLUSH flush_option [,flush_option]

· KILL thread_id

· SHOW DATABASES [LIKE wild]

or SHOW TABLES [FROM db_name] [LIKE wild]

or SHOW COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]

or SHOW INDEX FROM tbl_name [FROM db_name]

or SHOW STATUS

or SHOW VARIABLES [LIKE wild]

or SHOW [FULL] PROCESSLIST

or SHOW TABLE STATUS [FROM db_name] [LIKE wild]

or SHOW GRANTS FOR user

· EXPLAIN tbl_name

or EXPLAIN SELECT select_options

· {DESCRIBE | DESC} tbl_name {col_name | wild}

· LOCK TABLES tbl_name [AS alias] {READ | [READ_LOCAL] | [LOW_PRIORITY] WRITE } [, tbl_name {READ | [LOW_PRIORITY] WRITE} …]

UNLOCK TABLES

· SET [OPTION] SQL_VALUE_OPTION= value, …

· GRANT priv_type [(column_list)] [, priv_type [(column_list)] …]

ON {tbl_name | * | *.* | db_name.*}

TO user_name [IDENTIFIED BY ‘password’]

[, user_name [IDENTIFIED BY ‘password’] …]

[WITH GRANT OPTION]

· REVOKE priv_type [(column_list)] [, priv_type [(column_list)] …]

ON {tbl_name | * | *.* | db_name.*}

FROM user_name [, user_name …]

· CREATE [UNIQUE] INDEX index_name ON tbl_name (col_name[(length)],… )

· DROP INDEX index_name ON tbl_name

· CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|REAL|INTEGER}

SONAME shared_library_name

· DROP FUNCTION function_name

3 thoughts on “Fungsi-Fungsi Pada PHP dan MYSQL

    jaka @photoshop tutorial said:
    March 5, 2011 at 07:49

    hebat,, lengkap banget ya🙂

    waspodo selalu waspada said:
    November 29, 2010 at 23:18

    kurang komplit gan
    yang aku cari gak ada

    anm said:
    June 19, 2010 at 17:10

    wah yang di foto cantik banget

Terima Kasih Sudah berkunjung ke Blog saya. Dan Jangan Lupa Isi Komentar di Bawah ini.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s