Break structure, select query

Is there a way, within the break, to make SELECT mycolumn1, mycolumn2, and not SELECT * on the model. I only find the function $ this-> model-> select () and do not allow this.

Thank,

+3
source share
1 answer

The Recess structure is intended to return an object model when trying to query a database. So you are stuck in select * because every property of the object must be returned. This can be circumvented if you are accessing the PDO itself. For instance:

$results = Databases::getSource('dataSourceName');
$set = $results->query("SELECT col1, col2 FROM table");

This will give you a resultsSet object with which you can iterate through. However, you cannot use the methods → insert () and → equal () and other edge methods on this object.

+2
source

Source: https://habr.com/ru/post/1790682/


All Articles