Skip to content

Instantly share code, notes, and snippets.

@datibbaw
Created March 12, 2014 07:37
Show Gist options
  • Save datibbaw/57081bf47e2fc2d33f62 to your computer and use it in GitHub Desktop.
Save datibbaw/57081bf47e2fc2d33f62 to your computer and use it in GitHub Desktop.
<?php
if (preg_match('_^\s*SELECT _i', $query)) {
return $stmt->$fetch(PDO::FETCH_ASSOC);
} elseif (preg_match('_^\s*INSERT _i', $query) {
return $this->lastInsertId();
} elseif (preg_match('_^\s*UPDATE _i', $query) || preg_match('_^\s*DELETE _i', $query) {
return $stmt->rowCount();
}
return $stmt->$fetch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment