gabordemooij / redbean

ORM layer that creates models, config and database on the fly
https://www.redbeanphp.com
2.3k stars 279 forks source link

PartialBeans easier to use and more visible #937

Closed delafred closed 4 months ago

delafred commented 8 months ago

I'm currently looking how to optimize my code. Using redbean I didn't notice that by default all fields are updated.

The method R::usePartialBeans(); can help me on that, I also noticed I can apply an array of beans.

I think it could be easier, safer and more visible

  1. to get an option on the method R::store($bean, $option); that can force this parameter and/or
  2. to get a special method using this parameter ex : R::storePartialBean($bean);/ R::storeOnlyModified($bean); / R::storePartial($bean); / R::storeDirty($bean);

I explain

thx for this library that helped me a lot

gabordemooij commented 8 months ago

Thank you for your feature request, I will look into it.

Note that PHP has a share-nothing architecture, so on normal webservers it should not affect other threads. This is only a problem if you have a long running PHP application that manages its own threads. Is that the case?

delafred commented 8 months ago

This is only a problem if you have a long running PHP application that manages its own threads. Is that the case?

No I'm not in this case, I was more thinking to use pthreads and reuse of instance of rb. Note that I'm not an expert in PHP

Thanks to have a look on ths functionnality.

gabordemooij commented 8 months ago

pthreads seems abandoned? https://www.php.net/manual/en/intro.pthreads.php You can maybe use https://www.php.net/manual/en/book.parallel.php. RedBeanPHP and many aspects of PHP itself are not thread safe though.

delafred commented 8 months ago

pthreads seems abandoned? https://www.php.net/manual/en/intro.pthreads.php You can maybe use https://www.php.net/manual/en/book.parallel.php. RedBeanPHP and many aspects of PHP itself are not thread safe though.

Thanks for the information, I'll have a look.