Commit cb924af3 authored by romanb's avatar romanb

- Added Doctrine_Record::trySave()

- Modified the length validation to skip validation for integer fields. The length of integer fields represents the number of bytes and is used for table creation (4 = INT, ect.)
parent 37a6a6f5
......@@ -942,6 +942,23 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$conn->commit();
}
/**
* Tries to save the object and all its related components.
* In contrast to Doctrine_Record::save(), this method does not
* throw an exception when validation fails but returns TRUE on
* success or FALSE on failure.
*
* @param Doctrine_Connection $conn optional connection parameter
* @return TRUE if the record was saved sucessfully without errors, FALSE otherwise.
*/
public function trySave(Doctrine_Connection $conn = null) {
try {
$this->save($conn);
return true;
} catch (Doctrine_Validator_Exception $ignored) {
return false;
}
}
/**
* replace
* Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT
......
......@@ -177,12 +177,11 @@ class Doctrine_Validator
}
}
/**
* Enter description here...
*
* Validates the length of a field.
*/
private function validateLength($column, $key, $value)
{
if ($column[0] == "timestamp") {
if ($column[0] == "timestamp" || $column[0] == "integer") {
return true;
} else if ($column[0] == "array" || $column[0] == "object") {
$length = strlen(serialize($value));
......
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