<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Authorization_Model_DbTable_MapProfileTypeLevels extends Engine_Db_Table
{
  protected $_name = 'authorization_mapprofiletypelevels';
  protected $_rowClass = 'Authorization_Model_MapProfileTypeLevel';

  public function getMappedProfileTypeIds($memberLevelId = null) {
    $select = $this->select()->from($this->info('name'), array('profile_type_id','mapprofiletypelevel_id', 'member_level_id'));
    if (!empty($memberLevelId)) {
      $select->where('member_level_id = ?', $memberLevelId);
    }
    return $select->query()->fetchAll();
  }

  public function getMappedLevelId($profileTypeId = null) {
    if (empty($profileTypeId)) {
      return;
    }

    $select = $this->select()->from($this->info('name'), array('member_level_id'));
    $select->where('profile_type_id = ?', $profileTypeId);
    return $select->query()->fetchColumn();
  }

  public function getMappingId($profileTypeId = null) {
    if (empty($profileTypeId)) {
      return;
    }

    $select = $this->select()->from($this->info('name'), array('mapprofiletypelevel_id'));
    $select->where('profile_type_id = ?', $profileTypeId);
    return $select->query()->fetchColumn();
  }
}
