Skip to content

Commit

Permalink
Added varCopy in Variable class. Call getObject on TemporaryModel if …
Browse files Browse the repository at this point in the history
…table name starts with '_temp_'.

git-svn-id: http://voip.null.ro/svn/ansql/trunk@115 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9
  • Loading branch information
monica committed Sep 19, 2014
1 parent 34f6631 commit 32d0f40
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ function __construct($type, $def_value = NULL, $foreign_key = NULL, $critical =
$this->_required = ($required === true || strtolower($def_value) == "!null") ? true : false;
}

public static function varCopy($var)
{
$new_var = new Variable($var->_type, $var->_value, $var->_key, $var->_critical, $var->_matchkey, $var->_join_type, $var->_required);
return $new_var;
}

/**
* Returns the correctly formated value of a Variable object. Value will be used inside a query. Formating is done
* according to the type of the object
Expand Down Expand Up @@ -551,7 +557,10 @@ public static function createTable($table,$vars)
if ($db_type == "postgresql")
$query.= " WITH OIDS";
elseif ($db_type == "mysql") {
$class = get_class(Model::getObject($table));
if (substr($table,0,6)!="_temp_")
$class = get_class(Model::getObject($table));
else
$class = get_class(TemporaryModel::getObject(substr($table,6)));
$engine = call_user_func(array($class,"getDbEngine"));
if ($engine)
$query.= "ENGINE $engine";
Expand Down Expand Up @@ -2529,7 +2538,7 @@ public static function getVariable($class,$name)
}

/**
* Gets the variables of a certian object(including thoses that were added using the extend function)
* Gets the variables of a certain object(including thoses that were added using the extend function)
* @return Array of objects of type Variable that describe the current extended object
*/
public function extendedVariables()
Expand Down

0 comments on commit 32d0f40

Please sign in to comment.