<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


/**
 * 会員情報
 *
 * @package     Onedepo.Db.Member
 * @author      netnee
 * @access      public
 */
class Onedepo_Db_Member
{
    /**
     * DBアクセスオブジェクト
     *
     * @var     object
     * @access  private
     */
    var $dbaccess;

    function SelectMemberNm($cd)
    {
        $func_name = "Onedepo_Db_Member#SelectMemberNm";
        $log =& LogFactory::getLog();
        $db = $this->dbaccess->doConnect();
        $db->setFetchMode(DB_FETCHMODE_ASSOC);

        $sql  = "SELECT lastnm,firstnm,lastnmkana,firstnmkana FROM t_member_basic_attr WHERE membercd=? AND delflg=FALSE";
        $data = $db->getRow($sql, array($cd));
        if (DB::isError($data) || $data < 0) {
            $log->debug($data->userinfo, $func_name);
            $this->dbaccess->doClose($db);
            return false;
        }
        if (count($data) <= 0) {
            $sql  = "SELECT lastnm,firstnm,lastnmkana,firstnmkana FROM t_member_basic_attr WHERE membercd=? AND delflg=FALSE";
            $data = $db->getRow($sql, array($cd));
            if (DB::isError($data) || $data < 0) {
                $log->debug($data->userinfo, $func_name);
                $this->dbaccess->doClose($db);
                return false;
            }
        }

        $this->dbaccess->doClose($db);
        return $data;
    }
    
    function SelectMemberDate($cd)
    {
        $func_name = "Onedepo_Db_Member#SelectMemberDate";
        $log =& LogFactory::getLog();
        $db = $this->dbaccess->doConnect();
        $db->setFetchMode(DB_FETCHMODE_ASSOC);

        $sql  = "SELECT * FROM t_member_basic_attr WHERE membercd=? AND delflg=FALSE";
        $data = $db->getRow($sql, array($cd));
        if (DB::isError($data) || $data < 0) {
            $log->debug($data->userinfo, $func_name);
            $this->dbaccess->doClose($db);
            return false;
        }
        if (count($data) <= 0) {
            $sql  = "SELECT * FROM t_member_basic_attr WHERE membercd=? AND delflg=FALSE";
            $data = $db->getRow($sql, array($cd));
            if (DB::isError($data) || $data < 0) {
                $log->debug($data->userinfo, $func_name);
                $this->dbaccess->doClose($db);
                return false;
            }
        }

        $this->dbaccess->doClose($db);
        return $data;
    }

    function getMemberData($cd)
    {
        $func_name = "Onedepo_Db_Member#getMemberData";
        $log =& LogFactory::getLog();
        $db = $this->dbaccess->doConnect();
        $db->setFetchMode(DB_FETCHMODE_ASSOC);

        $sql  = "SELECT * FROM t_member_basic_attr WHERE membercd=? AND delflg=FALSE and memberstate=1";
        $data = $db->getRow($sql, array($cd));
        if (DB::isError($data) || $data < 0) {
            $log->debug($data->userinfo, $func_name);
            $this->dbaccess->doClose($db);
            return false;
        }

        $this->dbaccess->doClose($db);
        return $data;
    }
}
?>
