Skip to content

Commit

Permalink
Allow copyTo() to save field values to regular PHP variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bcosca authored and nanawel committed Sep 15, 2018
1 parent 40ddac6 commit 19af2a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions db/cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ abstract function update();
abstract function copyfrom($var,$func=NULL);

/**
* Populate hive array variable with mapper fields
* Populate array variable with mapper fields
* @return NULL
* @param $key string
* @param $var mixed
**/
abstract function copyto($key);
abstract function copyto(&$var);

/**
* Get cursor's equivalent external iterator
Expand Down
9 changes: 5 additions & 4 deletions db/jig/mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,13 @@ function copyfrom($var,$func=NULL) {
}

/**
* Populate hive array variable with mapper fields
* Populate array variable with mapper fields
* @return NULL
* @param $key string
* @param $var mixed
**/
function copyto($key) {
$var=&\Base::instance()->ref($key);
function copyto(&$var) {
if (is_string($var))
$var=&\Base::instance()->ref($key);
foreach ($this->document as $key=>$field)
$var[$key]=$field;
}
Expand Down
9 changes: 5 additions & 4 deletions db/mongo/mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,13 @@ function copyfrom($var,$func=NULL) {
}

/**
* Populate hive array variable with mapper fields
* Populate array variable with mapper fields
* @return NULL
* @param $key string
* @param $var mixed
**/
function copyto($key) {
$var=&\Base::instance()->ref($key);
function copyto($var) {
if (is_string($var))
$var=&\Base::instance()->ref($key);
foreach ($this->document as $key=>$field)
$var[$key]=$field;
}
Expand Down
9 changes: 5 additions & 4 deletions db/sql/mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,13 @@ function copyfrom($var,$func=NULL) {
}

/**
* Populate hive array variable with mapper fields
* Populate array variable with mapper fields
* @return NULL
* @param $key string
* @param $var mixed
**/
function copyto($key) {
$var=&\Base::instance()->ref($key);
function copyto(&$var) {
if (is_string($var))
$var=&\Base::instance()->ref($var);
foreach ($this->fields+$this->adhoc as $key=>$field)
$var[$key]=$field['value'];
}
Expand Down

0 comments on commit 19af2a0

Please sign in to comment.