![]() |
Tina4Stack
v1.0.1
The Tina4 Stack
|
Public Member Functions | |
__construct ($dbpath="", $username="", $password="", $dbtype="sqlite", $outputdateformat="YYYY-mm-dd", $tag="DEB", $debug=false) | |
connect ($dbpath="", $username="", $password="", $dbtype="sqlite", $outputdateformat="YYYY-mm-dd h:i:s") | |
getError () | |
encodeImage ($imagedata, $imagestore="imagestore", $size="", $noimage="/imagestore/noimage.jpg") | |
embedImage ($rawImage) | |
toArray () | |
toRequest ($row, $prefix="") | |
lastError () | |
getLastError () | |
createConnection () | |
getPageTemplate ($title="Default") | |
updateConnection () | |
close () | |
startTransaction () | |
rollbackTransaction ($handle) | |
setDatabase ($dbname) | |
insert ($tablename, $fieldValues) | |
update ($tablename, $fieldValues, $indexFieldValue) | |
updateOrInsert ($tableName, $fieldValues, $primaryKey) | |
escapeString ($data) | |
exec ($sql="") | |
setParams ($sql="", $inputvalues=Array()) | |
parseSQL ($sql="", $fromdbtype="generic", $todbtype="generic") | |
getInstance ($word, $sql) | |
getRow ($sql="", $id=0, $rowtype=0, $fetchblob=true) | |
getRows ($sql="", $rowtype=0, $fetchblob=true, $calculatedfields=array()) | |
getFieldByName ($fieldname="") | |
getBlob ($column) | |
translateDate ($input, $dbdateformat, $outputdateformat) | |
delete ($tablename, $fieldValues) | |
commit ($tranId=null) | |
getDataType ($data) | |
getKeyValue ($sql="") | |
getDatabase () | |
getFieldInfo ($sql="") | |
getAffectedRows ($sql="") | |
getRandomId ($noofchars) | |
getTableExists ($tablename="") | |
getInsertSQL ($fieldprefix="edt", $tablename="", $primarykey="", $genkey=true, $requestvar="", $passwordfields="", $datefields="", $exec=false, $arrayindex=0) | |
getNextId ($tablename="", $fieldname="", $filter="") | |
dateToDb ($invalue) | |
runFileUploads ($fieldprefix="edt", $tablename="", $primarykeyValue=0, $primarykey="ID") | |
setBlob ($tablename, $column, $blobvalue, $filter="fieldname = 0") | |
getUpdateSQL ($fieldprefix="edt", $tablename="", $primarykey="", $index="", $requestvar="", $passwordfields="", $datefields="", $exec=false, $arrayindex=0) | |
generateCsv ($sql, $filename="temp.csv", $delim=",") | |
Public Attributes | |
$dbh | |
$error | |
$dbtype = "sqlite3" | |
$dbpath = "" | |
$tmppath = "/tmp/" | |
$lastsql = Array() | |
$lasterror = Array() | |
$debug = false | |
$affectedrows = 0 | |
$nooffields = 0 | |
$fieldinfo | |
$version = "1.0" | |
$dbdateformat = "YYYY-mm-dd h:i:s" | |
$outputdateformat = "dd/mm/YYYY" | |
$updatefieldinfo = true | |
$RAWRESULT | |
$lastrowid | |
$tag | |
Debby is the database class
Debby is for developers just beginning with PHP database development, it takes the differences between the PHP database implementations and makes it easy to work and switch between the databases. It also acts as the testing platform for the SQL translation tool.
Debby::__construct | ( | $dbpath = "" , |
|
$username = "" , |
|||
$password = "" , |
|||
$dbtype = "sqlite" , |
|||
$outputdateformat = "YYYY-mm-dd" , |
|||
$tag = "DEB" , |
|||
$debug = false |
|||
) |
Debby::close | ( | ) |
BEGIN Close
Debby::commit | ( | $tranId = null | ) |
Debby::connect | ( | $dbpath = "" , |
|
$username = "" , |
|||
$password = "" , |
|||
$dbtype = "sqlite" , |
|||
$outputdateformat = "YYYY-mm-dd h:i:s" |
|||
) |
Debby::createConnection | ( | ) |
Debby::dateToDb | ( | $invalue | ) |
BEGIN Date to DB This function will format the date as needed by the database
Debby::delete | ( | $tablename, | |
$fieldValues | |||
) |
An easy way to write a delete statement and execute it immediatelly
String | $tablename | Name of the table to run the delete on |
Array | $fieldValues | The fields to filter by, used in the where statement |
Debby::embedImage | ( | $rawImage | ) |
Debby::encodeImage | ( | $imagedata, | |
$imagestore = "imagestore" , |
|||
$size = "" , |
|||
$noimage = "/imagestore/noimage.jpg" |
|||
) |
Debby::escapeString | ( | $data | ) |
Debby::exec | ( | $sql = "" | ) |
Debby::generateCsv | ( | $sql, | |
$filename = "temp.csv" , |
|||
$delim = "," |
|||
) |
A function to generate a CSV from an SQL statement
String | $sql | An SQL string |
String | $filename | The name of the file you want |
String | $delim | An optional delimeter - default is ',' |
Debby::getAffectedRows | ( | $sql = "" | ) |
BEGIN Get Affected Rows Get the number of rows changed or retrieved by last SQL
Debby::getBlob | ( | $column | ) |
Debby::getDatabase | ( | ) |
Debby::getDataType | ( | $data | ) |
Debby::getError | ( | ) |
Debby::getFieldByName | ( | $fieldname = "" | ) |
BEGIN Get Field Info By Name Get a fields info by name
Debby::getFieldInfo | ( | $sql = "" | ) |
Debby::getInsertSQL | ( | $fieldprefix = "edt" , |
|
$tablename = "" , |
|||
$primarykey = "" , |
|||
$genkey = true , |
|||
$requestvar = "" , |
|||
$passwordfields = "" , |
|||
$datefields = "" , |
|||
$exec = false , |
|||
$arrayindex = 0 |
|||
) |
BEGIN Get Insert SQL This function attempts to eliminate errors by creating the insert statements using prefixed input fields If you have a form with inputs prefixed with "txt" for example it will chop off the txt and make an insert statement Field names need to be in uppercase for better processing
<form> <input type="text" name="txtNAME" value="Andre"> <input type="text" name="txtDATE" value="01/10/2010"> </form>
Debby::getInstance | ( | $word, | |
$sql | |||
) |
Debby::getKeyValue | ( | $sql = "" | ) |
This function returns a value key pair of an sql statement based on 2 records. The first record retrieved will be the key and the second will be the value
type | $sql |
Debby::getLastError | ( | ) |
Debby::getNextId | ( | $tablename = "" , |
|
$fieldname = "" , |
|||
$filter = "" |
|||
) |
BEGIN Get Next ID Get the next id on a table by using the MAX function and adding 1
Debby::getPageTemplate | ( | $title = "Default" | ) |
The default page template for maggy
string | $title | String A title to name the page by |
Debby::getRandomId | ( | $noofchars | ) |
BEGIN Get Random ID Get a random id function and adding 1
Debby::getRow | ( | $sql = "" , |
|
$id = 0 , |
|||
$rowtype = 0 , |
|||
$fetchblob = true |
|||
) |
Debby::getRows | ( | $sql = "" , |
|
$rowtype = 0 , |
|||
$fetchblob = true , |
|||
$calculatedfields = array() |
|||
) |
Debby::getTableExists | ( | $tablename = "" | ) |
BEGIN get_table_exists() See if a certain table exists
Debby::getUpdateSQL | ( | $fieldprefix = "edt" , |
|
$tablename = "" , |
|||
$primarykey = "" , |
|||
$index = "" , |
|||
$requestvar = "" , |
|||
$passwordfields = "" , |
|||
$datefields = "" , |
|||
$exec = false , |
|||
$arrayindex = 0 |
|||
) |
BEGIN Get Update SQL This function attempts to eliminate errors by creating the update statements using prefixed input fields If you have a form with inputs prefixed with "txt" for example it will chop off the txt and make an update statement Field names need to be in uppercase for better processing
<form> <input type="text" name="txtNAME" value="Andre"> <input type="text" name="txtDATE" value="01/10/2010"> </form>
string | $fieldprefix | |
string | $tablename | |
string | $primarykey | |
string | $index | |
string | $requestvar | |
string | $passwordfields | |
string | $datefields | |
bool | false | $exec | |
int | $arrayindex |
Debby::insert | ( | $tablename, | |
$fieldValues | |||
) |
Create insert statement and run it
type | $tablename | Table name |
type | $fieldValues | Array value pairs ["field" => "value"] |
Debby::lastError | ( | ) |
Debby::parseSQL | ( | $sql = "" , |
|
$fromdbtype = "generic" , |
|||
$todbtype = "generic" |
|||
) |
Debby::rollbackTransaction | ( | $handle | ) |
Rollback Transaction
This starts a transaction if you database engine supports it and returns the transaction id The returned transaction id can be used for rolling back a transaction
Debby::runFileUploads | ( | $fieldprefix = "edt" , |
|
$tablename = "" , |
|||
$primarykeyValue = 0 , |
|||
$primarykey = "ID" |
|||
) |
Function to upload files based on prefixes and column names
String | $fieldprefix | The prefix of the form input - example txtFILE |
String | $tablename | The name of the table in the database |
String | $primarykeyValue | The value of the index in the table |
String | $primarykey | The name of the index field of the table |
Debby::setBlob | ( | $tablename, | |
$column, | |||
$blobvalue, | |||
$filter = "fieldname = 0" |
|||
) |
Debby::setDatabase | ( | $dbname | ) |
BEGIN set_database
This is more for a MYSQL type database where you can choose a different database once a connection has been made
Debby::setParams | ( | $sql = "" , |
|
$inputvalues = Array() |
|||
) |
Debby::startTransaction | ( | ) |
Start Transaction
This starts a transaction if you database engine supports it and returns the transaction id The returned transaction id can be used for rolling back a transaction
Debby::toArray | ( | ) |
Debby::toRequest | ( | $row, | |
$prefix = "" |
|||
) |
Debby::translateDate | ( | $input, | |
$dbdateformat, | |||
$outputdateformat | |||
) |
Debby::update | ( | $tablename, | |
$fieldValues, | |||
$indexFieldValue | |||
) |
Create update statement and run it
type | $tablename | Table name |
type | $fieldValues | Array value pairs ["field" => "value"] |
type | $indexFieldValue | Array ["index" => "value"] |
Debby::updateConnection | ( | ) |
Debby::updateOrInsert | ( | $tableName, | |
$fieldValues, | |||
$primaryKey | |||
) |
Method to do an insert or update into the system
$tablename | |
$fieldValues | |
$primaryKey |
Debby::$affectedrows = 0 |
Debby::$dbdateformat = "YYYY-mm-dd h:i:s" |
Debby::$dbh |
Debby::$dbpath = "" |
Debby::$dbtype = "sqlite3" |
Debby::$debug = false |
Debby::$error |
Debby::$fieldinfo |
Debby::$lasterror = Array() |
Debby::$lastrowid |
Debby::$lastsql = Array() |
Debby::$nooffields = 0 |
Debby::$outputdateformat = "dd/mm/YYYY" |
Debby::$RAWRESULT |
Debby::$tag |
Debby::$tmppath = "/tmp/" |
Debby::$updatefieldinfo = true |
Debby::$version = "1.0" |