Smutty


Smutty.Smutty_Database_MySQL

Class Smutty_Database_MySQL

Smutty_Object
|
+--Smutty_Database
|
+--Smutty_Database_MySQL

public class Smutty_Database_MySQL
extends Smutty_Database

an implementation of the database class for MySQL

/


Field Summary
mixed

$cnn

the db connection */

Method Summary
boolean

connect()

connects to the database.

String

escape(String string)

takes a string and escapes any characters in it that need to be for the current database

String

getCurrentDate()

returns the current date/time, formatted properly for the current database

String

getDateFormat()

returns the date format for this db.

String

getError()

returns the last error to occur

String

getFieldsSql(String table)

returns the sql used to eatract field information the resultset should have the fields: - name (field name) - type (field type) - nullable (yes/no string)

int

getInsertId(String table)

returns the auto generated id for the last record inserted.

Smutty_Database_Result

query(String sql)

executes a query on the database.

boolean

script(String file)

run an sql script against the database.

boolean

update(String sql)

executes an sql statement on the database and returns a boolean indicating if it went well or not

Methods inherited from Smutty.Smutty_Database
connect, escape, getCurrentDate, getDateFormat, getError, getFieldsSql, getInsertId, getInstance, query, script, update

Field Detail

cnn

public mixed $cnn = null

the db connection */


Method Detail

connect

public boolean connect()

connects to the database. db config information could be db independent so this method must read this info from the Smutty_Config class itself.

Returns:
indicating success
Go to code

escape

public String escape(String string)

takes a string and escapes any characters in it that need to be for the current database

Parameters:
string - the string to escape
Returns:
escaped string
Go to code

getCurrentDate

public String getCurrentDate()

returns the current date/time, formatted properly for the current database

Returns:
current datetime string
Go to code

getDateFormat

public String getDateFormat()

returns the date format for this db. the format should be ready for the date() function to use

Returns:
date format string
Go to code

getError

public String getError()

returns the last error to occur

Returns:
desc of last error
Go to code

getFieldsSql

public String getFieldsSql(String table)

returns the sql used to eatract field information

the resultset should have the fields: - name (field name) - type (field type) - nullable (yes/no string)

Parameters:
table - the table to get fields for
Returns:
sql string
Go to code

getInsertId

public int getInsertId(String table)

returns the auto generated id for the last record inserted. for compat you need to specify the table the record was inserted for (though this is not used for some dbs)

Parameters:
table - table record was inserted into
Returns:
the inserted id
Go to code

query

public Smutty_Database_Result query(String sql)

executes a query on the database. it should return an class which extends the Smutty_Database_Result class

Parameters:
sql - the query to execute
Returns:
query result
Go to code

script

public boolean script(String file)

run an sql script against the database. returns a boolean indicating success.

Parameters:
file - the script to run
Returns:
if script ran ok
Go to code

update

public boolean update(String sql)

executes an sql statement on the database and returns a boolean indicating if it went well or not

Parameters:
sql - the query to execute
Returns:
success
Go to code

Smutty