Sfoglia il codice sorgente

+ PDO::fetchFirstAsObject

Piotr Labudda 6 anni fa
parent
commit
c84a644a12
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  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)) {