Skip to content

Commit

Permalink
Merge pull request #16 from coco543/master
Browse files Browse the repository at this point in the history
实现insert之后返回主键AI的ID
  • Loading branch information
walkor committed Jan 30, 2015
2 parents 5ebfcbb + c212c76 commit 67c0f6b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion applications/Demo/Lib/DbConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1672,9 +1672,14 @@ public function query($query = '',$params = null, $fetchmode = \PDO::FETCH_ASSOC
if ($statement === 'select' || $statement === 'show') {
return $this->sQuery->fetchAll($fetchmode);
}
elseif ( $statement === 'insert' || $statement === 'update' || $statement === 'delete' ) {
elseif ( $statement === 'update' || $statement === 'delete' ) {
return $this->sQuery->rowCount();
}
elseif( $statement === 'insert' ){
if( $this->sQuery->rowCount() > 0 ){
return $this->lastInsertId();
}
}
else {
return NULL;
}
Expand Down

0 comments on commit 67c0f6b

Please sign in to comment.