Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / RedBeanPHP / OODBBean.php
index f77f4f2b0117e35b0ab72e1323aa820b2a60242a..ac37190617d74793da93b86770636fb1673f2c9f 100755 (executable)
@@ -548,7 +548,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable,Jsonable
        {
                $myID = $this->properties['id'];
 
        {
                $myID = $this->properties['id'];
 
-               $this->import( $otherBean->export() );
+               $this->import( $otherBean->export( FALSE, FALSE, TRUE ) );
 
                $this->id = $myID;
 
 
                $this->id = $myID;
 
@@ -1068,6 +1068,8 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable,Jsonable
                $hasSQL         = ($this->withSql !== '' || $this->via !== NULL);
                $exists         = isset( $this->properties[$property] );
                $fieldLink      = $property . '_id';
                $hasSQL         = ($this->withSql !== '' || $this->via !== NULL);
                $exists         = isset( $this->properties[$property] );
                $fieldLink      = $property . '_id';
+               $isFieldLink    = (($pos = strrpos($property, '_id')) !== FALSE) && array_key_exists( ($fieldName = substr($property, 0, $pos)), $this->properties );
+
 
                if ( ($isOwn || $isShared) &&  (!$exists || $hasSQL || $differentAlias) ) {
 
 
                if ( ($isOwn || $isShared) &&  (!$exists || $hasSQL || $differentAlias) ) {
 
@@ -1104,6 +1106,12 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable,Jsonable
                                throw new RedException( 'Cannot cast to bean.' );
                        }
                }
                                throw new RedException( 'Cannot cast to bean.' );
                        }
                }
+               
+               if ( $isFieldLink ){
+                       unset( $this->properties[ $fieldName ]);
+                       $this->properties[ $property ] = NULL;
+               }
+
 
                if ( $value === FALSE ) {
                        $value = '0';
 
                if ( $value === FALSE ) {
                        $value = '0';