Skip to content

Commit

Permalink
Added option to set object model to use when updating table structure.
Browse files Browse the repository at this point in the history
git-svn-id: http://voip.null.ro/svn/ansql/trunk@116 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9
  • Loading branch information
monica committed Sep 29, 2014
1 parent 32d0f40 commit b3d9f48
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function isRequired()
class Database
{
protected static $_connection = true;
protected static $_object_model = "Model";

// this library uses mostly postgresql types
// if type is not in the below list make sure that given type of a variables mathches real type in database
Expand Down Expand Up @@ -309,9 +310,10 @@ public static function query($query, $retrieve_last_id=false)
return $res;
elseif ($query != "ROLLBACK")
{
if(!Model::modified())
$model = self::$_object_model;
if(!call_user_func(array($model,"modified")))
{
Model::updateAll();
call_user_func(array($model,"updateAll"));
$res = self::queryRaw($query, $retrieve_last_id);
if ($res===false || $res===NULL) {
$mess = $query;
Expand All @@ -327,6 +329,11 @@ public static function query($query, $retrieve_last_id=false)
}
}

public static function setObjModel($model)
{
self::$_object_model = $model;
}

/**
* Make sure queries separated by ; won't we run
* @param $query String that will be verified
Expand Down

0 comments on commit b3d9f48

Please sign in to comment.