Smutty


Smutty.Smutty_Database

Class Smutty_Database

Smutty_Object
|
+--Smutty_Database

public abstract class Smutty_Database
extends Smutty_Object

this is the base class which all database implementations need to extend and implement. it controls access to these implementations however and getting a db handle should be done by using the

getInstance()

method.

/


Method Summary
protected abstract boolean

connect()

connects to the database.

abstract String

escape(String string)

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

abstract String

getCurrentDate()

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

abstract String

getDateFormat()

returns the date format for this db.

abstract String

getError()

returns the last error to occur

abstract 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)

abstract int

getInsertId(String table)

returns the auto generated id for the last record inserted.

static Smutty_Database

getInstance()

method for getting a handle to the current database connection.

abstract Smutty_Database_Result

query(String sql)

executes a query on the database.

abstract boolean

script(String file)

run an sql script against the database.

abstract boolean

update(String sql)

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

Method Detail

connect

protected abstract 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 abstract 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 abstract String getCurrentDate()

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

Returns:
current datetime string
Go to code

getDateFormat

public abstract 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 abstract String getError()

returns the last error to occur

Returns:
desc of last error
Go to code

getFieldsSql

public abstract 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 abstract 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

getInstance

public static Smutty_Database getInstance()

method for getting a handle to the current database connection. of none has been created then this will try and read the config to find out what and how to create.

Returns:
the singleton
Go to code

query

public abstract 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 abstract 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 abstract 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