Get record of first (and only) row?
- Pavel Kravčík
- Member | 1196
@GEpic: I guess he starts playing with sandbox. So he has only one user for this purpose.
- NoNoNo
- Member | 3
My aim is to have two different outputs in one template:
- Multiple users: Show list (with link to profile)
e.g.
/users/
- Single user: Show profile e.g.
/users/123
In the second case (single user), this works (but is ugly) to print name of first and only user:
{foreach $users as $user}{/foreach}{$user->name}
This does not work:
{$this->DB->table('users')->fetch()->name}
Or is this approach generally wrong?
- Ondřej Kubíček
- Member | 494
you have to specify which user you want
you probaly want user with id 123
$this->DB->table('users')->where('id', $id)->fetch()->name
or better way
$this->DB->table('users')->get($id)->name