From 04b11e86702b802374d9bcb4d7eac051bd826f16 Mon Sep 17 00:00:00 2001 From: Mainboarder Date: Thu, 10 Apr 2014 21:43:46 +0200 Subject: [PATCH] RedbeanPHP update --- libs/R.class.php | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/libs/R.class.php b/libs/R.class.php index 108b706..862dcbc 100644 --- a/libs/R.class.php +++ b/libs/R.class.php @@ -3323,7 +3323,8 @@ abstract class RedBean_QueryWriter_AQueryWriter { //bracket must be here - other $insertvalues[] = $pair['value']; } - return $this->insertRecord( $table, $insertcolumns, array( $insertvalues ) ); + //Otherwise psql returns string while MySQL/SQLite return numeric causing problems with additions (array_diff) + return (string) $this->insertRecord( $table, $insertcolumns, array( $insertvalues ) ); } if ( $id && !count( $updatevalues ) ) { @@ -5689,17 +5690,11 @@ class RedBean_OODB extends RedBean_Observable */ private function processTrashcan( $bean, $ownTrashcan ) { - $myFieldLink = $bean->getMeta( 'type' ) . '_id'; - if ( is_array( $ownTrashcan ) && count( $ownTrashcan ) > 0 ) { - $first = reset( $ownTrashcan ); - if ( $first instanceof RedBean_OODBBean ) { - $alias = $bean->getMeta( 'sys.alias.' . $first->getMeta( 'type' ) ); - if ( $alias ) { - $myFieldLink = $alias . '_id'; - } - } - } foreach ( $ownTrashcan as $trash ) { + $myFieldLink = $bean->getMeta( 'type' ) . '_id'; + $alias = $bean->getMeta( 'sys.alias.' . $trash->getMeta( 'type' ) ); + if ( $alias ) $myFieldLink = $alias . '_id'; + if ( isset( $this->dep[$trash->getMeta( 'type' )] ) && in_array( $bean->getMeta( 'type' ), $this->dep[$trash->getMeta( 'type' )] ) ) { $this->trash( $trash ); } else { @@ -5776,18 +5771,15 @@ class RedBean_OODB extends RedBean_Observable */ private function processAdditions( $bean, $ownAdditions ) { - $myFieldLink = $bean->getMeta( 'type' ) . '_id'; - if ( $bean && count( $ownAdditions ) > 0 ) { - $first = reset( $ownAdditions ); - if ( $first instanceof RedBean_OODBBean ) { - $alias = $bean->getMeta( 'sys.alias.' . $first->getMeta( 'type' ) ); - if ( $alias ) { - $myFieldLink = $alias . '_id'; - } - } - } + $beanType = $bean->getMeta( 'type' ); + foreach ( $ownAdditions as $addition ) { if ( $addition instanceof RedBean_OODBBean ) { + + $myFieldLink = $beanType . '_id'; + $alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) ); + if ( $alias ) $myFieldLink = $alias . '_id'; + $addition->$myFieldLink = $bean->id; $addition->setMeta( 'cast.' . $myFieldLink, 'id' ); $this->store( $addition );