phpDocumentor MySQL
[ class tree: MySQL ] [ index: MySQL ] [ all elements ]

Class: Mysql

Source Location: /mysql.php

Class Mysql

Class Overview

Defines basic functionality for communicating with MySQL.

The Mysql class constructor accepts MySQL connection parameters and saves them to member attributes used during connection. The class also provides two other methods: one for executing a query and the other provides access to Mysql_Statement through the prepare() method.

Located in /mysql.php [line 33]



		
				Author(s):
		
		
		
Information Tags:
Link:  http://albertfama.com/pkgs/distro/mysql/mysql.zip
Since:  File available since release .01 Alpha
Version:  1.0 (Stable)
License:  GNU GPL
Copyright:  2009 Albert Fama

Properties

Methods

[ Top ]
Property Summary
string   $_db_name   MySQL database name
resource   $_handle   MySQL resource
string   $_host   MySQL server name
string   $_password   MySQL password
string   $_username   MySQL username

[ Top ]
Method Summary
Mysql   __construct()   Constructor
string   escapeString()   Escape string
Mysql_Result   execute()   Execute query against MySQL database
Mysql_Statement   prepare()   Prepare query
void   selectDb()   Select database
void   _connect()   Connect to MySQL

[ Top ]
Properties
string   $_db_name [line 69]

MySQL database name

Database which is selected after successfully connecting MySQL

API Tags:
Access:  protected


[ Top ]
resource   $_handle [line 78]

MySQL resource

Member attribute used to store MySQL resource

API Tags:
Access:  protected


[ Top ]
string   $_host [line 60]

MySQL server name

Server name used when attempting to connect to MySQL

API Tags:
Access:  protected


[ Top ]
string   $_password [line 51]

MySQL password

Password used when attempting to connect to MySQL

API Tags:
Access:  protected


[ Top ]
string   $_username [line 42]

MySQL username

Username used when attempting to connect to MySQL

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 91]

  Mysql __construct( string $username, string $password, string $host, [string $db_name = null]  )

Constructor

Saves arguments to member attributes

Parameters:
string   $username:  username (MySQL username)
string   $password:  password (MySQL password)
string   $host:  host (MySQL sever name)
string   $db_name:  db_name (MySQL database name)

API Tags:
Access:  public


[ Top ]
escapeString  [line 155]

  string escapeString( string $value  )

Escape string

Method uses mysql_real_escape_string() to escape value sent, making it safe to use in a MySQL statement.

Parameters:
string   $value:  value (string to be escaped)

API Tags:
Access:  public
See:  mysql_real_escape_string


[ Top ]
execute  [line 179]

  Mysql_Result execute( string $query  )

Execute query against MySQL database

Method first checks if a connection exists to the database. If no connection exists method attempts to call _connect() method then select db. After a successful connection has been established method executes the query sent.

Parameters:
string   $query:  query

API Tags:
Access:  public

Information Tags:
Throws:  Mysql_Exception

[ Top ]
prepare  [line 206]

  Mysql_Statement prepare( string $query  )

Prepare query

Method first checks if a connection exists to the database. If no connection exists method attempts to call _connect() method then select db. After a successful connection has been established method creates and returns an instance of MySQL_Statement.

Parameters:
string   $query:  query

API Tags:
Access:  public


[ Top ]
selectDb  [line 130]

  void selectDb( string $database  )

Select database

Attempts to select a MySQL database for a connection. If no database name is given method uses db name sent to constructor.

Parameters:
string   $database:  database (name of database)

API Tags:
Access:  public

Information Tags:
Throws:  MySQL_Exception

[ Top ]
_connect  [line 109]

  void _connect( )

Connect to MySQL

Attempts to connect to MySQL using arguments sent to constructor. If connection fails method throws Mysql_Exception.


API Tags:
Access:  protected

Information Tags:
Throws:  Mysql_Exception

[ Top ]

Documentation generated on Mon, 15 Jun 2009 16:50:04 -0600 by phpDocumentor 1.3.0RC3