Sgss_Collection_Pdo_TableRow
Represents a row already exists in a database table

Description

Class diagram:
Sgss_Collection_TableRow_Abstract
 + Sgss_Collection_Pdo_TableRow
Used by:
Sgss_Collection_Pdo_Table::retrieveRow()
Author:
Matsuda Shota
Copyright:
(c) 2007-2008 Matsuda Shota
Usedby:
Sgss_Collection_Pdo_Table::retrieveRow()
License:
http://creativecommons.org/licenses/GPL/2.0/
Located in:
/Collection/Pdo/TableRow.php (line 51)

Direct descendant

Sgss_Collection_Pdo_TableRow_Prepared Represents a row prepared to be inserted into a database table

Class overview

Variables

protected array $_columns

Column names defined in the database schema

protected array $_config

Config to connect to the database

protected PDO $_db

Database handle used with this row

protected string $_driver

Driver name of the database handle

protected array $_id

Row identifier of this row

protected string $_row

Name of the column containing row identifiers that already exists in the database

protected string $_table

Name of the table that already exists in the database

Methods

__construct (array|PDO $config, string $table, string $row, array $columns, mixed $id)

The constructor

boolean delete (mixed $column)

Deletes the value at the specified column of this row

mixed get (mixed $column)

Returns the value at the specified column of this row

boolean has (mixed $column)

Determines the specified column identifier is defined in the table containing this row

boolean insert ()

Inserts or replaces this row into the containing table

boolean remove ()

Removes this row from the containing table

boolean set (mixed $column, mixed $value)

Inserts or replaces the specified value into the specified column of this row

array toArray ()

Converts this row to an associated array

protected void _connect ()

Connects to the database

protected string|array _quoteName (string|array $name)

Quotes the specified table or column name

protected scalar _sopite (mixed $obj, [boolean $key = false])

Converts the specified object to the corresponding scalar value

protected mixed _waken (scalar $scalar, [boolean $key = false])

Converts the specified scalar value to the corresponding object

array __sleep ()
void __wakeup ()
Inherited from Sgss_Collection_TableRow_Abstract:
offsetExists(), offsetGet(), offsetSet(), offsetUnset(), __get(), __isset(), __set(), __unset()

Variable detail

$_columns 

Column names defined in the database schema

Signature:
protected array $_columns


$_config 

Config to connect to the database

Signature:
protected array $_config = array(...)


$_db 

Database handle used with this row

Signature:
protected PDO $_db


$_driver 

Driver name of the database handle

Signature:
protected string $_driver = ''


$_id 

Row identifier of this row

Signature:
protected array $_id


$_row 

Name of the column containing row identifiers that already exists in the database

Signature:
protected string $_row


$_table 

Name of the table that already exists in the database

Signature:
protected string $_table


Method detail

__construct

The constructor

Parameters:
  • array|PDO $config

    Config to connect to the database used with the row

  • string $table

    Name of the table that already exists in the database

  • string $row

    Name of the column containing row identifiers that already exists in the database

  • array $columns

    Column names defined in the database schema

  • mixed $id

    Row identifier of the row

Throws:
  • Sgss_Collection_Table_Exception

    When the $columns contains no element

Signature:
public __construct (array|PDO $config, string $table, string $row, array $columns, mixed $id)


delete

Deletes the value at the specified column of this row

Parameters:
  • mixed $column

    Column identifier from which the value to be removed

Returns:
boolean -- True when the operation changed this row
Overridden by:
Related subject:
Sgss_Collection_TableRow_Interface::set()
Signature:
public boolean delete (mixed $column)


get

Returns the value at the specified column of this row

Parameters:
  • mixed $column

    Column identifier from which the value to be retrieved

Returns:
mixed -- Value at the column of this row
Throws:
  • Sgss_Collection_TableRow_Exception

    When unable to prepare statement

