<?php

class KataoNodePeer extends BaseKataoNodePeer {
    public static function getAll() {
        $criteria = new Criteria();
        return self::doSelectJoinAll($criteria);
    }

    /**
     * KataoNodePeer::getFirst()
     *
     * @return KataoNode
     */
    public static function getFirst() {
        $criteria = new Criteria();
        $criteria->addAscendingOrderByColumn(self::CITY);
        return self::doSelectOne($criteria);
    }

    public static function getAllArray() {
        $return = array();

        $criteria = new Criteria();
        $criteria->addSelectColumn(self::ID);
        $criteria->addSelectColumn(self::CITY);
        $criteria->addAscendingOrderByColumn(self::CITY);

        $rs = self::doSelectRS($criteria);
        while ($rs->next()) {
            $return[$rs->getInt(1)] = $rs->getString(2);
        }

        return $return;
    }

    /**
     * KataoNodePeer::retrieveByCity()
     *
     * @param string $city
     * @return KataoNode
     */
    public static function retrieveByCity($city) {
        $criteria = new Criteria();
        $criteria->add(self::CITY, $city);
        return self::doSelectOne($criteria);
    }

    public static function getBeginDate($katao_node_id) {
        $return = array();

        $criteria = new Criteria();
        $criteria->addSelectColumn(self::BEGIN_AT);
        if ($katao_node_id) {
            $criteria->add(self::ID, $katao_node_id);
        } else {
            $criteria->addAscendingOrderByColumn(self::BEGIN_AT);
        }
        $criteria->setLimit(1);

        $rs = self::doSelectRS($criteria);
        if ($rs->next()) {
            $return = strtotime($rs->getString(1));
        }

        return $return;
    }

    /**
     * KataoNodePeer::getDefaultOne()
     *
     * @return KataoNode
     */
    public static function getDefaultOne() {
        $criteria = new Criteria();
        $criteria->add(self::IS_DEFAULT, true);
        return self::doSelectOne($criteria);
    }
}