Skip to content

Commit

Permalink
Merging zdk's in
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Sep 1, 2009
2 parents 98bbd3c + 7ebeeb2 commit d5b7d4f
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 414 deletions.
8 changes: 4 additions & 4 deletions recess/recess/cache/Cache.class.php
Expand Up @@ -237,7 +237,6 @@ function __construct() {
$tries = 0;
while($tries < 2) {
try {
$tries++;
$this->setStatement = $this->pdo->prepare('INSERT OR REPLACE INTO cache (key,value,expire) values (:key,:value,:expire)');
$this->getStatement = $this->pdo->prepare('SELECT value,expire FROM cache WHERE key = :key');
$this->getManyStatement = $this->pdo->prepare('SELECT value,expire,key FROM cache WHERE key LIKE :key');
Expand All @@ -248,10 +247,11 @@ function __construct() {
$this->pdo->exec('CREATE TABLE "cache" ("key" TEXT PRIMARY KEY NOT NULL , "value" TEXT NOT NULL , "expire" INTEGER NOT NULL)');
$this->pdo->exec('CREATE INDEX "expiration" ON "cache" ("expire" ASC)');
} catch(PDOException $e) {
if($tries == 2) {
die('Could not create cache table.');
if($tries == 1) {
die('Could not create cache table');
}
sleep(1);
$tries++;
continue;
}
}
Expand Down Expand Up @@ -336,4 +336,4 @@ function clear() {
$this->reportsTo->clear();
}
}
?>
?>
8 changes: 7 additions & 1 deletion recess/recess/database/pdo/PdoDataSet.class.php
Expand Up @@ -350,5 +350,11 @@ function orderBy($clause) { $copy = clone $this; $copy->sqlBuilder->orderBy($cla
* @return PdoDataSet
*/
function groupBy($clause) { $copy = clone $this; $copy->sqlBuilder->groupBy($clause); return $copy; }

/**
* @see SqlBuilder::in
* @return PdoDataSet
*/
function in($lhs, $rhs) { $copy = clone $this; $copy->sqlBuilder->in($lhs,$rhs); return $copy; }
}
?>
?>
1 change: 1 addition & 0 deletions recess/recess/database/sql/ISqlConditions.class.php
Expand Up @@ -19,6 +19,7 @@ function lessThan($column, $value);
function lessThanOrEqualTo($column, $value);
function like($column, $value);
function notLike($column, $value);
function in($column, $value);

}
?>
18 changes: 18 additions & 0 deletions recess/recess/database/sql/SqlBuilder.class.php
Expand Up @@ -344,6 +344,16 @@ public function isNull($column) { return $this->addCondition($column, nul
*/
public function isNotNull($column) { return $this->addCondition($column, null, Criterion::IS_NOT_NULL); }

/**
* IN to expression for WHERE clause of update, delete, or select statements.
*
* @param string $column
* @param array $value
* @return SqlBuilder
*/
public function in($column, $value) { return $this->addCondition($column, $value, Criterion::IN); }


/**
* Add a condition to the SqlBuilder statement. Additional logic here to prepend
* a table name and also keep track of which columns have already been assigned conditions
Expand Down Expand Up @@ -730,6 +740,8 @@ class Criterion {

const UNDERSCORE = '_';

const IN = ' IN ';

public function __construct($column, $value, $operator, $pdoLabel = null){
$this->column = $column;
$this->value = $value;
Expand All @@ -746,6 +758,12 @@ public function getQueryParameter() {
if(is_numeric($this->value)) {
return $this->value;
}

if(is_array($this->value)) {
$hack_value = '('.join(',', $this->value).')';
return $hack_value;
}

// End workaround

if($this->operator == self::ASSIGNMENT) {
Expand Down
2 changes: 1 addition & 1 deletion recess/recess/framework/Application.class.php
Expand Up @@ -131,4 +131,4 @@ function urlTo($methodName) {
return call_user_func_array(array($controller,'urlTo'),$args);
}
}
?>
?>
2 changes: 1 addition & 1 deletion recess/test/recess/database/PdoDsnSettings.php
@@ -1,5 +1,5 @@
<?php
// DSN, Database Name, Username, Password
$_ENV['dsn.mysql'] = array('mysql:host=localhost;dbname=recess', 'recess', 'recess', 'recess');
$_ENV['dsn.mysql'] = array('mysql:host=localhost;dbname=recess', 'root', 'root', 'root');
$_ENV['dsn.sqlite'] = array('sqlite::memory:','','','');
?>

0 comments on commit d5b7d4f

Please sign in to comment.