Permalink
Browse files

Database: added fetchSingle method

  • Loading branch information...
1 parent b4e2ce6 commit 119096d67bd337dd56d495e386ac78af6b459708 @juzna committed Oct 7, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 Nette/Database/Table/Selection.php
@@ -890,4 +890,20 @@ public function fetchIndexed($key = NULL) {
return $this->fetchPairs($key ? : $this->primary);
}
+
+
+ /**
+ * Fetch single value
+ */
+ public function fetchSingle()
+ {
+ $row = reset($this->data);
+ if ($row) {
+ $tmp = $row->toArray();
+ return $tmp[0];
+ } else {
+ return null;
+ }
+ }
+
}

0 comments on commit 119096d

Please sign in to comment.