Working with raw data
Let's start with an example. Suppose you have an e-shop and tens of thousands of products in your product catalogue. And you need to have some service scripts. It doesn't matter if it's an inventory recalculation or a revaluation. The main thing is that in such a case you need to operate with a relatively large amount of data, or a large number of records. It is simply a different situation than managing products in the administration or viewing them by the customer. And in such a situation, it may not be entirely appropriate to work with tens of thousands of object instances, but it may be more appropriate to use raw data in the form of arrays/associated fields. Of course, this may not just be service scripts, but a whole host of other subtasks and troubleshooting. In short, as always, it's about choosing the right tool and resources in the right place - it's a matter of developer flair and skill. Let's demonstrate how to work with raw data in Jet.
Fetching is discussed in a separate chapter and the methods ::dataFetch*( ) are described there. Just for the sake of argument, then, let's note that they are used to retrieve data just as you would with an SQL query, but in doing so the benefits of ORM are preserved - that is, a properly developed application is portable to other relational databases and you can keep one style and approach constant in the application.
Suppose we need to recalculate the stock in our imaginary e-shop and simply adjust one number for the products, namely the number of available units. Would it be reasonable to load the entire product entities for this and then store them all again? Certainly not in this particular case. Here it will be enough to write the resulting number (or the resulting numbers if there are multiple warehouses and distribution points). It can be done and it is absolutely simple:
'stock_qty' => $qty
'id' => $id
The $data parameter is an associated array where the key corresponds to the property name, the value corresponds to the set (stored) value.
The $where parameter is a data setup rule made up of the same principle as queries for loading data.