<?php

/**
 * Subclass for performing query and update operations on the 'katao_supplier_node' table.
 *
 * @package lib.model
 */
class KataoSupplierNodePeer extends BaseKataoSupplierNodePeer {
    /**
     * KataoSupplierNodePeer::createIfNotExists()
     *
     * @param int $katao_supplier
     * @param int $katao_node_id
     * @return
     */
    public static function createIfNotExists($katao_supplier_id, $katao_node_id) {
        $criteria = new Criteria();
        $criteria->add(self::KATAO_SUPPLIER_ID, $katao_supplier_id);
        $criteria->add(self::KATAO_NODE_ID, $katao_node_id);
        if (0 == self::doCount($criteria)) {
            $katao_supplier_node = new KataoSupplierNode();
            $katao_supplier_node->setKataoSupplierId($katao_supplier_id);
            $katao_supplier_node->setKataoNodeId($katao_node_id);
            $katao_supplier_node->save();
            return true;
        }
        return false;
    }
}