<?php

/**
 * A resource representing a user.
 * @package Todojsc
 */
class Todojsc_Resource_User extends SF_Model_Resource_Db_Table_Abstract
                              implements Todojsc_Resource_User_Interface
{
    /** The name of the table holding users. */
    protected $_name = 'authentication';
    /** The name of the primary key in that table. */
    protected $_primary = 'id';
    /** The class that will hold a single user row. */
    protected $_rowClass = 'Todojsc_Resource_User_Item';

    public function getUserById($id)
    {
        $select = $this->select()->where('id = ?', $id);
        return $this->fetchRow($select);
    }

    public function getUserByName($name)
    {
        $select = $this->select()->where('username = ?', $name);
        return $this->fetchRow($select);
    }
    
    public function getUsers()
    {
        return $this->fetchAll($this->select());
    }

}