-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
authored and
unknown
committed
Sep 21, 2009
0 parents
commit 3b87ecc
Showing
75 changed files
with
7,312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.buildpath | ||
.project | ||
.settings | ||
.ssh | ||
.bash_history | ||
nbproject | ||
autotestforphp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
To install, copy the OUTLET/classes/outlet folder to a place in your php include path. | ||
|
||
Go to http://outlet.knowledgehead.com for the documentation. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Copyright (c) 2007, Alvaro Carrasco | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* Neither the name of Outlet nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-------------------------------------------------------------------------------- | ||
DATE: 17/09/2009 | ||
|
||
- IN MEMORY SQLITE | ||
******************************* Outlet ***************************************** | ||
Time(s) | ||
Initializing 0.0178699 | ||
selectRecords x 10 1.2292109 | ||
bulkInsertRecords x 1000 0.7088680 | ||
insertRecords x 1000 0.6118929 | ||
|
||
******************************** PDO ******************************************* | ||
Time(s) | ||
selectRecords x 10 0.0003042 | ||
insertRecords x 1000 0.0241060 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
==== Release 0.5 ==== | ||
- Fixed a bug with Outlet->delete (another one) | ||
|
||
==== Release 0.4 ==== | ||
- Fixed a bug with one-to-many relationships | ||
|
||
==== Release 0.3 ==== | ||
- Fixed a bug with Outlet->delete | ||
|
||
==== Release 0.2 ==== | ||
- Better error handling | ||
- More config options: plural names, default values, default expressions, etc | ||
- Refactored the config system | ||
- Fixed a few bugs | ||
|
||
==== Release 0.1 ==== | ||
- Support for SQLite and MySQL | ||
- One-to-many and Many-to-one relationships | ||
- Single-field primary keys | ||
|
||
Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
phpunit --configuration "/path/to/tests/phpunit.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
- Fluent interface API -> The repository need to support other parameters / | ||
methods like orderBy, limit, groupBy... and eager fetching | ||
|
||
- Abstract repository and create classes for MySQL, Postgres and SQLServer | ||
|
||
- DB transaction for UoW | ||
|
||
- Backwards compatibility (?) -> modifying Outlet::getInstance() to return a | ||
session that automatically flushes after executing an operation might do the job | ||
|
||
- UoW#attach and UoW#getOriginalValues need to check PHP version and use another | ||
approach for object hashing, spl_object_hash does not work for PHP < 5.2 | ||
|
||
- Hydrator and ProxyGenerator needs to handle associations | ||
|
||
- "Cascade" changes to identity map and entitiy original values cache (UoW) | ||
This includes propagating PK changes | ||
|
||
- Remove duplication from integration tests, the Bug entity config is coded in | ||
more than one place | ||
|
||
- Make composite primary keys work in any order on identity map. | ||
Currently it only works if the values are on the same order as config | ||
EX: | ||
// ... class mapping | ||
'Entity' => | ||
'props' => | ||
'pk1' => array('pk', 'int', array('pk' => true)), | ||
'pk2' => array('pk', 'int', array('pk' => true)) | ||
// .... | ||
|
||
$obj = new Entity(1, 'other pk'); | ||
IndentityMap#register($obj); | ||
IndentityMap#get(array('other pk', 1)) // returns null | ||
// solution? | ||
IndentityMap#get(array('pk2' => 'other pk', 'pk1' => 1)) | ||
|
||
- OutletProxyAutoloader | ||
|
||
- Tests needed for: | ||
* Session#setAutoFlush | ||
* Cleaning UoW orders after commiting | ||
* AutoDetect parameter of Session#flush |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
class Collection extends ArrayObject { | ||
public function add ($obj) { | ||
return $this->append($obj); | ||
} | ||
public function remove ($obj) {} | ||
|
||
public function removeAll () { | ||
$this->exchangeArray(array()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class teste { | ||
function bla() { | ||
$x = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
class NestedSetBrowser { | ||
protected $cls; | ||
protected $left; | ||
protected $right; | ||
protected $qualifiers; | ||
|
||
public function __construct ($cls, $qualifiers = array(), $left='Left', $right='Right') { | ||
$this->cls = $cls; | ||
$this->qualifiers = $qualifiers; | ||
$this->left = $left; | ||
$this->right = $right; | ||
} | ||
|
||
public function appendChild ($parent, $node) { | ||
// begin transaction | ||
$outlet = Outlet::getInstance(); | ||
$con = $outlet->getConnection(); | ||
$con->beginTransaction(); | ||
|
||
$c = '{'.$this->cls.'}'; | ||
$l = '{'.$this->cls.'.'.$this->left.'}'; | ||
$r = '{'.$this->cls.'.'.$this->right.'}'; | ||
|
||
// qualifiers | ||
$w = ''; | ||
foreach ($this->qualifiers as $field) { | ||
$w .= "{$field} = " . $outlet->quote($node->$field) . " AND "; | ||
} | ||
|
||
// make space | ||
$stmt = $outlet->prepare(" | ||
UPDATE $c | ||
SET $l = $l+2 | ||
WHERE $w $l > ? | ||
"); | ||
|
||
$stmt->execute(array( | ||
$parent->{$this->right} | ||
)); | ||
|
||
$stmt = $outlet->prepare(" | ||
UPDATE $c | ||
SET $r = $r+2 | ||
WHERE $w $r >= ? | ||
"); | ||
$stmt->execute(array( | ||
$parent->{$this->right} | ||
)); | ||
|
||
// insert node | ||
$parent->{$this->right} += 2; | ||
$node->{$this->left} = $parent->{$this->right}-2; | ||
$node->{$this->right} = $parent->{$this->right}-1; | ||
|
||
$outlet->save($node); | ||
|
||
$con->commit(); | ||
|
||
return $node; | ||
} | ||
|
||
public function getChildren ($obj) { | ||
$outlet = Outlet::getInstance(); | ||
|
||
$cls = $this->cls; | ||
$left = $this->left; | ||
$right = $this->right; | ||
|
||
// qualifiers | ||
$w = ''; | ||
foreach ($this->qualifiers as $field) { | ||
$w .= "{n.$field} = " . $outlet->quote($obj->$field) . " AND "; | ||
} | ||
|
||
$children = $outlet->from("$cls n") | ||
->leftJoin("{"."$cls parent} ON ({parent.$left} < {n.$left} AND {parent.$right} > {n.$right})") | ||
->where( | ||
" | ||
$w | ||
{n.$left} > ? | ||
AND {n.$right} < ? | ||
AND {parent.$left} >= ? | ||
", | ||
array($obj->Left, $obj->Right, $obj->Left) | ||
) | ||
->select("COUNT({parent.$left})") | ||
->groupBy("{n.$left}, {n.$right}") | ||
->having("COUNT({parent.$left}) = 1") | ||
->find(); | ||
|
||
return $children; | ||
} | ||
} |
Oops, something went wrong.