Permalink
Browse files

re-added relatedOne.

  • Loading branch information...
1 parent 185c371 commit 5459a5d463692089adc4f7846bac9c6fe4666167 = committed Jan 30, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 RedBean/Facade.php
View
16 RedBean/Facade.php
@@ -316,6 +316,22 @@ public static function related( RedBean_OODBBean $bean, $type, $sql=null, $value
return self::$redbean->convertToBeans($type,$rows);
}
+ /**
+ * Returns only single associated bean.
+ *
+ * @param RedBean_OODBBean $bean bean provided
+ * @param string $type type of bean you are searching for
+ * @param string $sql SQL for extra filtering
+ * @param array $values values to be inserted in SQL slots
+ *
+ *
+ * @return RedBean_OODBBean $bean
+ */
+ public static function relatedOne( RedBean_OODBBean $bean, $type, $sql=null, $values=array() ) {
+ $beans = self::related($bean, $type, $sql, $values);
+ if (count($beans)==0) return null;
+ return reset( $beans );
+ }
/**
* Checks whether a pair of beans is related N-M. This function does not

0 comments on commit 5459a5d

Please sign in to comment.