databases
[ class tree: databases ] [ index: databases ] [ all elements ]

Class: MySQLDatabaseTable

Source Location: /databases/mysql/MySQLDatabaseTable.class.php

Class Overview

ABSTDatabaseTable
   |
   --MySQLDatabaseTable



Author(s):

Version:

  • 0.4.2

Copyright:

  • Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>

    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License.

    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Methods


Inherited Variables

Inherited Methods

Class: ABSTDatabaseTable

ABSTDatabaseTable::ABSTDatabaseTable()
Fake-Constructor
ABSTDatabaseTable::addField()
Adds a field's reference to this object of a database table.
ABSTDatabaseTable::addFieldname()
Adds a field's reference to this object of a database table.
ABSTDatabaseTable::addJoin()
Adds a join's reference to this object of a database table.
ABSTDatabaseTable::getFieldnames()
Returns the table's fieldnames.
ABSTDatabaseTable::getInsertID()
Returns the last insert id that was made to the underlying database table.
ABSTDatabaseTable::getLastQuery()
Returns the last stored database query.
ABSTDatabaseTable::getName()
Returns the name of the database table.
ABSTDatabaseTable::getParent()
Returns the parent object of this object.
ABSTDatabaseTable::getPrimaryKey()
This method has to be implement in a subclass!
ABSTDatabaseTable::getResourceID()
Returns the id of the connection resource to the database host.
ABSTDatabaseTable::setName()
Sets the name of the databasetable.
ABSTDatabaseTable::setParent()
Sets the parent of this object.
ABSTDatabaseTable::__contructor()
Constructor

Class Details

[line 60]


Tags:

author:  Daniel Plücken <daniel@debakel.net>
version:  0.4.2
copyright:  

Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

license:  GNU Lesser General Public License


[ Top ]


Class Methods


constructor MySQLDatabaseTable [line 74]

MySQLDatabaseTable MySQLDatabaseTable( string $name, [object $parent = ""])

Constructor



Tags:

version:  1.0
since:  0.1.0
access:  public


Parameters:

string   $name  
object   $parent  

[ Top ]

method copyTable [line 383]

boolean copyTable( string $newTableName, [string $targetDatabase = ""])

Copies this table.



Tags:

version:  1.1
since:  0.1.0
access:  public


Parameters:

string   $newTableName  
string   $targetDatabase  

[ Top ]

method delete [line 1240]

boolean delete( string $where)

Deletes the specified dataset.



Tags:

version:  1.0
since:  0.2.1
access:  public


Parameters:

string   $where  

[ Top ]

method doCSVImport [line 110]

boolean doCSVImport( CSVFiles $csv_file_obj, [array $field_arr = ""])

Iports data from a csv file. You have to create a CSVFiles-Object first.



Tags:

version:  1.0
since:  0.1.0
access:  public


Parameters:

CSVFiles   $csv_file_obj  
array   $field_arr  

[ Top ]

method echoBufferedDump [line 505]

string echoBufferedDump( [string $newTableName = ""], [boolean $full_inserts = false], [boolean $drop_order = false], [boolean $if_not_exists_order = false], [string $where = ""], [integer $flush_row_count = 1000])

Returns an SQL-DUMP.



Tags:

version:  1.0
since:  0.3.8
access:  public


Parameters:

string   $newTableName  
boolean   $full_inserts  
boolean   $drop_order  
boolean   $if_not_exists_order  
string   $where  
integer   $flush_row_count  

[ Top ]

method emptyTable [line 419]

boolean emptyTable( )

Emptys this table.



Tags:

version:  1.0
since:  0.1.0
access:  public


[ Top ]

method getArrayOfDataField [line 1101]

mixed getArrayOfDataField( string $fieldname, string $where)

Returns a array of values of a data field.



Tags:

version:  1.0
since:  0.3.1
access:  public


Parameters:

string   $fieldname  
string   $where  

[ Top ]

method getAutoIncrementField [line 218]

string getAutoIncrementField( )

Returns the fieldname of the auto increment field if there is one.



Tags:

version:  1.0
since:  0.4.2
access:  public


[ Top ]

method getCount [line 657]

integer getCount( [string $where = ""])

Returns the count of the fields in the where clause.



Tags:

