<?php
defined('COT_CODE') or die('Wrong URL');

global $db, $db_marketfav;
cot::$db->registerTable('marketfav');

function cot_marketfav($id, $onlycnt = false)
{
	global $db, $db_marketfav, $usr;
	$return = 0;

  if($id > 0 && ($usr['id'] > 0 || $onlycnt))
  {
   $return = $db->query("SELECT COUNT(*) FROM $db_marketfav
			WHERE fav_pid=".$id.(!$onlycnt ? " AND fav_uid=".$usr['id'] : ''))->fetchColumn();
	}
  return $return;
}