Skip to content

Commit

Permalink
[#13002] - Added conditional for setup and lowInsert -> lastinsertid
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed May 15, 2019
1 parent 1aa48ab commit 4838b52
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion phalcon/Mvc/Model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,7 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
exceptionOnFailedSave, phqlLiterals, virtualForeignKeys,
lateStateBinding, castOnHydrate, ignoreUnknownColumns,
updateSnapshotOnSave, disableAssignSetters,
caseInsensitiveColumnMap, prefetchRecords;
caseInsensitiveColumnMap, prefetchRecords, lastInsertId;

/**
* Enables/Disables globally the internal events
Expand Down Expand Up @@ -2845,6 +2845,10 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
if fetch prefetchRecords, options["prefetchRecords"] {
globals_set("orm.resultset_prefetch_records", prefetchRecords);
}

if fetch lastInsertId, options["castLastInsertIdToInt"] {
globals_set("orm.cast_last_insert_id_to_int", lastInsertId);
}
}

/**
Expand Down Expand Up @@ -3619,6 +3623,13 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
*/
let lastInsertedId = connection->lastInsertId(sequenceName);

/**
* If we want auto casting
*/
if unlikely globals_get("orm.cast_last_insert_id_to_int")
let lastInsertedId = intval(lastInsertId, 10);
}

let this->{attributeField} = lastInsertedId;
let snapshot[attributeField] = lastInsertedId;

Expand Down

0 comments on commit 4838b52

Please sign in to comment.