<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/

/**
 * Class AHDB_Db_Row
 *
 * @property int $id
 * @property string $credential
 * @property string $password
 * @property string $created
 * @property int $last_update
 */

class AHDMN_Ent_Account extends AHDB_Db_Row
{
    /**
     * @param string $token
     * @return NULL|AHDMN_Ent_Session
     */
    public static function getByCredentials( $credential, $password )
    {
        $sql  = "SELECT * FROM " . self::getTable() . " WHERE credential = :credential ";
        $sql .= "AND pass = :pass LIMIT 1";

        return self::findOne( $sql, array( ':credential' => $credential, ':pass' => md5( $password ) ) );
    }

    /**
     * Return table name
     *
     * @return null|string
     */
    public static function getTable()
    {
        return 'account';
    }

    /**
     * Return db handler
     *
     * @return AHDB_Db_PDO
     */
    public static function getDbh()
    {
        return AHDMN_Db_Admin::get();
    }
}