nyroFwk  0.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
db_table Class Reference
Inheritance diagram for db_table:
object

Public Member Functions

 isI18n ()
 
 hasI18n ()
 
 getI18nTable ()
 
 getI18nFields ()
 
 getDb ()
 
 getWhere (array $prm=array())
 
 isLinked ($field)
 
 getLinkedTableName ($tablename)
 
 getLinked ($field=null)
 
 getLinkedTable ($field)
 
 getLinkedTableRow ($field, array $data=array())
 
 isRelated ($name)
 
 getRelated ($name=null)
 
 getRelatedTableRow ($name, array $data=array())
 
 getRelatedTable ($name)
 
 getRelatedTableName ($name, $add=true)
 
 getTargetingTables ()
 
 isTargeting ($tableName)
 
 getLabel ($field=null)
 
 getI18nLabel ($field=null)
 
 getField ($field=null, $keyVal=null)
 
 getFieldFile ()
 
 getCols ()
 
 getName ()
 
 getRawName ()
 
 getIdent ()
 
 getPrimary ()
 
 insert (array $data)
 
 replace (array $data)
 
 update (array $data, $where=null)
 
 delete ($where=null)
 
 dateAutoData (array &$data, $type)
 
 select (array $prm=array())
 
 count (array $prm)
 
 selectQuery (array $prm, &$tmpTables)
 
 find ($where)
 
 findText ($text, $filter=null)
 
 getRange ($field=null)
 
 clearCache ($clearTargeting=null)
 
 getRow (array $data=array(), $withAuto=false, array $morePrm=array())
 
 getAttr ($name)
 
 setAttr ($name, $value)
 
 getCfg ()
 

Static Public Member Functions

static parseLinked (array &$data, array $linked)
 

Protected Member Functions

 afterInit ()
 
 _initI18n ()
 
 _initFields ()
 
 _initIdent ()
 
 _initLinkedTables ()
 
 _initRelatedTables ()
 
 _initLabels ()
 
 dateValue ($type)
 
 beforeInit ()
 

Protected Attributes

 $rawName
 
 $fields = array()
 
 $cols = array()
 
 $linkedTables
 
 $linkedTableNames
 
 $relatedTables
 
 $targetingTables
 
 $i18nTable
 
 $cfg
 

Detailed Description

SQL Table interface

Definition at line 10 of file table.class.php.

Member Function Documentation

◆ _initFields()

_initFields ( )
protected

Initialize the fields

Definition at line 139 of file table.class.php.

◆ _initI18n()

_initI18n ( )
protected

Init the i18n table

Definition at line 84 of file table.class.php.

◆ _initIdent()

_initIdent ( )
protected

Initialize the primary and ident information, if needed

Definition at line 164 of file table.class.php.

◆ _initLabels()

_initLabels ( )
protected

Initialize the labels

Definition at line 498 of file table.class.php.

◆ _initLinkedTables()

_initLinkedTables ( )
protected

Initialize the linked tables, if needed

Definition at line 182 of file table.class.php.

◆ _initRelatedTables()

_initRelatedTables ( )
protected

Initialize the related tables, if needed

Definition at line 332 of file table.class.php.

◆ afterInit()

afterInit ( )
protected

Definition at line 68 of file table.class.php.

◆ beforeInit()

beforeInit ( )
protectedinherited

Call just before the configuration initialisation

Definition at line 35 of file object.class.php.

◆ clearCache()

clearCache (   $clearTargeting = null)

Clear the cache of selected queries for this table

Parameters
bool | null$clearTargetingIndifcate if cache of targeting tables should also be cleared. If null, default settings will be used
Returns
int|bool Number of cache deleted or false

Definition at line 1266 of file table.class.php.

◆ count()

count ( array  $prm)

Count the number of result

Parameters
array$prmThe initial parameter
Returns
int

Definition at line 840 of file table.class.php.

◆ dateAutoData()

dateAutoData ( array &  $data,
  $type 
)

Add an automatic field date

Parameters
array$dataRecord values; will be modified if needed
string$typeType to insert date
Returns
bool True if the date was added

Definition at line 761 of file table.class.php.

◆ dateValue()

dateValue (   $type)
protected

Get a date value regarding a SQL type. If not parsed, time() will be affected

Parameters
string$typeSQL type (date and datetime parsed)
Returns
mixed The date value

Definition at line 777 of file table.class.php.

◆ delete()

delete (   $where = null)

Delete data in the table

