i am using Fat-Free Framework to do rapid prototyping of my application. Now, whenever I try to load some data from database, i can use the load()
function within the SQL\Mapper
but it returned all of the column.
I found SELECT()
function but it does not returning any data.
$this->load(['myId=?',$id])
will return the data along with the other columns
$this->select('name',['myId=?',$id])
should return the data from name
column but i got nothing.
$this->db->exec('SELECT name FROM persons WHERE myId=?',$id)
will return the the data from name
column.
what is the proper way of using SELECT()
from Fat-Free framework? my goal is to only retrieve single data from name
column only.
The right way to do it is like this:
$table = new DB\SQL\Mapper($db, 'persons');
// assign to $results
$results = $table->load(array('myId=?', $id));
foreach($results => $row){
echo $row->name;
}
As described here: https://fatfreeframework.com/3.6/databases#SeekandYouShallFind