Skip to content

Commit

Permalink
Merge pull request #13 from votemike/affected_rows
Browse files Browse the repository at this point in the history
Fix #12 Returning affected rows
  • Loading branch information
yadakhov authored Jan 19, 2017
2 parents 5ef1ee7 + 6a78541 commit 4a5f934
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/InsertOnDuplicateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait InsertOnDuplicateKey
* @param array $data is an array of array.
* @param array $updateColumns NULL or [] means update all columns
*
* @return bool
* @return int 0 if row is not changed, 1 if row is inserted, 2 if row is updated
*/
public static function insertOnDuplicateKey(array $data, array $updateColumns = null)
{
Expand All @@ -33,15 +33,15 @@ public static function insertOnDuplicateKey(array $data, array $updateColumns =

$data = static::inLineArray($data);

return self::getModelConnectionName()->statement($sql, $data);
return self::getModelConnectionName()->affectingStatement($sql, $data);
}

/**
* Insert using mysql INSERT IGNORE INTO.
*
* @param array $data
*
* @return bool
* @return int 0 if row is ignored, 1 if row is inserted
*/
public static function insertIgnore(array $data)
{
Expand All @@ -58,15 +58,15 @@ public static function insertIgnore(array $data)

$data = static::inLineArray($data);

return self::getModelConnectionName()->statement($sql, $data);
return self::getModelConnectionName()->affectingStatement($sql, $data);
}

/**
* Insert using mysql REPLACE INTO.
*
* @param array $data
*
* @return bool
* @return int 1 if row is inserted without replacements, greater than 1 if rows were replaced
*/
public static function replace(array $data)
{
Expand All @@ -83,7 +83,7 @@ public static function replace(array $data)

$data = static::inLineArray($data);

return self::getModelConnectionName()->statement($sql, $data);
return self::getModelConnectionName()->affectingStatement($sql, $data);
}

/**
Expand Down

0 comments on commit 4a5f934

Please sign in to comment.