Skip to content

Commit

Permalink
Allow passing options in to insert, update, and delete queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Peterson authored and Eric Peterson committed Jan 17, 2017
1 parent 8258998 commit c45fdcd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions models/Query/Builder.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ component displayname="Builder" accessors="true" {

// insert

public any function insert( required any values, boolean toSql = false ) {
public any function insert( required any values, struct options = {}, boolean toSql = false ) {
if ( values.isEmpty() ) {
return;
}
Expand Down Expand Up @@ -785,10 +785,10 @@ component displayname="Builder" accessors="true" {
return sql;
}

return run( sql );
return run( sql, options );
}

public any function update( required any values, boolean toSql = false ) {
public any function update( required any values, struct options = {}, boolean toSql = false ) {
var updateArray = values.keyArray();
updateArray.sort( "textnocase" );

Expand All @@ -802,18 +802,18 @@ component displayname="Builder" accessors="true" {
return sql;
}

return run( sql );
return run( sql, options );
}

public function updateOrInsert( required any values, boolean toSql = false ) {
public function updateOrInsert( required any values, struct options = {}, boolean toSql = false ) {
if ( exists() ) {
return this.limit( 1 ).update( argumentCollection = arguments );
}

return this.insert( argumentCollection = arguments );
}

public any function delete( any id, boolean toSql = false ) {
public any function delete( any id, struct options = {}, boolean toSql = false ) {
if ( ! isNull( arguments.id ) ) {
where( "id", "=", arguments.id );
}
Expand All @@ -824,7 +824,7 @@ component displayname="Builder" accessors="true" {
return sql;
}

return run( sql );
return run( sql, options );
}

public Builder function newQuery() {
Expand Down

0 comments on commit c45fdcd

Please sign in to comment.