Commit 5059dbc9 authored by zYne's avatar zYne

Sqlite Datadict updated, Doctrine_Record::merge fixed

parent 33d8f27e
...@@ -196,19 +196,25 @@ final class Doctrine { ...@@ -196,19 +196,25 @@ final class Doctrine {
* mode for lazy offset fetching * mode for lazy offset fetching
*/ */
const FETCH_LAZY_OFFSET = 4; const FETCH_LAZY_OFFSET = 4;
/** /**
* RETURN CONSTANTS * FETCH CONSTANTS
*/ */
/** /**
* RETURN VALUEHOLDER * FETCH VALUEHOLDER
*/
const FETCH_VHOLDER = 1;
/**
* FETCH RECORD
*/ */
const RETURN_VHOLDER = 1; const FETCH_RECORD = 2;
/** /**
* RETURN RECORD * FETCH ARRAY
*/ */
const RETURN_RECORD = 2; const FETCH_ARRAY = 3;
/** /**
* LOCKMODE CONSTANTS * LOCKMODE CONSTANTS
......
...@@ -226,7 +226,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { ...@@ -226,7 +226,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
* @param string $params * @param string $params
* @return Doctrine_Collection the root collection * @return Doctrine_Collection the root collection
*/ */
public function execute($params = array(), $return = Doctrine::RETURN_RECORD) { public function execute($params = array(), $return = Doctrine::FETCH_RECORD) {
$this->data = array(); $this->data = array();
$this->collections = array(); $this->collections = array();
...@@ -275,9 +275,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { ...@@ -275,9 +275,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$array = $this->parseData($stmt); $array = $this->parseData($stmt);
if($return == Doctrine::RETURN_VHOLDER) { if($return == Doctrine::FETCH_VHOLDER) {
return $this->hydrateHolders($array); return $this->hydrateHolders($array);
} } elseif($return == Doctrine::FETCH_ARRAY)
return $array;
foreach($array as $data) { foreach($array as $data) {
/** /**
......
...@@ -1239,7 +1239,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1239,7 +1239,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public function merge(array $values) { public function merge(array $values) {
foreach($this->table->getColumnNames() as $value) { foreach($this->table->getColumnNames() as $value) {
try { try {
$this->data[$value] = $values[$value]; if(isset($values[$value]))
$this->set($value, $values[$value]);
} catch(Exception $e) { } } catch(Exception $e) { }
} }
} }
......
...@@ -143,7 +143,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -143,7 +143,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
// reverse names // reverse names
$names = array_reverse($names); $names = array_reverse($names);
// create database table // create database table
if(method_exists($record,"setTableDefinition")) { if(method_exists($record,"setTableDefinition")) {
$record->setTableDefinition(); $record->setTableDefinition();
......
...@@ -11,6 +11,14 @@ class Doctrine_Validator_Email { ...@@ -11,6 +11,14 @@ class Doctrine_Validator_Email {
if(empty($value)) if(empty($value))
return true; return true;
return self::validateEmail($value);
}
/**
* validateEmail
*
* @param string $value
*/
public static function validateEmail($value) {
$parts = explode("@", $value); $parts = explode("@", $value);
if(count($parts) != 2) if(count($parts) != 2)
......
...@@ -898,7 +898,7 @@ class ADODB_DataDict { ...@@ -898,7 +898,7 @@ class ADODB_DataDict {
} }
// return string must begin with space // return string must begin with space
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint) function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned = null)
{ {
$suffix = ''; $suffix = '';
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
......
...@@ -50,7 +50,8 @@ class ADODB2_sqlite extends ADODB_DataDict { ...@@ -50,7 +50,8 @@ class ADODB2_sqlite extends ADODB_DataDict {
} }
} }
// return string must begin with space // return string must begin with space
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned = null)
{ {
$suffix = ''; $suffix = '';
if ($funsigned) $suffix .= ' UNSIGNED'; if ($funsigned) $suffix .= ' UNSIGNED';
...@@ -97,14 +98,14 @@ class ADODB2_sqlite extends ADODB_DataDict { ...@@ -97,14 +98,14 @@ class ADODB2_sqlite extends ADODB_DataDict {
return $sql; return $sql;
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) $this->outp("AlterColumnSQL not supported"); if ($this->debug) $this->outp("AlterColumnSQL not supported");
return array(); return array();
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) $this->outp("DropColumnSQL not supported"); if ($this->debug) $this->outp("DropColumnSQL not supported");
return array(); return array();
......
...@@ -84,11 +84,13 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase { ...@@ -84,11 +84,13 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($stack['mystring'], Doctrine_Validator::ERR_NOTNULL); $this->assertEqual($stack['mystring'], Doctrine_Validator::ERR_NOTNULL);
$this->assertEqual($stack['myemail2'], Doctrine_Validator::ERR_NOTBLANK); $this->assertEqual($stack['myemail2'], Doctrine_Validator::ERR_NOTBLANK);
$test->mystring = 'str'; $test->mystring = 'str';
$test->save(); $test->save();
} }
public function testEmailValidation() {
}
public function testValidate() { public function testValidate() {
$user = $this->session->getTable("User")->find(4); $user = $this->session->getTable("User")->find(4);
......
...@@ -19,7 +19,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase { ...@@ -19,7 +19,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
public function testSimpleQuery() { public function testSimpleQuery() {
$q = new Doctrine_Query($this->session); $q = new Doctrine_Query($this->session);
$q->from("User"); $q->from("User");
$users = $q->execute(array(), Doctrine::RETURN_VHOLDER); $users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
$this->assertEqual($users->count(), 8); $this->assertEqual($users->count(), 8);
...@@ -27,7 +27,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase { ...@@ -27,7 +27,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
public function testQueryWithOneToManyRelation() { public function testQueryWithOneToManyRelation() {
$q = new Doctrine_Query($this->session); $q = new Doctrine_Query($this->session);
$q->from("User.Phonenumber"); $q->from("User.Phonenumber");
$users = $q->execute(array(), Doctrine::RETURN_VHOLDER); $users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
$this->assertEqual($users->count(), 8); $this->assertEqual($users->count(), 8);
$this->assertTrue($users[0] instanceof Doctrine_ValueHolder); $this->assertTrue($users[0] instanceof Doctrine_ValueHolder);
$this->assertTrue($users[3] instanceof Doctrine_ValueHolder); $this->assertTrue($users[3] instanceof Doctrine_ValueHolder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment