From 18372ae8dc7e27eded07b0d70270597d4e834bf9 Mon Sep 17 00:00:00 2001 From: h2lsoft Date: Thu, 28 May 2020 07:41:52 +0200 Subject: [PATCH] deprecated get --- README.md | 4 ++-- examples/4-utils.php | 2 +- src/DBManager.php | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2d81b13..9f9827d 100644 --- a/README.md +++ b/README.md @@ -126,10 +126,10 @@ $pager = $DBM->paginate($sql, $params, $current_page, 20); ```php // get a record by ID, you can use multiple ID by array -$record = $DBM->table('Country')->get(10); +$record = $DBM->table('Country')->getByID(10); // multiple ID -$records = $DBM->table('Country')->get([12, 10, 55]); +$records = $DBM->table('Country')->getByID([12, 10, 55]); ``` diff --git a/examples/4-utils.php b/examples/4-utils.php index 2463cf8..5b1c3be 100644 --- a/examples/4-utils.php +++ b/examples/4-utils.php @@ -19,7 +19,7 @@ // multiple ID -$records = $DBM->table('Country')->get([12, 10, 55]); +$records = $DBM->table('Country')->getByID([12, 10, 55]); echo "
";
 print_r($records);
diff --git a/src/DBManager.php b/src/DBManager.php
index e49ace2..44bd5ef 100644
--- a/src/DBManager.php
+++ b/src/DBManager.php
@@ -643,7 +643,7 @@ public function delete($where, $limit=-1, $deleted_by='', $table='')
 	 *
 	 * @return array|bool
 	 */
-	public function get($ID, $fields='*', $fetch_mode=PDO::FETCH_ASSOC, $table='')
+	public function getByID($ID, $fields='*', $fetch_mode=PDO::FETCH_ASSOC, $table='')
 	{
 		if(empty($table))$table = $this->table;
 		
@@ -670,9 +670,24 @@ public function get($ID, $fields='*', $fetch_mode=PDO::FETCH_ASSOC, $table='')
 		}
 		
 		return $records;
-		
 	}
 	
+	/**
+	 * Get a record by ID (if array multiple is returned)
+	 *
+	 * @param int|array $ID
+	 * @param string $fields
+	 * @param string $table
+	 *
+	 * @return array|bool
+	 * @deprecated use getByID
+	 */
+	public function get($ID, $fields='*', $fetch_mode=PDO::FETCH_ASSOC, $table='')
+	{
+		return $this->getByID($ID, $fields, $fetch_mode);
+	}
+	
+	
 	
 	/**
 	 * Add dynamically table soft mode columns (deleted, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by)