Skip to content

Commit

Permalink
MultiResult::insert_update (closes #22)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Sep 17, 2011
1 parent c9cf6e6 commit 3431a24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions NotORM/MultiResult.php
Expand Up @@ -36,6 +36,11 @@ function insert($data) {
return call_user_func_array(array($this, 'parent::insert'), $args); // works since PHP 5.1.2, array('parent', 'insert') issues E_STRICT in 5.1.2 <= PHP < 5.3.0
}

function insert_update(array $unique, array $insert, array $update = array()) {
$unique[$this->column] = $this->active;
return parent::insert_update($unique, $insert, $update);
}

protected function single() {
$this->where[0] = "$this->column = " . $this->quote($this->active);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/22-insert-update.phpt
Expand Up @@ -7,8 +7,11 @@ include_once dirname(__FILE__) . "/connect.inc.php";
for ($i=0; $i < 2; $i++) {
echo $software->application()->insert_update(array("id" => 5), array("author_id" => 12, "title" => "Texy", "web" => "", "slogan" => "$i")) . "\n";
}
$application = $software->application[5];
echo $application->application_tag()->insert_update(array("tag_id" => 21), array()) . "\n";
$software->application("id", 5)->delete();
?>
--EXPECTF--
1
2
1

0 comments on commit 3431a24

Please sign in to comment.