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


/**
 * 都道府県マスタテーブル関連
 *
 * @package     Onedepo.Db.Pref
 * @author      netnee T.Otogawa<tomokazu.otogawa@netnee.jp>
 * @access      public
 */
class Onedepo_Db_Pref
{
    var $dbaccess;


    function selectAll($sort="disppriority")
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Pref#selectAll";

        $db = $this->dbaccess->doConnect();
        $db->setFetchMode(DB_FETCHMODE_ASSOC);

        $params = array($sort);

        $sql  = "SELECT prefcd, prefnm, disppriority ";
        $sql .= "  FROM t_pref ";
        $sql .= " WHERE delflg = FALSE ";
        $sql .= " ORDER BY %s";
        $sql = sprintf($sql, $sort);

        $data = $db->getAll($sql);
        $this->dbaccess->doClose($db);

        return $data;
    }

    function selectKey($code)
    {
        $log =& LogFactory::getLog();
        $func_name = "Onedepo_Db_Pref#selectKey";

        $db = $this->dbaccess->doConnect();
        $db->setFetchMode(DB_FETCHMODE_ASSOC);

        $params = array($code);

        $sql  = "SELECT prefcd, prefnm, disppriority ";
        $sql .= "  FROM t_pref ";
        $sql .= " WHERE delflg = FALSE ";
        $sql .= "   AND prefcd = ?;";

        $data = $db->getRow($sql, $params);
        $this->dbaccess->doClose($db);

        return $data;
    }
}
?>
