Fix some typos and docblocks

This commit is contained in:
Timothy Warren 2014-04-22 14:02:54 -04:00
parent d6c0fd23dc
commit 0a64edd453
7 changed files with 178 additions and 120 deletions

View File

@ -31,7 +31,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
/**
* Reference to the last executed query
* @var PDOStatement
* @var \PDOStatement
*/
protected $statement;
@ -49,7 +49,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
/**
* Reference to util class
* @var DB_Util
* @var Abstract_Util
*/
public $util;
@ -102,6 +102,7 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
*
* @param string $name
* @param array $args
* @return mixed
*/
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
*
* @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 bool $filtered_index

View File

@ -65,9 +65,9 @@ final class Connection_Manager {
// --------------------------------------------------------------------------
/**
* Make sure serialize/deseriaze doesn't work
* Make sure serialize/deserialize doesn't work
* @codeCoverageIgnore
* @throws DomainException
* @throws \DomainException
*/
private function __wakeup()
{
@ -102,11 +102,11 @@ final class Connection_Manager {
*
* @param string|array|object $name
* @return Query_Builder
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
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]))
{
return $this->connections[$name];
@ -169,6 +169,7 @@ final class Connection_Manager {
* Parses params into a dsn and option array
*
* @param \ArrayObject $params
* @return array
* @throws BadDBDriverException
*/
private function parse_params(\ArrayObject $params)
@ -177,7 +178,7 @@ final class Connection_Manager {
$dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql';
// 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');
}

View File

@ -1,96 +1,144 @@
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
namespace Query\Driver;
/**
* PDO Interface to implement for database drivers
*
* @package Query
* @subpackage Drivers
*/
interface Driver_Interface {
/**
* Constructor/Connection method
*
* @param string $dsn
* @param [string] $username
* @param [string] $password
* @param [array] $driver_options
* @return void
*/
public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options = array());
/**
* Begin a transaction
*
* @return bool
*/
public function beginTransaction();
/**
* Commit a transaction
*
* @return bool
*/
public function commit();
/**
* Return the current error code
*
* @return mixed
*/
public function errorCode();
/**
* Return information about the current error
*
* @return array
*/
public function errorInfo();
/**
* Execute an SQL statement and return the number of affected rows
*
* @param string $statement
* @return int
*/
public function exec($statement);
/**
* Get a connection attribute for the current db driver
*
* @param int $attribute
* @returm mixed
*/
public function getAttribute($attribute);
/**
* Rollback a transaction
*
* @return bool
*/
public function rollback();
/**
* Set a connection attribute
* @param int $attribute
* @param mixed $value
* @return bool
*/
public function setAttribute($attribute, $value);
}
// End of driver_interface.php
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
* @copyright Copyright (c) 2012 - 2014
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
namespace Query\Driver;
/**
* PDO Interface to implement for database drivers
*
* @package Query
* @subpackage Drivers
*/
interface Driver_Interface {
/**
* Constructor/Connection method
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $driver_options
* @return void
*/
public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options = array());
/**
* Begin a transaction
*
* @return bool
*/
public function beginTransaction();
/**
* Commit a transaction
*
* @return bool
*/
public function commit();
/**
* Return the current error code
*
* @return mixed
*/
public function errorCode();
/**
* Return information about the current error
*
* @return array
*/
public function errorInfo();
/**
* Execute an SQL statement and return the number of affected rows
*
* @param string $statement
* @return int
*/
public function exec($statement);
/**
* Get a connection attribute for the current db driver
*
* @param int $attribute
* @return mixed
*/
public function getAttribute($attribute);
/**
* Rollback a transaction
*
* @return bool
*/
public function rollback();
/**
* Set a connection attribute
* @param int $attribute
* @param mixed $value
* @return bool
*/
public function setAttribute($attribute, $value);
/**
* 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

View File

@ -26,10 +26,9 @@ interface SQL_Interface {
/**
* Get database specific sql for limit clause
*
* @abstract
* @param string $sql
* @param int $limit
* @param int $offset
* @param int|bool $offset
* @return string
*/
public function limit($sql, $limit, $offset=FALSE);
@ -45,7 +44,6 @@ interface SQL_Interface {
/**
* Get the sql for random ordering
*
* @abstract
* @return string
*/
public function random();

View File

@ -18,7 +18,7 @@ namespace Query;
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
*
* @package Query
@ -32,13 +32,13 @@ class Query_Builder implements Query_Builder_Interface {
/**
* Compiled 'select' clause
* @var type string
* @var string
*/
protected $select_string = '';
/**
* Compiled 'from' clause
* @var type string
* @var 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
*
* @param string $field
* @param string $as
* @param string|FALSE $as
* @return Query_Builder
*/
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 $val
@ -891,7 +891,7 @@ class Query_Builder implements Query_Builder_Interface {
* Set a limit on the current sql statement
*
* @param int $limit
* @param int $offset
* @param int|bool $offset
* @return Query_Builder
*/
public function limit($limit, $offset=FALSE)
@ -973,8 +973,8 @@ class Query_Builder implements Query_Builder_Interface {
* execute current compiled query
*
* @param $table
* @param int $limit
* @param int $offset
* @param int|bool $limit
* @param int|bool $offset
* @return PDOStatement
*/
public function get($table='', $limit=FALSE, $offset=FALSE)

View File

@ -311,7 +311,15 @@ class Table_Builder {
*/
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()
{
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

View File

@ -72,6 +72,8 @@ class Firebird extends Abstract_Driver {
* @param string $user
* @param string $pass
* @param array $options
* @throws \PDOException
* @return void
*/
public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', array $options = array())
{
@ -226,7 +228,7 @@ class Firebird extends Abstract_Driver {
* @param string $query
* @param array $options
* @return Firebird_Result
* @throws PDOException
* @throws \PDOException
*/
public function prepare($query, $options=array())
{
@ -355,7 +357,7 @@ class Firebird extends Abstract_Driver {
*/
public function errorCode()
{
return fbird_errcode();
return \fbird_errcode();
}
// --------------------------------------------------------------------------