Parameters
db_where | array | string$where: The where clause. If array, they are used with AND. (default: none)
Returns
int Deleted rows
See also
db_abstract::delete

Definition at line 702 of file table.class.php.

◆ find()

find (   $where)

Find a row by Id or by different value if array

Parameters
mixed$valId value
Returns
db_row

Definition at line 1201 of file table.class.php.

◆ findText()

findText (   $text,
  $filter = null 
)

Search text in every text fileds present the table

Parameters
string$textThe text to search
db_where | array | string$whereSame paramter than select
Returns
db_rowset
See also
select

Definition at line 1216 of file table.class.php.

◆ getAttr()

getAttr (   $name)
inherited

Get an attribute

Parameters
string$nameAttribute name
Returns
mixed|null The attribute or null if not set

Definition at line 48 of file object.class.php.

◆ getCfg()

getCfg ( )
inherited

Get the configuration object

Returns
config

Definition at line 67 of file object.class.php.

◆ getCols()

getCols ( )

Get the columns

Returns
array

Definition at line 595 of file table.class.php.

◆ getDb()

getDb ( )

Return the db object

Returns
db_abstract

Definition at line 245 of file table.class.php.

◆ getField()

getField (   $field = null,
  $keyVal = null 
)

Get the fields information

Parameters
string | null$fieldField name. If null, the whole field array will be returned
string | null$keyValValue to retrieve directly
Returns
array|null

Definition at line 566 of file table.class.php.

◆ getFieldFile()

getFieldFile ( )

Get the fields which are file

Returns
array|null;

Definition at line 581 of file table.class.php.

◆ getI18nFields()

getI18nFields ( )

Get the i18nFields

Returns
array

Definition at line 125 of file table.class.php.

◆ getI18nLabel()

getI18nLabel (   $field = null)

Get the label for the i18n fields

Parameters
null | string$fieldFieldname or null to retrieve an all of them as an array
Returns
array|string

Definition at line 555 of file table.class.php.

◆ getI18nTable()

getI18nTable ( )

Get the i18n table

Returns
db_table

Definition at line 116 of file table.class.php.

◆ getIdent()

getIdent ( )

Get the ident column name

Returns
string

Definition at line 622 of file table.class.php.

◆ getLabel()

getLabel (   $field = null)

Get the label for the fields

Parameters
null | string$fieldFieldname or null to retrieve an all of them as an array
Returns
array|string

Definition at line 538 of file table.class.php.

◆ getLinked()

getLinked (   $field = null)

Get the linked information about a field

Parameters
string | null$fieldField name. If null the whole table will be returned
Returns
array|null

Definition at line 290 of file table.class.php.

◆ getLinkedTable()

getLinkedTable (   $field)

Get the table object for a link field

Parameters
string$fieldField Name
Returns
db_table|null

Definition at line 305 of file table.class.php.

◆ getLinkedTableName()

getLinkedTableName (   $tablename)

Get linked info with a table name

Parameters
string$tablenametable name
Returns
array|null Smae result than

Definition at line 275 of file table.class.php.

◆ getLinkedTableRow()

getLinkedTableRow (   $field,
array  $data = array() 
)

Get a row for a linked table

Parameters
string$fieldField Name
array$dataThe data for overwrite the default value
Returns
db_row

Definition at line 323 of file table.class.php.

◆ getName()

getName ( )

Get the table name

Returns
string

Definition at line 604 of file table.class.php.

◆ getPrimary()

getPrimary ( )

Get the primary columns

Returns
array

Definition at line 631 of file table.class.php.

◆ getRange()

getRange (   $field = null)

Get the min and the max value for a field.

Parameters
string$fieldFieldname. If null, id is used
Returns
array With key min and max

Definition at line 1246 of file table.class.php.

◆ getRawName()

getRawName ( )

Get the raw table name

Returns
string

Definition at line 613 of file table.class.php.

◆ getRelated()

getRelated (   $name = null)

Get the related table

Parameters
string$nameIf need only 1 related information
Returns
array|null

Definition at line 384 of file table.class.php.

◆ getRelatedTable()

getRelatedTable (   $name)

Get the related table object

Parameters
string$nameRelated table name
Returns
db_table

Definition at line 411 of file table.class.php.

◆ getRelatedTableName()

getRelatedTableName (   $name,
  $add = true 
)

Get the name of the related table

Parameters
string$name
bool$addif True, the prefix will be added if needed. If false, it will removed if needed
Returns
string

Definition at line 424 of file table.class.php.

