Skip to content

Commit

Permalink
Allow adding columns with default values when using objectExists if t…
Browse files Browse the repository at this point in the history
…hey are added in param.

git-svn-id: http://voip.null.ro/svn/ansql/trunk@161 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9
  • Loading branch information
monica committed Apr 9, 2015
1 parent f42ca90 commit 0c874db
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -1740,11 +1740,15 @@ public static function rowExists($param, $value, $class, $id, $value_id = NULL,
}

/**
* Verify if an object has an entry in the database. Before this method is called one must set the values of the fields that will build the WHERE clause. Variables that have a default value will be ignored
* Verify if an object has an entry in the database. Before this method is called one must set
* the values of the fields that will build the WHERE clause. Variables that have a default value
* will be ignored unless added in $columns_with_default
* @param $id_name Name of the id of this object
* @param $columns_with_default Array. List of the columns with default values that should be added
* when building condition
* @return id or the object that matches the conditions, false otherwise
*/
public function objectExists($id_name = NULL)
public function objectExists($id_name = NULL, $columns_with_default=array())
{
Debug::func_start(__METHOD__,func_get_args(),"framework");

Expand Down Expand Up @@ -1774,7 +1778,7 @@ public function objectExists($id_name = NULL)
// ignoring fields that have a default value and the numeric id of the object
if ($this->{$var_name} != '' && $var_name != $id_name)
{
if($clone->{$var_name} != '')
if($clone->{$var_name} != '' && !in_array($var_name, $columns_with_default))
continue;
$conditions[$var_name] = $this->{$var_name};
}
Expand Down

0 comments on commit 0c874db

Please sign in to comment.