version:  2.5
since:  0.1.0
access:  public


Parameters:

string   $where  

[ Top ]

method getCreateOrder [line 254]

string getCreateOrder( [string $newTableName = ""], [boolean $drop_order = false], [boolean $if_not_exists_order = false])

Returns an SQL-string to create this table. You can give a new name for creating the table.



Tags:

version:  1.4
since:  0.1.0
access:  public


Parameters:

string   $newTableName  
boolean   $drop_order  
boolean   $if_not_exists_order  

[ Top ]

method getDataOrder [line 309]

string getDataOrder( [string $newTableName = ""], [boolean $full_inserts = false], [string $where = ""])

Returns an SQL-string to fill this table. You can give a new name for the table to insert in.



Tags:

version:  1.32
since:  0.1.0
access:  public


Parameters:

string   $newTableName  
boolean   $full_inserts  
string   $where  

[ Top ]

method getDatasets [line 837]

array getDatasets( [string $fields_or_where = "1=1"], [boolean $where_or_only_one = false], [string $array_kind = MYSQL_OUTPUT_DEFAULT], [boolean $only_one = false])

This method is an alias for the method "getDatasetsWithFields".

Returns the datasets as an two dimensional array if the query could be execute. The first dimension carries the datasets. The second dimension carries the fields's values of the result list.

Usage: getDatasets( $fieldnamesArr, $where, $array_kind ); Or: getDatasets( $where );




Tags:

version:  1.4
since:  0.1.5
access:  public


Parameters:

string   $fields_or_where   The where clause of the query.
boolean   $where_or_only_one   Whether only one Dataset should be output.
string   $array_kind   The kind how the tuples should be output. MYSQL_OUTPUT_ASSOC - to get an associative array, with the fieldnames as indices. MYSQL_OUTPUT_NUM - to get an array, with numbers as indices in order of the $fieldnamesArr or of the underlying table. MYSQL_OUTPUT_DEFAULT - to get a mix of both output kinds.
boolean   $only_one   Whether only one Dataset should be output.

[ Top ]

method getDatasetsWithFields [line 708]

array getDatasetsWithFields( [array $field_arr = array()], [string $where = "1=1"], [string $only_one = false], [string $array_kind = MYSQL_OUTPUT_DEFAULT])

Returns the datasets as an two dimensional array if the query could be execute. The first dimension carries the datasets. The second dimension carries the fields's values of the result list.

Usage: getDatasetsWithFields( $fieldnamesArr, $where ); Or: getDatasetsWithFields( $where, $array_kind ); Or: getDatasetsWithFields( $where );




Tags:

version:  1.7
since:  0.1.5
access:  public


Parameters:

array   $field_arr   The fields that should be in the result list.
string   $where   The where clause of the query.
string   $only_one  
string   $array_kind   The kind how the tuples should be output. MYSQL_OUTPUT_ASSOC - to get an associative array, with the fieldnames as indices. MYSQL_OUTPUT_NUM - to get an array, with numbers as indices in order of the $fieldnamesArr or of the underlying table. MYSQL_OUTPUT_DEFAULT - to get a mix of both output kinds.

[ Top ]

method getDatasetsWithPrimaryToMultiple [line 955]

array getDatasetsWithPrimaryToMultiple( array $primary_key, array $value_fields, [string $where = null])

Returns the datasets as array with the values of the primary key as index.



Tags:

version:  1.11
since:  0.1.8
access:  public


Parameters:

array   $primary_key   The fields that should be in the result list.
array   $value_fields   The fields with the values for the content.
string   $where   The where clause of the query.

[ Top ]

method getDatasetsWithPrimaryToValue [line 891]

array getDatasetsWithPrimaryToValue( array $primary_key, array $value_fields, [string $where = null])

Returns the datasets as array with the values of the primary key as index.



Tags:

version:  1.21
since:  0.1.8
access:  public


Parameters:

array   $primary_key   The fields that should be in the result list.
array   $value_fields   The fields with the values for the content.
string   $where   The where clause of the query.

[ Top ]

method getDump [line 472]

string getDump( [string $newTableName = ""], [boolean $full_inserts = false], [boolean $drop_order = false], [boolean $if_not_exists_order = false])

Returns an SQL-DUMP.



