Skip to content

Commit

Permalink
Use all array values
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed May 7, 2010
1 parent 2ff1e97 commit b534612
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions NotORM.php
Expand Up @@ -58,8 +58,8 @@ function __get($table) {
function __call($table, array $where) {
$return = new NotORM_Result($table, $this);
if ($where) {
if (is_array($where[0])) {
return $return->insert($where[0]); // $db->$table($data) is a shortcut for $db->$table()->insert($data)
if (is_array($where[0])) { // $db->$table($data) is a shortcut for $db->$table()->insert($data)
return call_user_func_array(array($return, 'insert'), $where);
}
call_user_func_array(array($return, 'where'), $where);
}
Expand Down
4 changes: 2 additions & 2 deletions NotORM/Result.php
Expand Up @@ -77,7 +77,7 @@ function insert(array $data) {
$this->parameters = array();
foreach ($data as $val) {
if (is_array($val)) { // SQL code - for example "NOW()"
$values[] = $val[0];
$values[] = implode("", $val);
//! } elseif ($val instanceof NotORM_Result) {
} else {
$values[] = "?";
Expand All @@ -102,7 +102,7 @@ function update(array $data) {
$values = array();
foreach ($data as $key => $val) {
// doesn't use binding because $this->parameters can be filled by ? or :name
$values[] = "$key = " . (!isset($val) ? "NULL" : (is_array($val) ? $val[0] : $this->notORM->connection->quote($val)));
$values[] = "$key = " . (!isset($val) ? "NULL" : (is_array($val) ? implode("", $val) : $this->notORM->connection->quote($val)));
}
$return = $this->query("UPDATE $this->table SET " . implode(", ", $values) . $this->whereString());
if (!$return) {
Expand Down

0 comments on commit b534612

Please sign in to comment.