Ticket Details

Model::find with specified fields error

BUG Ticket (closed)

###What happened:
{{{
static::all(); 
}}}
this one is ok, but if i'll add 'fields' argument like:

{{{
static::all(array('fields' => array('username'));
}}}
the result will be:
{{{
array
  0 => string 'Rafał' (length=6)
}}}
"Rafał" is the username of my first record in table.

####Next example:
{{{
Permission::all(array('conditions' => array('user_id' => $record->id)));
}}}
This one is ok but again, if i'll add:
{{{
Permission::all(array('conditions' => array('user_id' => $record->id), 'fields' => array('role')));
}}}
The result is:
{{{
array
  0 => string '6' (length=1)
}}}
Where '6' is value of role column for my first record in table.
on 09.05.10 reported by: rafalfilipek owned by: Howard

Updates

on 10.20.10 by jamalsa
I have similar problems. When I specify fields, it return empty data.
{{{
$members = Member::find('all', array(
	'fields' => array(
		'id', 'nama_lengkap', 'alamat', 'kota_kabupaten_id',
		'provinsi_id'
	)
));

var_dump($members->count()); // It display 0

foreach($members as $item) {
	var_dump($item); // display null
}
}}}

But if the fields is removed, it give correct result.
{{{
$members = Member::find('all');

var_dump($members->count()); // It display amount of members

foreach($members as $item) {
	var_dump($item); // display Record object
}
}}}
on 10.20.10 by jamalsa
I forgot to say that I use MySQL.
on 10.21.10 by kertz
This bug is on x-data
(fixed) on 01.13.11 by Howard
  • owner was changed to Howard
  • status was changed to closed
  • resolution was changed to fixed
Restricting fields now works within the the latest database.php here:

http://dev.lithify.me/lithium/source/branches/x-data/libraries/lithium/data/source/Database.php