1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

Sqlite Datadict updated, Doctrine_Record::merge fixed

This commit is contained in:
zYne 2006-08-20 18:52:07 +00:00
parent 33d8f27e8e
commit 5059dbc90d
9 changed files with 37 additions and 19 deletions

View file

@ -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 RETURN_VHOLDER = 1; const FETCH_VHOLDER = 1;
/** /**
* RETURN RECORD * FETCH RECORD
*/ */
const RETURN_RECORD = 2; const FETCH_RECORD = 2;
/**
* FETCH ARRAY
*/
const FETCH_ARRAY = 3;
/** /**
* LOCKMODE CONSTANTS * LOCKMODE CONSTANTS

View file

@ -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 {
$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) {
/** /**

View file

@ -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) { }
} }
} }

View file

@ -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();
@ -734,7 +733,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$users = $q->query("FROM ".$this->name." WHERE ".$dql, $params); $users = $q->query("FROM ".$this->name." WHERE ".$dql, $params);
return $users; return $users;
} }
public function findByDql($dql, array $params = array()) { public function findByDql($dql, array $params = array()) {
return $this->findBySql($dql, $params); return $this->findBySql($dql, $params);
} }

View file

@ -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)
@ -27,7 +35,7 @@ class Doctrine_Validator_Email {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $parts[$i])) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $parts[$i])) {
return false; return false;
} }
} }
if (!ereg("^\[?[0-9\.]+\]?$", $parts[1])) { // Check if domain is IP. If not, it should be valid domain name if (!ereg("^\[?[0-9\.]+\]?$", $parts[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $parts[1]); $domain_array = explode(".", $parts[1]);
if (count($domain_array) < 2) { if (count($domain_array) < 2) {

View file

@ -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";

View file

@ -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 {
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();

View file

@ -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);

View file

@ -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 {
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);