Skip to content

Commit

Permalink
Cleanup Phalcon\Db\AdapterInterface::connect
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Jul 23, 2016
1 parent f2f91d0 commit 638b1c9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 62 deletions.
26 changes: 15 additions & 11 deletions phalcon/db/adapter/pdo.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand Down Expand Up @@ -31,14 +31,18 @@ use Phalcon\Db\Result\Pdo as ResultPdo;
*
* Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect to a database
*
*<code>
* $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array(
* 'host' => '192.168.0.11',
* 'username' => 'sigma',
* 'password' => 'secret',
* 'dbname' => 'blog',
* 'port' => '3306'
* ));
* <code>
* use Phalcon\Db\Adapter\Pdo\Mysql;
*
* $config = [
* 'host' => 'localhost',
* 'dbname' => 'blog',
* 'port' => 3306,
* 'username' => 'sigma',
* 'password' => 'secret'
* ];
*
* $connection = new Mysql($config);
*</code>
*/
abstract class Pdo extends Adapter
Expand Down Expand Up @@ -83,12 +87,12 @@ abstract class Pdo extends Adapter
* @param array descriptor
* @return boolean
*/
public function connect(descriptor = null)
public function connect(array descriptor = null) -> boolean
{
var username, password, dsnParts, dsnAttributes,
persistent, options, key, value;

if descriptor === null {
if empty descriptor {
let descriptor = this->_descriptor;
}

Expand Down
13 changes: 6 additions & 7 deletions phalcon/db/adapter/pdo/mysql.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand Down Expand Up @@ -33,15 +33,14 @@ use Phalcon\Db\Adapter\Pdo as PdoAdapter;
* Specific functions for the Mysql database system
*
*<code>
*
* use Phalcon\Db\Adapter\Pdo\Mysql;
*
* $config = [
* "host" => "192.168.0.11",
* "dbname" => "blog",
* "port" => 3306,
* "username" => "sigma",
* "password" => "secret"
* 'host' => 'localhost',
* 'dbname' => 'blog',
* 'port' => 3306,
* 'username' => 'sigma',
* 'password' => 'secret'
* ];
*
* $connection = new Mysql($config);
Expand Down
32 changes: 17 additions & 15 deletions phalcon/db/adapter/pdo/oracle.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand All @@ -29,16 +29,17 @@ use Phalcon\Db\Adapter\Pdo as PdoAdapter;
* Phalcon\Db\Adapter\Pdo\Oracle
*
* Specific functions for the Oracle database system
* <code>
*
* $config = array(
* "dbname" => "//localhost/dbname",
* "username" => "oracle",
* "password" => "oracle"
* );
* <code>
* use Phalcon\Db\Adapter\Pdo\Oracle;
*
* $connection = new \Phalcon\Db\Adapter\Pdo\Oracle($config);
* $config = [
* 'dbname' => '//localhost/dbname',
* 'username' => 'oracle',
* 'password' => 'oracle'
* ];
*
* $connection = new Oracle($config);
* </code>
*/
class Oracle extends PdoAdapter implements AdapterInterface
Expand All @@ -51,22 +52,21 @@ class Oracle extends PdoAdapter implements AdapterInterface
/**
* This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
* Call it when you need to restore a database connection.
*
* @param array descriptor
* @return boolean
*/
public function connect(descriptor = null) -> boolean
public function connect(array descriptor = null) -> boolean
{
var startup, value, status;

if !descriptor {
if empty descriptor {
let descriptor = this->_descriptor;
}

let status = parent::connect(descriptor);

/**
* Database session settings initiated with each HTTP request. Oracle behaviour depends on particular NLS* parameter. Check if the developer has defined custom startup or create one from scratch
* Database session settings initiated with each HTTP request.
* Oracle behaviour depends on particular NLS* parameter.
* Check if the developer has defined custom startup or create one from scratch
*/
if fetch startup, descriptor["startup"] {
if typeof startup == "array" {
Expand All @@ -82,7 +82,9 @@ class Oracle extends PdoAdapter implements AdapterInterface
/**
* Returns an array of Phalcon\Db\Column objects describing a table
*
* <code>print_r($connection->describeColumns("posts")); ?></code>
* <code>
* print_r($connection->describeColumns("posts"));
* </code>
*/
public function describeColumns(string! table, string schema = null) -> <Column[]>
{
Expand Down
26 changes: 13 additions & 13 deletions phalcon/db/adapter/pdo/postgresql.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand All @@ -30,17 +30,20 @@ use Phalcon\Db\Exception;
* Phalcon\Db\Adapter\Pdo\Postgresql
*
* Specific functions for the Postgresql database system
*
* <code>
* use Phalcon\Db\Adapter\Pdo\Postgresql;
*
* $config = array(
* "host" => "192.168.0.11",
* "dbname" => "blog",
* "username" => "postgres",
* "password" => ""
* );
* $config = [
* 'host' => 'localhost',
* 'dbname' => 'blog',
* 'port' => 5432,
* 'username' => 'postgres',
* 'password' => 'secret'
* ];
*
* $connection = new \Phalcon\Db\Adapter\Pdo\Postgresql($config);
*
* $connection = new Postgresql($config);
* </code>
*/
class Postgresql extends PdoAdapter implements AdapterInterface
Expand All @@ -53,15 +56,12 @@ class Postgresql extends PdoAdapter implements AdapterInterface
/**
* This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
* Call it when you need to restore a database connection.
*
* @param array $descriptor
* @return boolean
*/
public function connect(descriptor = null)
public function connect(array descriptor = null) -> boolean
{
var schema, sql;

if descriptor === null {
if empty descriptor {
let descriptor = this->_descriptor;
}

Expand Down
19 changes: 9 additions & 10 deletions phalcon/db/adapter/pdo/sqlite.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand Down Expand Up @@ -35,13 +35,15 @@ use Phalcon\Db\Adapter\Pdo as PdoAdapter;
* Phalcon\Db\Adapter\Pdo\Sqlite
*
* Specific functions for the Sqlite database system
*
* <code>
* use Phalcon\Db\Adapter\Pdo\Sqlite;
*
* $config = array(
* "dbname" => "/tmp/test.sqlite"
* );
* $config = [
* 'dbname' => '/tmp/test.sqlite'
* ];
*
* $connection = new \Phalcon\Db\Adapter\Pdo\Sqlite($config);
* $connection = new Sqlite($config);
* </code>
*/
class Sqlite extends PdoAdapter implements AdapterInterface
Expand All @@ -54,15 +56,12 @@ class Sqlite extends PdoAdapter implements AdapterInterface
/**
* This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
* Call it when you need to restore a database connection.
*
* @param array $descriptor
* @return boolean
*/
public function connect(descriptor = null)
public function connect(array descriptor = null) -> boolean
{
var dbname;

if descriptor === null {
if empty descriptor {
let descriptor = this->_descriptor;
}

Expand Down
9 changes: 3 additions & 6 deletions phalcon/db/adapterinterface.zep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Phalcon\Db;

/**
* Phalcon\Db\Adapter\Pdo\Mysql
* Phalcon\Db\AdapterInterface
*
* Interface for Phalcon\Db adapters
*/
Expand Down Expand Up @@ -255,13 +255,10 @@ interface AdapterInterface
public function getDialect() -> <DialectInterface>;

/**
* This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
* This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor.
* Call it when you need to restore a database connection
*
* @param array descriptor
* @return boolean
*/
public function connect(descriptor = null);
public function connect(array descriptor = null) -> boolean;

/**
* Sends SQL statements to the database server returning the success state.
Expand Down

0 comments on commit 638b1c9

Please sign in to comment.