Skip to content

Commit

Permalink
insertToSQL now handle createColumn content if not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Apr 10, 2020
1 parent 62c88b1 commit 8535d8f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Ease/SQL/Orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ public function saveToSQL($data = null, $searchForID = false) {
* @return int|null id of new row in database
*/
public function insertToSQL($data = null) {
if ($this->createColumn && !isset($data[$this->createColumn])) {
$data[$this->createColumn] = date("Y-m-d H:i:s");
}
try {
$this->getFluentPDO()->insertInto($this->getMyTable(), is_null($data) ? $this->getData() : $data)->execute();
return is_null($this->getPdo()->lastInsertId()) ? null : intval($this->getPdo()->lastInsertId());
Expand Down

0 comments on commit 8535d8f

Please sign in to comment.