summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TDbMetaData.php')
-rw-r--r--framework/Data/ActiveRecord/Vendor/TDbMetaData.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
index 3a959ba4..a3a13120 100644
--- a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
+++ b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
@@ -212,15 +212,26 @@ abstract class TDbMetaData extends TComponent
/**
* Gets the columns that can be inserted into the database.
+ * Missing properties are assumed to be null.
* @param TActiveRecord record object to be inserted.
* @return array name value pairs of fields to be added.
+ * @throws TActiveRecordException if property is null and table column is
+ * defined as not null unless primary key column.
*/
protected function getInsertableColumns($record)
{
$columns = array();
foreach($this->getColumns() as $name=>$column)
{
- $value = $record->{$name};
+ try
+ {
+ $value = $record->{$name};
+ }
+ catch (TInvalidOperationException $e) //ignore missing properties
+ {
+ $value = null;
+ }
+
if($column->getNotNull() && $value===null && !$column->getIsPrimaryKey())
{
throw new TActiveRecordException(