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

/**
 * Class TB_Shared_Ent_TeamData_ProfileTimestamp
 *
 * @property integer $id
 * @property integer $profile_id
 * @property integer $registered
 * @property integer $last_online
 * @property integer $last_news_update
 */
class TB_Shared_Ent_TeamData_ProfileTimestamp extends Francis_Db_Row {

    /**
     * Return entity corresponding to given profile id
     *
     * @param integer $profileId
     * @return NULL|TB_Shared_Ent_TeamData_ProfileTimestamp
     */
    public static function getByProfileId( $profileId ) {
        $sql = 'SELECT * FROM ' . self::getTable() . ' WHERE profile_id = :profile_id LIMIT 1';
        return self::findOne( $sql, array( ':profile_id' => $profileId) );
    }

    /**
     * Delete entry for given profile id
     *
     * @param $profileId
     * @return bool
     */
    public static function deleteAllForProfileId( $profileId ) {
        $sql = 'DELETE FROM ' . self::getTable() . ' WHERE profile_id = :profile_id LIMIT 1';
        return self::execute( $sql, array( ':profile_id' => $profileId ) );
    }

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

    /**
     * Return db handler
     *
     * @return Francis_Db_MySql|null
     */
    public static function getDbh() {
        return TB_Shared_Db_TeamData::get();
    }
}