Skip to content

Commit

Permalink
deprecated get
Browse files Browse the repository at this point in the history
  • Loading branch information
h2lsoft committed May 28, 2020
1 parent 91cb181 commit 18372ae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

```

Expand Down
2 changes: 1 addition & 1 deletion examples/4-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


// multiple ID
$records = $DBM->table('Country')->get([12, 10, 55]);
$records = $DBM->table('Country')->getByID([12, 10, 55]);

echo "<pre>";
print_r($records);
Expand Down
19 changes: 17 additions & 2 deletions src/DBManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down

0 comments on commit 18372ae

Please sign in to comment.