<?php
/*
 * Copyright(C). D-cube,Inc. All Rights Reserved.
 */

/*
 * @file		AccountManager.class.php
 * @brief		accountテーブルの処理を行うクラス
 * @date		2007.01.19
 */

require_once(CLASS_DIR."/adodb/BitcubeDB.class.php");

class AccountManager extends BitcubeDB
{
	function AccountManager()
	{
		$this->BitcubeDB();
	}
	
	function updAccount($record,$account_name)
	{
		$record["account_pass"] = md5($record["account_pass"]);
		return $this->ExecuteUpdate($this->account,$record,"account_name = ".$this->qstr($account_name));
	}
	
	function findAccount($account_name,$account_pass)
	{
		$condition = "is_delete = 0 and account_name = ".$this->qstr($account_name)." and account_pass = ".$this->qstr($account_pass);
		if($this->GetCount($this->account,$condition) > 0)
			return true;
		else
			return false;
	}
	
	// ユーザ名重複チェック
	function findAccountName($account_name,$exception)
	{
		$condition = "account_name = ".$this->qstr($account_name)." and account_name <> ".$this->qstr($exception);
		if($this->GetCount($this->account,$condition) > 0)
			return true;
		else
			return false;
	}
	
	// テーブルをロック
	function Lock()
	{
		$this->doLock($this->account);
	}
}
