Commit 5059dbc9 authored by zYne's avatar zYne

Sqlite Datadict updated, Doctrine_Record::merge fixed

parent 33d8f27e
......@@ -196,19 +196,25 @@ final class Doctrine {
* mode for lazy offset fetching
*/
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
......
......@@ -226,7 +226,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
* @param string $params
* @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->collections = array();
......@@ -275,9 +275,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$array = $this->parseData($stmt);
if($return == Doctrine::RETURN_VHOLDER) {
if($return == Doctrine::FETCH_VHOLDER) {
return $this->hydrateHolders($array);
}
} elseif($return == Doctrine::FETCH_ARRAY)
return $array;
foreach($array as $data) {
/**
......
......@@ -1239,7 +1239,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public function merge(array $values) {
foreach($this->table->getColumnNames() as $value) {
try {
$this->data[$value] = $values[$value];
if(isset($values[$value]))
$this->set($value, $values[$value]);
} catch(Exception $e) { }
}
}
......
......@@ -143,7 +143,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
// reverse names
$names = array_reverse($names);
// create database table
if(method_exists($record,"setTableDefinition")) {
$record->setTableDefinition();
......
......@@ -11,6 +11,14 @@ class Doctrine_Validator_Email {
if(empty($value))
return true;
return self::validateEmail($value);
}
/**
* validateEmail
*
* @param string $value
*/
public static function validateEmail($value) {
$parts = explode("@", $value);
if(count($parts) != 2)
......
......@@ -898,7 +898,7 @@ class ADODB_DataDict {
}
// 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 = '';
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
......
......@@ -50,7 +50,8 @@ class ADODB2_sqlite extends ADODB_DataDict {
}
}
// 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 = '';
if ($funsigned) $suffix .= ' UNSIGNED';
......@@ -97,14 +98,14 @@ class ADODB2_sqlite extends ADODB_DataDict {
return $sql;
}
function AlterColumnSQL($tabname, $flds)
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
if ($this->debug) $this->outp("AlterColumnSQL not supported");
return array();
}
function DropColumnSQL($tabname, $flds)
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
if ($this->debug) $this->outp("DropColumnSQL not supported");
return array();
......
......@@ -84,11 +84,13 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($stack['mystring'], Doctrine_Validator::ERR_NOTNULL);
$this->assertEqual($stack['myemail2'], Doctrine_Validator::ERR_NOTBLANK);
$test->mystring = 'str';
$test->save();
}
public function testEmailValidation() {
}
public function testValidate() {
$user = $this->session->getTable("User")->find(4);
......
......@@ -19,7 +19,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
public function testSimpleQuery() {
$q = new Doctrine_Query($this->session);
$q->from("User");
$users = $q->execute(array(), Doctrine::RETURN_VHOLDER);
$users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
$this->assertEqual($users->count(), 8);
......@@ -27,7 +27,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
public function testQueryWithOneToManyRelation() {
$q = new Doctrine_Query($this->session);
$q->from("User.Phonenumber");
$users = $q->execute(array(), Doctrine::RETURN_VHOLDER);
$users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
$this->assertEqual($users->count(), 8);
$this->assertTrue($users[0] 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