Prechádzať zdrojové kódy

+ PDO::fetchFirstAsObject

Piotr Labudda 6 rokov pred
rodič
commit
c84a644a12
1 zmenil súbory, kde vykonal 5 pridanie a 0 odobranie
  1. 5 0
      SE/se-lib/Core/Pdo.php

+ 5 - 0
SE/se-lib/Core/Pdo.php

@@ -471,6 +471,11 @@ EOF_STRUCT_MYSQL;
 		return $sth->fetch();
 	}
 
+	public function fetchFirstAsObject($sql, $values = []) { // fetch only first row as object or null - used in old functions
+		$item = $this->fetchFirst($sql, $values);
+		return ($item) ? (object)$item : null;
+	}
+
 	public function fetchFirstNoLog($sql, $values = []) { // fetch only first row - used in User::getID() required in DBG
 		$sth = $this->prepare($sql);
 		if (!empty($values)) {