Note that there are some explanatory texts on larger screens.

plurals
  1. PORedBean PHP: Is there a way to protect a database column from being changed? (ex: insertion_date )
    primarykey
    data
    text
    <p>Already used as many ORMs as you can imagine. At moment I'm in a love / hate crush with RedBean PHP. Here we go... after a few hours studying it I got a doubt about whats the better way to solve this very basic problem (best way means, in this case, the way that better fits to the RedBean's ease of use philosophy):</p> <p>It's very common to limit access to some properties of our classes so we can prevent certain kinds of wrong data manipulation. This is usually accomplished with good use of getters and setters. But as far as already know about RedBean, there are no formal setters in the native classes, only some public properties that can be changed and persisted in the database.</p> <p>What I would like to do is to protect some properties from being changed manually, so I can avoid other programmer to make any kind of weirdness like:</p> <pre><code>$beam-&gt;insertion_date = 'yesterday'; R::store($beam); </code></pre> <p>That field should never be changed after the row insertion, obviously, but we can't just trust no one will do that. Is there a way to achieve something like turning the insertion_date a protected property or making it inaccessible in some way?</p> <p>I have a feeling that the best way to do that is using <code>$beam-&gt;setMetadata()</code> and declare that a given property shouldn't be changed, but I don't know how to achieve this in RedBean and still couldn't find enough information in the official manual. Any help is appreciated.</p> <p>Thanks for reading.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload