Skip to content

Commit

Permalink
Added the remaining missing destructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziminji committed Sep 1, 2015
1 parent e9f6d0a commit 0441205
Show file tree
Hide file tree
Showing 27 changed files with 171 additions and 51 deletions.
12 changes: 11 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM
* @version 2014-04-24
* @version 2015-08-31
*/
abstract class Builder extends \Leap\Core\Object {

Expand All @@ -48,6 +48,16 @@ public function __construct(\Leap\Core\DB\SQL\Builder $builder) {
$this->builder = $builder;
}

/**
* This destructor ensures that all references have been destroyed.
*
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->builder);
}

}

}
14 changes: 13 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Delete/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM\Delete
* @version 2014-07-04
* @version 2015-08-31
*/
class Proxy extends \Leap\Core\Object implements \Leap\Core\DB\SQL\Statement {

Expand Down Expand Up @@ -98,6 +98,18 @@ public function __construct($model) {
$this->builder->from($table);
}

/**
* This destructor ensures that all references have been destroyed.
*
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->builder);
unset($this->data_source);
unset($this->extension);
}

/**
* This method returns the raw SQL command.
*
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM
* @version 2014-04-24
* @version 2015-08-31
*
* @see http://www.firebirdsql.org/manual/migration-mssql-data-types.html
* @see http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx
Expand Down Expand Up @@ -85,6 +85,7 @@ public function __construct(\Leap\Core\DB\ORM\Model $model, $type) {
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->metadata);
unset($this->model);
unset($this->value);
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Field/Adaptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM\Field
* @version 2014-01-26
* @version 2015-08-31
*/
abstract class Adaptor extends \Leap\Core\Object {

Expand Down Expand Up @@ -69,6 +69,7 @@ public function __construct(\Leap\Core\DB\ORM\Model $model, $field) {
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->metadata);
unset($this->model);
}
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Field/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM\Field
* @version 2014-01-26
* @version 2015-08-31
*/
class Alias extends \Leap\Core\Object {

Expand Down Expand Up @@ -68,6 +68,7 @@ public function __construct(\Leap\Core\DB\ORM\Model $model, $field) {
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->metadata);
unset($this->model);
}
Expand Down
15 changes: 14 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Insert/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM\Insert
* @version 2014-07-04
* @version 2015-08-31
*/
class Proxy extends \Leap\Core\Object implements \Leap\Core\DB\SQL\Statement {

Expand Down Expand Up @@ -82,6 +82,19 @@ public function __construct($model) {
$this->model = $model;
}

/**
* This destructor ensures that all references have been destroyed.
*
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->builder);
unset($this->data_source);
unset($this->extension);
unset($this->model);
}

/**
* This method attempts to call an otherwise inaccessible function on the model's
* builder extension.
Expand Down
32 changes: 23 additions & 9 deletions src/classes/Leap/Core/DB/ORM/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM
* @version 2014-04-24
* @version 2015-08-31
*/
abstract class Model extends \Leap\Core\Object implements \Leap\Core\GC\IDisposable {

Expand All @@ -36,56 +36,63 @@ abstract class Model extends \Leap\Core\Object implements \Leap\Core\GC\IDisposa
* @access protected
* @var array
*/
protected $adaptors = array();
protected $adaptors;

/**
* This variable stores the aliases for certain fields.
*
* @access protected
* @var array
*/
protected $aliases = array();
protected $aliases;

/**
* This variable stores whether dispose has been called.
*
* @access protected
* @var boolean
*/
protected $disposed = FALSE;
protected $disposed;

/**
* This variable stores the record's fields.
*
* @access protected
* @var array
*/
protected $fields = array();
protected $fields;

/**
* This variable stores the record's metadata.
*
* @access protected
* @var array
*/
protected $metadata = array();
protected $metadata;

/**
* This variable stores the record's relations.
*
* @access protected
* @var array
*/
protected $relations = array();
protected $relations;

/**
* This constructor instantiates this class.
*
* @access public
*/
public function __construct() {
$this->metadata['loaded'] = FALSE;
$this->metadata['saved'] = NULL;
$this->adaptors = array();
$this->aliases = array();
$this->disposed = FALSE;
$this->fields = array();
$this->metadata = array(
'loaded' => FALSE,
'saved' => NULL,
);
$this->relations = array();
}

/**
Expand All @@ -95,6 +102,13 @@ public function __construct() {
*/
public function __destruct() {
$this->dispose(FALSE);
parent::__destruct();
unset($this->adaptors);
unset($this->aliases);
unset($this->disposed);
unset($this->fields);
unset($this->metadata);
unset($this->relations);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Core/DB/ORM/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM
* @version 2014-01-28
* @version 2015-08-31
*/
abstract class Relation extends \Leap\Core\Object {

Expand Down Expand Up @@ -74,6 +74,7 @@ public function __construct(\Leap\Core\DB\ORM\Model $model, $type) {
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->cache);
unset($this->metadata);
unset($this->model);
Expand Down
14 changes: 14 additions & 0 deletions src/classes/Leap/Core/DB/ORM/Select/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ public function __construct($model, Array $columns = array()) {
$this->model = $model;
}

/**
* This destructor ensures that all references have been destroyed.
*
* @access public
*/
public function __destruct() {
parent::__destruct();
unset($this->builder);
unset($this->data_source);
unset($this->extension);
unset($this->model);
unset($this->table);
}

/**
* This method returns the raw SQL command.
*
Expand Down
37 changes: 25 additions & 12 deletions src/classes/Leap/Core/DB/ORM/Update/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Core\DB\ORM\Update
* @version 2014-07-04
* @version 2015-08-31
*/
class Proxy extends \Leap\Core\Object implements \Leap\Core\DB\SQL\Statement {

Expand Down Expand Up @@ -78,6 +78,19 @@ public function __call($function, $arguments) {
throw new \Leap\Core\Throwable\UnimplementedMethod\Exception('Message: Call to undefined member function. Reason: Function :function has not been defined in class :class.', array(':class' => get_class($this->extension), ':function' => $function, ':arguments' => $arguments));
}

/**
* This method returns the SQL command.
*
* @access public
* @override
* @param boolean $terminated whether to add a semi-colon to the end
* of the statement
* @return \Leap\Core\DB\SQL\Command the SQL command
*/
public function command($terminated = TRUE) {
return $this->builder->command($terminated);
}

/**
* This constructor instantiates this class using the specified model's name.
*
Expand All @@ -99,14 +112,15 @@ public function __construct($model) {
}

/**
* This method returns the raw SQL command.
* This destructor ensures that all references have been destroyed.
*
* @access public
* @override
* @return string the raw SQL command
*/
public function __toString() {
return $this->builder->command()->__toString();
public function __destruct() {
parent::__destruct();
unset($this->builder);
unset($this->data_source);
unset($this->extension);
}

/**
Expand Down Expand Up @@ -183,17 +197,16 @@ public function set($column, $value) {
return $this;
}


/**
* This method returns the SQL command.
* This method returns the raw SQL command.
*
* @access public
* @override
* @param boolean $terminated whether to add a semi-colon to the end
* of the statement
* @return \Leap\Core\DB\SQL\Command the SQL command
* @return string the raw SQL command
*/
public function command($terminated = TRUE) {
return $this->builder->command($terminated);
public function __toString() {
return $this->builder->command()->__toString();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Plugin/DB/DB2/Connection/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Plugin\DB\DB2\Connection
* @version 2014-07-04
* @version 2015-08-31
*
* @see http://php.net/manual/en/ref.ibm-db2.php
*/
Expand All @@ -43,6 +43,7 @@ public function __destruct() {
if (is_resource($this->resource)) {
@db2_close($this->resource);
}
parent::__destruct();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Plugin/DB/Drizzle/Connection/Improved.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Plugin\DB\Drizzle\Connection
* @version 2014-07-04
* @version 2015-08-31
*
* @see http://www.php.net/manual/en/book.mysqli.php
*/
Expand All @@ -41,6 +41,7 @@ public function __destruct() {
if ($this->resource !== NULL) {
@mysqli_close($this->resource);
}
parent::__destruct();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Leap/Plugin/DB/Drizzle/Connection/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @access public
* @class
* @package Leap\Plugin\DB\Drizzle\Connection
* @version 2014-07-04
* @version 2015-08-31
*
* @see http://www.php.net/manual/en/book.mysql.php
*/
Expand All @@ -41,6 +41,7 @@ public function __destruct() {
if (is_resource($this->resource)) {
@mysql_close($this->resource);
}
parent::__destruct();
}

/**
Expand Down
Loading

0 comments on commit 0441205

Please sign in to comment.