Open krisives opened 1 month ago
When exporting a bean currently it will export different information based on if the bean has been stored or not.
Firstly, it's understood that the id column of a bean that has not yet been stored will be zero. This issue is not about that.
id
R::setup("sqlite:./test.db"); $author = R::dispense('author'); $author->name = 'Some Guy'; $book = R::dispense('book'); $book->title = 'Every Book Makes Someone Mad'; $book->author = $author; // R::store($book); var_dump($book->export());
The above code (without storing the bean) will output:
array(3) { ["id"]=> int(0) ["title"]=> string(28) "Every Book Makes Someone Mad" ["author"]=> array(2) { ["id"]=> int(0) ["name"]=> string(8) "Some Guy" } }
However, if you uncomment that line and actually store the bean, you will get a different output:
array(3) { ["id"]=> string(1) "1" ["title"]=> string(28) "Every Book Makes Someone Mad" ["author_id"]=> string(1) "1" }
Lastly, if we change the export() invocation to set $onlyMe = true and still export an unstored bean, like this:
export()
$onlyMe = true
R::setup("sqlite:./test.db"); $author = R::dispense('author'); $author->name = 'Some Guy'; $book = R::dispense('book'); $book->title = 'Every Book Makes Someone Mad'; $book->author = $author; // R::store($book); var_dump($book->export(false, false, true));
We still get an export that contains the author bean, despite the $onlyMe argument somewhat indicating this is not expected behavior.
author
$onlyMe
Let me know if I can be of any help!
https://github.com/gabordemooij/redbean/issues/739#issuecomment-516360082
When exporting a bean currently it will export different information based on if the bean has been stored or not.
Firstly, it's understood that the
id
column of a bean that has not yet been stored will be zero. This issue is not about that.The above code (without storing the bean) will output:
However, if you uncomment that line and actually store the bean, you will get a different output:
Lastly, if we change the
export()
invocation to set$onlyMe = true
and still export an unstored bean, like this:We still get an export that contains the
author
bean, despite the$onlyMe
argument somewhat indicating this is not expected behavior.Let me know if I can be of any help!