diff --git a/.htaccess b/.htaccess index 3fc3e1a..6b571ce 100644 --- a/.htaccess +++ b/.htaccess @@ -4,18 +4,26 @@ Deny from all -# Friendly URL +# Rewrites for pretty URLs RewriteEngine On + + # Optional - The location of the project directory + #RewriteBase /path/to/project + # Ignoring any existing files RewriteCond %{REQUEST_FILENAME} !-f + # Ignoring any existing directories RewriteCond %{REQUEST_FILENAME} !-d - # Example 1 - Only pagination: http://localhost/PDO4You/index.php?n=1 OR http://localhost/PDO4You/index/n/1 + + # Example 1 - Only pagination: http://localhost/path/to/project/index.php?n=1 OR http://localhost/path/to/project/index/n/1 RewriteRule ^([A-Za-z]+)/([A-Za-z]+)/([0-9]+)/?$ $1.php?$2=$3 [L] - # Example 2 - Pagination + Id + Slug: http://localhost/PDO4You/index/paginator/number-current-page/id/some-title + + # Example 2 - Pagination + Id + Slug: http://localhost/path/to/project/index/paginator/number-current-page/id/some-title RewriteRule ^([A-Za-z]+)/([A-Za-z]+)/([0-9]+)/([0-9]+)/([\w\-\.]+)/?$ $1.php?$2=$3&id=$4&slug=$5 [L] - # For demo page: http://localhost/PDO4You/index/paginator/number-current-page/page-demo/page-name-demo + + # For demo page: http://localhost/path/to/project/index/paginator/number-current-page/page-demo/page-name-demo RewriteRule ^(\w+)/(\w+)/(\d+)/(\w+)/([\w]+)/?$ $1.php?$2=$3&$4=$5 [L] RewriteRule ^(\w+)/(\w+)/(\d+)/(\w+)/?$ $1.php [L] RewriteRule ^(\w+)/?$ $1.php [L] diff --git a/src/PDO4You/Describe.php b/src/PDO4You/Describe.php index 1bcaf79..d86628a 100644 --- a/src/PDO4You/Describe.php +++ b/src/PDO4You/Describe.php @@ -1,6 +1,5 @@ - * @copyright 2010-2013, Giovanni Ramos + * @copyright 2010-2014, Giovanni Ramos * @since 2010-09-07 * @license http://opensource.org/licenses/MIT * @link http://github.com/giovanniramos/PDO4You * @package PDO4You - * - * */ + */ class Describe { @@ -27,8 +25,7 @@ class Describe * @access public static * @param string $schema Name of the schema used * @return void - * - * */ + */ public static function showTables($schema = null) { try { @@ -58,8 +55,7 @@ public static function showTables($schema = null) * @access private static * @param void * @return void - * - * */ + */ private static function showMySqlTables() { Singleton::setStyle(); @@ -93,8 +89,7 @@ private static function showMySqlTables() * @access private static * @param string $schema Name of scheme * @return void - * - * */ + */ private static function showPgSqlTables($schema) { Singleton::setStyle(); @@ -126,8 +121,7 @@ private static function showPgSqlTables($schema) * @access private static * @param void * @return void - * - * */ + */ private static function showCubridTables() { Singleton::setStyle(); @@ -161,8 +155,7 @@ private static function showCubridTables() * @access private static * @param string $schema Name of scheme * @return void - * - * */ + */ private static function showMsSqlTables($schema) { Singleton::setStyle(); diff --git a/src/PDO4You/PDO4You.config.php b/src/PDO4You/PDO4You.config.php index 7ed7ebf..defc35b 100644 --- a/src/PDO4You/PDO4You.config.php +++ b/src/PDO4You/PDO4You.config.php @@ -1,19 +1,17 @@ - * @copyright 2010-2013, Giovanni Ramos + * @copyright 2010-2014, Giovanni Ramos * @since 2010-09-07 * @license http://opensource.org/licenses/MIT * @link http://github.com/giovanniramos/PDO4You * @package PDO4You - * - * */ + */ interface Config { // Connection adapter defined in: PDO4You.settings.ini diff --git a/src/PDO4You/PDO4You.php b/src/PDO4You/PDO4You.php index 09e1772..b8237f8 100644 --- a/src/PDO4You/PDO4You.php +++ b/src/PDO4You/PDO4You.php @@ -1,27 +1,25 @@ - * @copyright 2010-2013, Giovanni Ramos + * @copyright 2010-2014, Giovanni Ramos * @since 2010-09-07 * @license http://opensource.org/licenses/MIT * @link http://github.com/giovanniramos/PDO4You * @package PDO4You * @version 4.4 - * - * */ + */ class PDO4You implements Config { /** @@ -30,8 +28,7 @@ class PDO4You implements Config * * @access private static * @var string - * - * */ + */ private static $settings; /** @@ -39,8 +36,7 @@ class PDO4You implements Config * * @access private static * @var string - * - * */ + */ private static $datahost; /** @@ -48,8 +44,7 @@ class PDO4You implements Config * * @access private static * @var string - * - * */ + */ private static $dataport; /** @@ -57,8 +52,7 @@ class PDO4You implements Config * * @access private static * @var string - * - * */ + */ private static $connection; /** @@ -66,8 +60,7 @@ class PDO4You implements Config * * @access private static * @var object - * - * */ + */ private static $instance; /** @@ -75,8 +68,7 @@ class PDO4You implements Config * * @access private static * @var array - * - * */ + */ private static $handle = array(); /** @@ -84,35 +76,31 @@ class PDO4You implements Config * * @access private static * @var boolean - * - * */ + */ private static $persistent = false; /** * Stores the ID of the last inserted row or sequence value * - * @access private + * @access private static * @var string - * - * */ + */ private static $lastId; /** * Stores the total of affected rows in last CRUD operation * - * @access private + * @access private static * @var string - * - * */ + */ private static $rowCount; /** * Stores messages Exception thrown * - * @access public + * @access public static * @var array - * - * */ + */ public static $exception = array( 'code-1044' => 'Access denied for user: \'%1$s\'', 'code-1045' => 'Failed communication with the database using: \'%1$s\'@\'%2$s\'', @@ -135,8 +123,7 @@ class PDO4You implements Config * The constructor is set to private, preventing direct instance of the class * * @access private - * - * */ + */ private function __construct() { exit; @@ -148,9 +135,7 @@ private function __construct() * * @access public static * @param string $settings Path of the file that contains the configuration of adapters - * @return void - * - * */ + */ public static function setSettings($settings) { self::$settings = $settings; @@ -159,11 +144,9 @@ public static function setSettings($settings) /** * Method to retrieve the path of the file that contains the configuration of adapters * - * @access public static - * @param void + * @access private static * @return string - * - * */ + */ private static function getSettings() { // File directory @@ -183,11 +166,10 @@ private static function getSettings() * @param string $driver Driver DSN connection * @param string $user Username of the database * @param string $pass Password of the database - * @param string $option Configuration the connection driver + * @param array $option Configuration the connection driver * @return void - * @throws PDOException Throws an exception in case of connection failures - * - * */ + * @throws \PDOException Throws an exception in case of connection failures + */ private static function singleton($alias, $driver, $user, $pass, $option) { try { @@ -238,9 +220,7 @@ private static function singleton($alias, $driver, $user, $pass, $option) * * @access public static * @param string $alias Pseudonym of a connection instance - * @return void - * - * */ + */ public static function setInstance($alias) { self::$instance = self::getHandle($alias == null ? 'standard' : $alias); @@ -254,11 +234,10 @@ public static function setInstance($alias) * @param string $type Connection type if using "Initial Setup" or "Full DSN" * @param string $user Username of the database * @param string $pass Password of the database - * @param string $option Configuration the connection driver + * @param array $option Configuration the connection driver * @return object - * @throws Exception Throws an exception in case of connection failures - * - * */ + * @throws \PDOException Throws an exception in case of connection failures + */ public static function getInstance($alias = 'standard', $type = null, $user = null, $pass = null, Array $option = null) { try { @@ -383,11 +362,10 @@ public static function getInstance($alias = 'standard', $type = null, $user = nu /** * Method for assigning a new object instance PDO connection - * - * @param string $alias Pseudonym to identify the connection instance - * @param PDO $instance Object PDO connection - * @return void * + * @access private static + * @param string $alias Pseudonym to identify the connection instance + * @param \PDO $instance Object PDO connection */ private static function setHandle($alias, \PDO $instance) { @@ -396,16 +374,16 @@ private static function setHandle($alias, \PDO $instance) /** * Method to return an object PDO connection - * + * + * @access private static * @param string $alias Pseudonym of a connection instance * @return object - * */ private static function getHandle($alias) { self::setConnection($alias); - return self::$handle[$alias]; + return @ self::$handle[$alias]; } /** @@ -413,9 +391,7 @@ private static function getHandle($alias) * * @access private static * @param string $host Server name - * @return void - * - * */ + */ private static function setDatahost($host) { self::$datahost = $host; @@ -425,10 +401,8 @@ private static function setDatahost($host) * Method to retrieve the server name * * @access public static - * @param void * @return string - * - * */ + */ public static function getDatahost() { return self::$datahost; @@ -439,9 +413,7 @@ public static function getDatahost() * * @access private static * @param string $port Port number - * @return void - * - * */ + */ private static function setDataport($port) { self::$dataport = $port; @@ -451,10 +423,8 @@ private static function setDataport($port) * Method to retrieve the port number of the server * * @access public static - * @param void * @return string - * - * */ + */ public static function getDataport() { return self::$dataport; @@ -465,9 +435,7 @@ public static function getDataport() * * @access private static * @param string $alias Pseudonym of a connection instance - * @return void - * - * */ + */ private static function setConnection($alias) { self::$connection = $alias; @@ -477,10 +445,8 @@ private static function setConnection($alias) * Method to retrieve the name of the current instance of connection * * @access public static - * @param void * @return string - * - * */ + */ public static function getConnection() { return self::$connection; @@ -492,9 +458,7 @@ public static function getConnection() * * @access public static * @param boolean $persistent Sets a persistent connection - * @return void - * - * */ + */ public static function setPersistent($persistent = false) { self::$persistent = $persistent; @@ -504,11 +468,10 @@ public static function setPersistent($persistent = false) * Method to capture the error information of an Exception * * @access private static - * @param PDOException $e Gets the message from the exception thrown + * @param \PDOException $e Gets the message from the exception thrown * @param boolean $debug Enables the display of the captured values * @return array - * - * */ + */ private static function getErrorInfo(\PDOException $e, $debug = false) { if (defined(static::PDO4YOU_WEBMASTER)) { @@ -536,10 +499,8 @@ private static function getErrorInfo(\PDOException $e, $debug = false) * Method to retrieve the name of the current driver * * @access public static - * @param void * @return string - * - * */ + */ public static function getDriver() { return self::$instance->getAttribute(\PDO::ATTR_DRIVER_NAME); @@ -551,8 +512,7 @@ public static function getDriver() * @access public static * @param void * @return void - * - * */ + */ public static function showServerInfo() { try { @@ -575,8 +535,7 @@ public static function showServerInfo() * @access public static * @param void * @return void - * - * */ + */ public static function showAvailableDrivers() { try { @@ -597,8 +556,7 @@ public static function showAvailableDrivers() * @access public static * @param void * @return void - * - * */ + */ public static function css() { $style = '