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


/**
 * 新規会員テーブル関連
 *
 * @package     Onedepo.Db.Member.Leave
 * @author      FUCO Tominaga
 * @access      public
 */
class Onedepo_Db_Member_Leave
{
    var $dbaccess;

    function get_cnt($MemberCd)
    {
        $db = $this->dbaccess->doConnect();
        
        $params = array($MemberCd);
        $sql = "select UpdCnt from t_member_basic_attr where MemberCd=?;";
        
        $res = $db->getone($sql, $params);
        if(DB::isError($res) || !$res)
        {
            $this->dbaccess->doClose($db);
            return false;
        }
        else
        {
            $this->dbaccess->doClose($db);
            return $res;
        }
    }

    function delete_member($MemberCd) {
        $ret = true;
        $log =& LogFactory::getLog();

        $params = array(date("Y-m-d H:i:s"),
                         $_SERVER['REMOTE_ADDR'],
                         ($this->get_cnt($MemberCd) + 1),
                         $MemberCd);
        $sql = "update t_member_basic_attr set MemberState=8, DelFlg='true', UpdDate=?, UpdUsrNm='test', UpdPcNm=?, UpdCnt=? where MemberCd=?;";

        $db = $this->dbaccess->doConnect();
        $res = $db->query($sql, $params);
        if (DB::isError($res) || !$res) {
            $db->rollback();
            $ret = false;
            trigger_error($res->userinfo, E_USER_ERROR);
        }
        $log->trace("commit", "Onedepo_Db_Member_Leave#delete");

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