Tags:

version:  1.2
since:  0.1.0
access:  public


Parameters:

string   $newTableName  
boolean   $full_inserts  
boolean   $drop_order  
boolean   $if_not_exists_order  

[ Top ]

method getFieldnames [line 1507]

array getFieldnames( [boolean $backticks = false])

Returns the table's fieldnames. If you want you can get the fieldnames enclosed in backticks.



Tags:

version:  1.3
since:  0.1.1
access:  public


Overrides ABSTDatabaseTable::getFieldnames() (Returns the table's fieldnames.)

Parameters:

boolean   $backticks  

[ Top ]

method getMaxOf [line 590]

integer getMaxOf( string $fieldname, [string $where = ""])

Returns the maximum value from a field.



Tags:

version:  1.1
since:  0.1.0
access:  public


Parameters:

string   $fieldname  
string   $where   The where-clause is optional.

[ Top ]

method getMinOf [line 556]

integer getMinOf( string $fieldname, [string $where = ""])

Returns the minimum value from a field.



Tags:

version:  1.0
since:  0.2.7
access:  public


Parameters:

string   $fieldname  
string   $where   The where-clause is optional.

[ Top ]

method getPrimaryKey [line 183]

array|false &getPrimaryKey( )

Returns all field members of the primary key of this database table.



Tags:

version:  1.0
since:  0.2.3
access:  public


Overrides ABSTDatabaseTable::getPrimaryKey() (This method has to be implement in a subclass!)

[ Top ]

method getRealFieldnames [line 1466]

array getRealFieldnames( [boolean $backticks = false])

Returns the table's fieldnames independence of overruled fieldnames. If you want you can get the fieldnames enclosed in backticks.



Tags:

version:  1.1
since:  0.1.3
access:  public


Parameters:

boolean   $backticks  

[ Top ]

method getSingleDataFieldValue [line 1072]

mixed getSingleDataFieldValue( string $fieldname, string $where)

Returns a single value of a data field.



Tags:

version:  1.0
since:  0.2.8
access:  public


Parameters:

string   $fieldname  
string   $where  

[ Top ]

method getSingleDataset [line 1027]

array getSingleDataset( string $fields_or_where, [string $where = ""], [string $array_kind = MYSQL_OUTPUT_DEFAULT])

Returns a single dataset as an array if the query could be execute.



Tags:

version:  1.3
since:  0.1.2
access:  public


Parameters:

string   $fields_or_where  
string   $where  
string   $array_kind   The kind how the tuples should be output. MYSQL_OUTPUT_ASSOC - to get an associative array, with the fieldnames as indices. MYSQL_OUTPUT_NUM - to get an array, with numbers as indices in order of the $fieldnamesArr or of the underlying table. MYSQL_OUTPUT_DEFAULT - to get a mix of both output kinds.

[ Top ]

method getSumOf [line 624]

integer getSumOf( string $fieldname, [string $where = ""])

Returns the sum value of a field.



Tags:

version:  1.0
since:  0.3.3
access:  public


Parameters:

string   $fieldname  
string   $where   The where-clause is optional.

[ Top ]

method insert [line 1276]

boolean insert( array $fieldArr, array $valueArr)

Inserts the specified dataset. Note that this function will create a global variable $GLOBALS["insert_id"] which contains the result of mysql_insert_id();



Tags:

version:  1.66
since:  0.1.1
access:  public


Parameters:

array   $fieldArr   The array that carries the fieldnames.
array   $valueArr   The array that carries the values.

[ Top ]

method overruleFieldnames [line 1539]

void overruleFieldnames( array $array)

Overrules the table's fieldnames. The given array should contain the comma separated list of the query between the keywords SELECT and FROM.

Each element of the array should represent one element of the list.




Tags:

version:  1.0
since:  0.2.3
access:  public


Parameters:

array   $array  

[ Top ]

method probeConnection [line 1578]

boolean probeConnection( )

Probes whether there is a connection to the databasehost, if not it will attempt to connect to the host.



Tags:

version:  1.2
since:  0.1.0
access:  public


[ Top ]

method putSingleDatasetIntoGetVars [line 1223]

void putSingleDatasetIntoGetVars( string|array $where_or_field_arr, [string $where = ""])

Puts a single dataset into "get"-variables. The names of the "get"-vars accord to the fieldnames of the Databasetable.



Tags:

version:  1.21
see:  MySQLDatabaseTable::putSingleDatasetIntoRequestVars()
since:  0.1.5
access:  public


Parameters:

string|array   $where_or_field_arr  
string   $where  

[ Top ]

method putSingleDatasetIntoPostVars [line 1203]

void putSingleDatasetIntoPostVars( string|array $where_or_field_arr, [string $where = ""])

Puts a single dataset into "post"-variables. The names of the "Post"-vars accord to the fieldnames of the Databasetable.



Tags:

version:  1.21
see:  MySQLDatabaseTable::putSingleDatasetIntoRequestVars()
since:  0.1.5
access:  public


Parameters:

string|array   $where_or_field_arr  
string   $where  

[ Top ]

method putSingleDatasetIntoRequestVars [line 1153]

void putSingleDatasetIntoRequestVars( string|array $where_or_field_arr, [string $where = ""], [array $request_type_arr = array( "GET", "POST", "REQUEST" )])

Puts a single dataset into request-variables. The names of the request-vars

accord to the fieldnames of the Databasetable. You can fill variables of the types: $_REQUEST, $_GET and $_POST. You only have to list them in an array passed as third parameter in this function (see the description for third parameter).




Tags:

version:  1.0
since:  0.4.1
access:  public


Parameters:

string|array   $where_or_field_arr   This has to be the where-clause of the query to the underlying database table. If you only want to fetch and put a few fields of the table, you schould pass here an array of fieldnames and pass the where-clause to the with parameter.
string   $where   This has to be the where-clause of the query to the underlying database table, if the first parameter should carry the fields that are only to fetch.
array   $request_type_arr   Valid Values are: array( "GET", "POST", "REQUEST" ) You can leave out the array values you don't need that the field values put in according request-variables.

[ Top ]

method renameTable [line 443]

boolean renameTable( string $newTableName)

Renames this table.



Tags:

version:  1.1
since:  0.1.0
access:  public


Parameters:

string   $newTableName  

[ Top ]

method replace [line 1359]

boolean replace( array $fieldArr, array $valueArr)

Replaces the specified dataset.



Tags:

version:  1.16
since:  0.2.0
access:  public


Parameters:

array   $fieldArr   The array that carries the fieldnames.
array   $valueArr   The array that carries the values.

[ Top ]

method researchFields [line 88]

void researchFields( )



Tags:

version:  1.0
todo:  This isn't programmed yet.
since:  0.1.0
access:  public


[ Top ]

method storeFieldFlags [line 143]

void storeFieldFlags( )

Stores the Flags: (!)not_null <=> $this->field_can_be_null[FIELDINDEX], primary_key <=> $this->field_is_primary_member[FIELDINDEX], auto_increment <=> $this->field_has_auto_increment[FIELDINDEX]. This is necessary to get dump of the table data.



Tags:

version:  1.0
since:  0.2.9
access:  public


[ Top ]

method storeFieldnames [line 1423]

boolean storeFieldnames( )

Stores the names of fields in this object.



Tags:

version:  1.1
since:  0.1.0
access:  public


[ Top ]

method swapFieldValuesOf [line 1402]

boolean swapFieldValuesOf( string $fieldname, string $where_a, string $where_b)

Swaps values of a specified field in two tupel.



Tags:

version:  1.0
since:  0.3.2
access:  public


Parameters:

string   $fieldname  
string   $where_a  
string   $where_b  

[ Top ]

method unsetOverruledFieldnames [line 1557]

void unsetOverruledFieldnames( )

Unsets the overrules of fieldnames.



Tags:

version:  1.0
since:  0.2.7
access:  public


[ Top ]

method update [line 1319]

boolean update( array $fieldArr, array $valueArr, [string $where = "1=1"])

Updates the specified dataset.



Tags:

version:  1.46
since:  0.1.1
access:  public


Parameters:

array   $fieldArr   The array that carries the fieldnames.
array   $valueArr   The array that carries the values.
string   $where   The wheredefinition of the query.

[ Top ]


Documentation generated on Thu, 05 Jun 2008 19:14:20 +0200 by phpDocumentor 1.4.1