Overridden by:
Uses:
Sgss_Collection_Pdo_TableRow::has(), Sgss_Collection_Pdo_TableRow::_waken()
Related subject:
Sgss_Collection_TableRow_Interface::get()
Signature:
public mixed get (mixed $column)


has

Determines the specified column identifier is defined in the table containing this row

Parameters:
  • mixed $column

    Column identifier to determine

Returns:
boolean -- True when the column identifier is defined in the table
Uses:
array_search()
Used by:
Sgss_Collection_Pdo_TableRow::set(), Sgss_Collection_Pdo_TableRow::get()
Related subject:
Sgss_Collection_TableRow_Interface::has()
Signature:
public boolean has (mixed $column)


insert

Inserts or replaces this row into the containing table

Returns:
boolean -- True when the operation changed the containing table
Overridden by:
Related subject:
Sgss_Collection_TableRow_Interface::insert()
Signature:
public boolean insert ()


remove

Removes this row from the containing table

Returns:
boolean -- True when the operation changed the containing table
Throws:
  • Sgss_Collection_TableRow_Exception

    When unable to prepare statement

Overridden by:
Related subject:
Sgss_Collection_TableRow_Interface::remove()
Signature:
public boolean remove ()


set

Inserts or replaces the specified value into the specified column of this row

Parameters:
  • mixed $column

    Column identifier into which the value to be inserted

  • mixed $value

    Value to be inserted into the specified column of this row

Returns:
boolean -- True when the operation changed this row
Throws:
  • Sgss_Collection_TableRow_Exception

    When unable to prepare statement

Overridden by:
Uses:
Sgss_Collection_Pdo_TableRow::has(), Sgss_Collection_Pdo_TableRow::_sopite()
Related subject:
Sgss_Collection_TableRow_Interface::set()
Signature:
public boolean set (mixed $column, mixed $value)


toArray

Converts this row to an associated array

Returns:
array -- Associated array representing this row
Throws:
  • Sgss_Collection_TableRow_Exception

    When unable to prepare statement

Overridden by:
Uses:
Sgss_Collection_Pdo_TableRow::_waken()
Related subject:
Sgss_Collection_TableRow_Interface::toArray()
Signature:
public array toArray ()


_connect 

Connects to the database

Throws:
  • Sgss_Collection_TableRow_Exception

    When unable to connect to the database

Used by:
Sgss_Collection_Pdo_TableRow::__wakeup(), Sgss_Collection_Pdo_TableRow_Prepared::insert()
Signature:
protected void _connect ()


_quoteName 

Quotes the specified table or column name

Parameters:
  • string|array $name

    Column or table name or its array to be quoted

Returns:
string|array -- Quoted string or array
Signature:
protected string|array _quoteName (string|array $name)


_sopite 

Converts the specified object to the corresponding scalar value

Parameters:
  • mixed $obj

    Object to be converted to scalar

  • boolean $key

    Whether the object is used as the key

Returns:
scalar -- Scalar value corresponding to the object
Throws:
  • Sgss_Collection_TableRow_Exception

    When the object is or contains unconvertable to scalar (resource or internal class)

Uses:
serialize()
Used by:
Sgss_Collection_Pdo_TableRow::set()
Signature:
protected scalar _sopite (mixed $obj, [boolean $key = false])


_waken 

Converts the specified scalar value to the corresponding object

Parameters:
  • scalar $scalar

    Scalar value to be converted to object

  • boolean $key

    Whether the converted object is to be used as the key

Returns:
mixed -- Object corresponding to the scalar
Uses:
unserialize()
Used by:
Sgss_Collection_Pdo_TableRow::toArray(), Sgss_Collection_Pdo_TableRow::get()
Signature:
protected mixed _waken (scalar $scalar, [boolean $key = false])


__sleep

Throws:
  • Sgss_Collection_TableRow_Exception

    When this row is unserializable

Overridden by:
Signature:
public array __sleep ()


__wakeup

Uses:
Sgss_Collection_Pdo_TableRow::_connect()
Signature:
public void __wakeup ()