public function relatedCount($bean, $type, $sql = NULL, $bindings = array())
{
if (!$bean instanceof OODBBean) {
throw new RedException('Expected array or OODBBean but got:' . gettype($bean));
}
if (!$bean->id) {
return 0;
}
$beanType = $bean->getMeta('type');
try {
return $this->writer->queryRecordCountRelated($beanType, $type, $bean->id, $sql, $bindings);
} catch (SQLException $exception) {
$this->handleException($exception);
return 0;
}
}