Skip to content

Commit 129ccf5

Browse files
committed
Releasing 1.1.1
2 parents 94bb3f1 + d9f18e8 commit 129ccf5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/TgDatabase/DAO.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,15 @@ public function deleteBy($criteria = array()) {
247247
$whereClause = $this->createWhereClause($criteria);
248248
return $this->database->delete($this->tableName, substr($whereClause, 6));
249249
}
250-
250+
251+
/**
252+
* Returns the next auto increment value for this class. (Use with care!)
253+
* @return int - next auto increment value as UID.
254+
*/
255+
public function getNextUid() {
256+
return $this->database->getNextUid($this->tableName);
257+
}
258+
251259
/**
252260
* Get the full SQL query to delete the given uid.
253261
* <p>Override this to implement soft delete functionality.</p>

src/TgDatabase/Database.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ public function updateSingle($table, $fields, $where) {
331331
return $rc;
332332
}
333333

334+
/**
335+
* Returns the next auto increment value for this class. (Use with care!)
336+
* @return int - next auto increment value as UID.
337+
*/
338+
public function getNextUid($tableName) {
339+
$sql = 'SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name='.$this->quote($this->replaceTablePrefix($tableName));
340+
$record = $this->querySingle($sql);
341+
if (is_object($record)) return $record->auto_increment;
342+
return 0;
343+
}
344+
334345
/**
335346
* Replaces the #__ in a table name with the tablePrefix (if configured).
336347
* @param string $s - the table name

0 commit comments

Comments
 (0)