◆ getRelatedTableRow()

getRelatedTableRow (   $name,
array  $data = array() 
)

Get a row for a related table

Parameters
string$nameTable Name
array$dataThe data for overwrite the default value
Returns
db_row

Definition at line 399 of file table.class.php.

◆ getRow()

getRow ( array  $data = array(),
  $withAuto = false,
array  $morePrm = array() 
)

Get a row

Parameters
array$dataThe data for overwrite the default value
bool$withAutoInclude auto field
array$morePrmArray of configuration for the row
Returns
db_row

Definition at line 1291 of file table.class.php.

◆ getTargetingTables()

getTargetingTables ( )

Get Targeting table names

Returns
array Targeting table names

Definition at line 440 of file table.class.php.

◆ getWhere()

getWhere ( array  $prm = array())

Get a where object

Parameters
array$prmThe configuration for the where object
Returns
db_where

Definition at line 255 of file table.class.php.

◆ hasI18n()

hasI18n ( )

Indicate if the thable has a i18n table

Returns
bool

Definition at line 107 of file table.class.php.

◆ insert()

insert ( array  $data)

Insert into the table

Parameters
array$dataThe values to insert. The key are the identifier
Returns
mixed the inserted id
See also
db_abstract::insert

Definition at line 642 of file table.class.php.

◆ isI18n()

isI18n ( )

Indicate if the table is a i18n table

Returns
bool

Definition at line 98 of file table.class.php.

◆ isLinked()

isLinked (   $field)

Check if a field name is linked to a table

Parameters
string$fieldField name
Returns
bool

Definition at line 265 of file table.class.php.

◆ isRelated()

isRelated (   $name)

Check if a table name is ralted to the table

Parameters
string$nameTable name
Returns
bool

Definition at line 374 of file table.class.php.

◆ isTargeting()

isTargeting (   $tableName)

Indicates if the table is targeting an other table

Parameters
strong$tableNameTable name to check against
Returns
boolean

Definition at line 471 of file table.class.php.

◆ parseLinked()

static parseLinked ( array &  $data,
array  $linked 
)
static

Parse select result for the linked and related tables

Parameters
array$data(reference, will be updated) Data issued from the select
array$linkedLinked array issued from the select

Definition at line 1091 of file table.class.php.

◆ replace()

replace ( array  $data)

Replace into the table

Parameters
array$dataThe values to insert. The key are the identifier
Returns
mixed the inserted id
See also
db_abstract::insert

Definition at line 662 of file table.class.php.

◆ select()

select ( array  $prm = array())

Search on the table

Parameters
array$prmSelect query configuration. Same parameter than db::select, with more:
  • db_where|string|null filter: Where clause to filter the result. If string, serach to be equal to the identity
  • bool first: Return onlt the first result as a db_row
Returns
db_rowset|db_row
See also
selectQuery, db_abstract::select

Definition at line 799 of file table.class.php.

◆ selectQuery()

selectQuery ( array  $prm,
$tmpTables 
)

Create the right array paremeter for select query

Parameters
array$prmThe initial parameter
array$tmpTablesArray used with parseLinked

Definition at line 867 of file table.class.php.

◆ setAttr()

setAttr (   $name,
  $value 
)
inherited

Set an attribute

Parameters
string$nameAttribute name
mixed$valueAttribute value

Definition at line 58 of file object.class.php.

◆ update()

update ( array  $data,
  $where = null 
)

update data in the table

Parameters
array$dataThe values to update. The key are the identifier
db_where | array | string$where: The where clause. If array, they are used with AND. (default: none)
Returns
int Affected rows
See also
db_abstract::update

Definition at line 683 of file table.class.php.

Field Documentation

◆ $cfg

$cfg
protectedinherited

Definition at line 17 of file object.class.php.

◆ $cols

$cols = array()
protected

Definition at line 31 of file table.class.php.

◆ $fields

$fields = array()
protected

Definition at line 24 of file table.class.php.

◆ $i18nTable

$i18nTable
protected

Definition at line 66 of file table.class.php.

◆ $linkedTableNames

$linkedTableNames
protected

Definition at line 45 of file table.class.php.

◆ $linkedTables

$linkedTables
protected

Definition at line 38 of file table.class.php.

◆ $rawName

$rawName
protected

Definition at line 17 of file table.class.php.

◆ $relatedTables

$relatedTables
protected

Definition at line 52 of file table.class.php.

◆ $targetingTables

$targetingTables
protected

Definition at line 59 of file table.class.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13