Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 33 → Rev 34

/trunk/Db/Database.php
95,8 → 95,44
*/
protected $_lastInsertId = '';
public function __construct()
/**
* Creates a new <code>Database</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 string $dsn
* @param string $username
* @param string $password
* @param mixed $options
*/
public function __construct($dsn = '', $username = null,
$password = null, array $options = array())
{
if ($dsn !== '')
{
$this->_dsn = $dsn;
}
if ($username !== null)
{
$this->_username = $username;
}
if ($password !== null)
{
$this->_password = $password;
}
if ($options)
{
$this->_options = $options;
}
$this->_connection =
new PDO($this->_dsn, $this->_username, $this->_password, $this->_options);
}
388,8 → 424,10
if (is_array($where) && $this->_isAssociativeArray($where))
{
/* FIXME: Export and reuse this */
foreach ($where as $column => $condition)
{
/* TODO: Also handle function calls as keys */
if (is_array($condition) && $this->_isAssociativeArray($condition))
{
reset($condition);
/trunk/Db/Table.php
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;
}
}
/**
/trunk/Db/database.class.php
1,6 → 1,6
<?php
 
require_once __LIB__ . '/../global.inc';
require_once __DIR__ . '/../global.inc';
 
/* NOTE: Obsolete with autoloader */
//require_once 'Zend/Registry.php';