1,5 → 1,6 |
<?php |
|
require_once __DIR__ . '/../Application.php'; |
require_once __DIR__ . '/../AbstractModel.php'; |
|
/** |
10,7 → 11,7 |
* ID of the last inserted row, or the last value from |
a sequence object, depending on the underlying driver. |
*/ |
abstract class Table extends AbstractModel |
class Table extends AbstractModel |
{ |
/** |
* Name of the table |
25,9 → 26,50 |
|
protected $_id = 'id'; |
|
public function __construct() |
/** |
* Creates a new <code>Table</code> instance. |
* |
* Each of the parameters is optional and can also be given |
* by a protected property where the parameter name is preceded |
* by <code>_</code>. Parameter values overwrite the default |
* property values. It is recommended to use default property |
* values of inheriting classes except for small applications |
* and testing purposes. |
* |
* @param Database $database |
* Database of the table (required in order to use a fitting |
* query language) |
* @param string $name |
* Table name |
* @param string $id |
* Name of the primary key column |
* @throws InvalidArgumentException |
*/ |
public function __construct(Database $database = null, $name = '', $id = '') |
{ |
$this->_database = Application::getInstance()->getDefaultDatabase(); |
if ($database === null) |
{ |
$this->_database = Application::getInstance()->getDefaultDatabase(); |
} |
else |
{ |
$this->_database = $database; |
} |
|
if ($name !== '') |
{ |
$this->_name = $name; |
} |
|
if (!$this->_name) |
{ |
throw new InvalidArgumentException('a table name is required'); |
} |
|
if ($id !== '') |
{ |
$this->_id = $id; |
} |
} |
|
/** |