Fix some typos and docblocks
This commit is contained in:
parent
d6c0fd23dc
commit
0a64edd453
@ -31,7 +31,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the last executed query
|
* Reference to the last executed query
|
||||||
* @var PDOStatement
|
* @var \PDOStatement
|
||||||
*/
|
*/
|
||||||
protected $statement;
|
protected $statement;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to util class
|
* Reference to util class
|
||||||
* @var DB_Util
|
* @var Abstract_Util
|
||||||
*/
|
*/
|
||||||
public $util;
|
public $util;
|
||||||
|
|
||||||
@ -102,6 +102,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $args
|
* @param array $args
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __call($name, $args = array())
|
public function __call($name, $args = array())
|
||||||
{
|
{
|
||||||
@ -415,7 +416,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retreives an array of non-user-created tables for
|
* Retrieves an array of non-user-created tables for
|
||||||
* the connection/database
|
* the connection/database
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
@ -479,7 +480,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to simplify retreiving db results for meta-data queries
|
* Method to simplify retrieving db results for meta-data queries
|
||||||
*
|
*
|
||||||
* @param string|array|null $query
|
* @param string|array|null $query
|
||||||
* @param bool $filtered_index
|
* @param bool $filtered_index
|
||||||
|
@ -65,9 +65,9 @@ final class Connection_Manager {
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure serialize/deseriaze doesn't work
|
* Make sure serialize/deserialize doesn't work
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @throws DomainException
|
* @throws \DomainException
|
||||||
*/
|
*/
|
||||||
private function __wakeup()
|
private function __wakeup()
|
||||||
{
|
{
|
||||||
@ -102,11 +102,11 @@ final class Connection_Manager {
|
|||||||
*
|
*
|
||||||
* @param string|array|object $name
|
* @param string|array|object $name
|
||||||
* @return Query_Builder
|
* @return Query_Builder
|
||||||
* @throws InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function get_connection($name = '')
|
public function get_connection($name = '')
|
||||||
{
|
{
|
||||||
// If the paramater is a string, use it as an array index
|
// If the parameter is a string, use it as an array index
|
||||||
if (is_scalar($name) && isset($this->connections[$name]))
|
if (is_scalar($name) && isset($this->connections[$name]))
|
||||||
{
|
{
|
||||||
return $this->connections[$name];
|
return $this->connections[$name];
|
||||||
@ -169,6 +169,7 @@ final class Connection_Manager {
|
|||||||
* Parses params into a dsn and option array
|
* Parses params into a dsn and option array
|
||||||
*
|
*
|
||||||
* @param \ArrayObject $params
|
* @param \ArrayObject $params
|
||||||
|
* @return array
|
||||||
* @throws BadDBDriverException
|
* @throws BadDBDriverException
|
||||||
*/
|
*/
|
||||||
private function parse_params(\ArrayObject $params)
|
private function parse_params(\ArrayObject $params)
|
||||||
@ -177,7 +178,7 @@ final class Connection_Manager {
|
|||||||
$dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql';
|
$dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql';
|
||||||
|
|
||||||
// Make sure the class exists
|
// Make sure the class exists
|
||||||
if ( ! class_exists("Query\\Driver\\$dbtype"))
|
if ( ! class_exists("Query\\Driver\\{$dbtype}"))
|
||||||
{
|
{
|
||||||
throw new BadDBDriverException('Database driver does not exist, or is not supported');
|
throw new BadDBDriverException('Database driver does not exist, or is not supported');
|
||||||
}
|
}
|
||||||
|
@ -1,96 +1,144 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Query
|
* Query
|
||||||
*
|
*
|
||||||
* Free Query Builder / Database Abstraction Layer
|
* Free Query Builder / Database Abstraction Layer
|
||||||
*
|
*
|
||||||
* @package Query
|
* @package Query
|
||||||
* @author Timothy J. Warren
|
* @author Timothy J. Warren
|
||||||
* @copyright Copyright (c) 2012 - 2014
|
* @copyright Copyright (c) 2012 - 2014
|
||||||
* @link https://github.com/aviat4ion/Query
|
* @link https://github.com/aviat4ion/Query
|
||||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Query\Driver;
|
namespace Query\Driver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDO Interface to implement for database drivers
|
* PDO Interface to implement for database drivers
|
||||||
*
|
*
|
||||||
* @package Query
|
* @package Query
|
||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
*/
|
*/
|
||||||
interface Driver_Interface {
|
interface Driver_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor/Connection method
|
* Constructor/Connection method
|
||||||
*
|
*
|
||||||
* @param string $dsn
|
* @param string $dsn
|
||||||
* @param [string] $username
|
* @param string $username
|
||||||
* @param [string] $password
|
* @param string $password
|
||||||
* @param [array] $driver_options
|
* @param array $driver_options
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options = array());
|
public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begin a transaction
|
* Begin a transaction
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function beginTransaction();
|
public function beginTransaction();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commit a transaction
|
* Commit a transaction
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function commit();
|
public function commit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current error code
|
* Return the current error code
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function errorCode();
|
public function errorCode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return information about the current error
|
* Return information about the current error
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function errorInfo();
|
public function errorInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute an SQL statement and return the number of affected rows
|
* Execute an SQL statement and return the number of affected rows
|
||||||
*
|
*
|
||||||
* @param string $statement
|
* @param string $statement
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function exec($statement);
|
public function exec($statement);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a connection attribute for the current db driver
|
* Get a connection attribute for the current db driver
|
||||||
*
|
*
|
||||||
* @param int $attribute
|
* @param int $attribute
|
||||||
* @returm mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAttribute($attribute);
|
public function getAttribute($attribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback a transaction
|
* Rollback a transaction
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function rollback();
|
public function rollback();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a connection attribute
|
* Set a connection attribute
|
||||||
* @param int $attribute
|
* @param int $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setAttribute($attribute, $value);
|
public function setAttribute($attribute, $value);
|
||||||
}
|
|
||||||
// End of driver_interface.php
|
/**
|
||||||
|
* Retrieve column information for the current database table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_columns($table);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve foreign keys for the table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_fks($table);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of tables for the current database
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_tables();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Surrounds the string with the databases identifier escape characters
|
||||||
|
*
|
||||||
|
* @param mixed $ident
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function quote_ident($ident);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quote database table name, and set prefix
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function quote_table($table);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and execute a prepared statement with the provided parameters
|
||||||
|
*
|
||||||
|
* @param string $sql
|
||||||
|
* @param array $params
|
||||||
|
* @return \PDOStatement
|
||||||
|
*/
|
||||||
|
public function prepare_execute($sql, $params);
|
||||||
|
}
|
||||||
|
// End of driver_interface.php
|
||||||
|
@ -26,10 +26,9 @@ interface SQL_Interface {
|
|||||||
/**
|
/**
|
||||||
* Get database specific sql for limit clause
|
* Get database specific sql for limit clause
|
||||||
*
|
*
|
||||||
* @abstract
|
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @param int $offset
|
* @param int|bool $offset
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function limit($sql, $limit, $offset=FALSE);
|
public function limit($sql, $limit, $offset=FALSE);
|
||||||
@ -45,7 +44,6 @@ interface SQL_Interface {
|
|||||||
/**
|
/**
|
||||||
* Get the sql for random ordering
|
* Get the sql for random ordering
|
||||||
*
|
*
|
||||||
* @abstract
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function random();
|
public function random();
|
||||||
|
@ -18,7 +18,7 @@ namespace Query;
|
|||||||
use \Query\Driver\Driver_Interface;
|
use \Query\Driver\Driver_Interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convienience class for creating sql queries - also the class that
|
* Convenience class for creating sql queries - also the class that
|
||||||
* instantiates the specific db driver
|
* instantiates the specific db driver
|
||||||
*
|
*
|
||||||
* @package Query
|
* @package Query
|
||||||
@ -32,13 +32,13 @@ class Query_Builder implements Query_Builder_Interface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiled 'select' clause
|
* Compiled 'select' clause
|
||||||
* @var type string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $select_string = '';
|
protected $select_string = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiled 'from' clause
|
* Compiled 'from' clause
|
||||||
* @var type string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $from_string;
|
protected $from_string;
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ class Query_Builder implements Query_Builder_Interface {
|
|||||||
* Selects the maximum value of a field from a query
|
* Selects the maximum value of a field from a query
|
||||||
*
|
*
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @param string $as
|
* @param string|FALSE $as
|
||||||
* @return Query_Builder
|
* @return Query_Builder
|
||||||
*/
|
*/
|
||||||
public function select_max($field, $as=FALSE)
|
public function select_max($field, $as=FALSE)
|
||||||
@ -562,7 +562,7 @@ class Query_Builder implements Query_Builder_Interface {
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do all the repeditive stuff for where/having type methods
|
* Do all the repedative stuff for where/having type methods
|
||||||
*
|
*
|
||||||
* @param mixed $key
|
* @param mixed $key
|
||||||
* @param mixed $val
|
* @param mixed $val
|
||||||
@ -891,7 +891,7 @@ class Query_Builder implements Query_Builder_Interface {
|
|||||||
* Set a limit on the current sql statement
|
* Set a limit on the current sql statement
|
||||||
*
|
*
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @param int $offset
|
* @param int|bool $offset
|
||||||
* @return Query_Builder
|
* @return Query_Builder
|
||||||
*/
|
*/
|
||||||
public function limit($limit, $offset=FALSE)
|
public function limit($limit, $offset=FALSE)
|
||||||
@ -973,8 +973,8 @@ class Query_Builder implements Query_Builder_Interface {
|
|||||||
* execute current compiled query
|
* execute current compiled query
|
||||||
*
|
*
|
||||||
* @param $table
|
* @param $table
|
||||||
* @param int $limit
|
* @param int|bool $limit
|
||||||
* @param int $offset
|
* @param int|bool $offset
|
||||||
* @return PDOStatement
|
* @return PDOStatement
|
||||||
*/
|
*/
|
||||||
public function get($table='', $limit=FALSE, $offset=FALSE)
|
public function get($table='', $limit=FALSE, $offset=FALSE)
|
||||||
|
@ -311,7 +311,15 @@ class Table_Builder {
|
|||||||
*/
|
*/
|
||||||
public function has_foreign_key($columns, $constraint = NULL)
|
public function has_foreign_key($columns, $constraint = NULL)
|
||||||
{
|
{
|
||||||
|
$keys = $this->get_driver()->get_fks($this->name);
|
||||||
|
|
||||||
|
|
||||||
|
foreach($keys as $key)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -363,7 +371,7 @@ class Table_Builder {
|
|||||||
*/
|
*/
|
||||||
public function get_columns()
|
public function get_columns()
|
||||||
{
|
{
|
||||||
return $this->driver->get_columns($this->prefix_table($this->name));
|
return $this->driver->get_columns($this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -430,4 +438,4 @@ class Table_Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// End of table_bulider.php
|
// End of table_builder.php
|
||||||
|
@ -72,6 +72,8 @@ class Firebird extends Abstract_Driver {
|
|||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $pass
|
* @param string $pass
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
* @throws \PDOException
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', array $options = array())
|
public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', array $options = array())
|
||||||
{
|
{
|
||||||
@ -226,7 +228,7 @@ class Firebird extends Abstract_Driver {
|
|||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return Firebird_Result
|
* @return Firebird_Result
|
||||||
* @throws PDOException
|
* @throws \PDOException
|
||||||
*/
|
*/
|
||||||
public function prepare($query, $options=array())
|
public function prepare($query, $options=array())
|
||||||
{
|
{
|
||||||
@ -355,7 +357,7 @@ class Firebird extends Abstract_Driver {
|
|||||||
*/
|
*/
|
||||||
public function errorCode()
|
public function errorCode()
|
||||||
{
|
{
|
||||||
return fbird_errcode();
|
return \fbird_errcode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user