Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
1  .gitignore
@@ -5,6 +5,7 @@
.DS_Store
.tmp_*
nbproject
+.idea
/cli/settings/*.xml
/includes/configuration.inc.php
/includes/QApplication.class.php
View
1  includes/qcodo/_core/QApplication.class.php-dist
@@ -14,6 +14,7 @@
* This is called by the PHP5 Autoloader. This method overrides the
* one in ApplicationBase.
*
+ * @param $strClassName
* @return void
*/
public static function Autoload($strClassName) {
View
43 includes/qcodo/_core/codegen/templates/db_orm/class_gen/object_save.tpl
@@ -75,25 +75,30 @@
<% } %>
<% } %>
- // Perform the UPDATE query
- $objDatabase->NonQuery('
- UPDATE
- <%= $strEscapeIdentifierBegin %><%= $objTable->Name %><%= $strEscapeIdentifierEnd %>
- SET
-<% foreach ($objTable->ColumnArray as $objColumn) { %>
- <% if ((!$objColumn->Identity) && (!$objColumn->Timestamp)) { %>
- <%= $strEscapeIdentifierBegin %><%= $objColumn->Name %><%= $strEscapeIdentifierEnd %> = ' . $objDatabase->SqlVariable($this-><%= $objColumn->VariableName %>) . ',
- <% } %>
-<% } %><%--%>
- WHERE
-<% foreach ($objTable->PrimaryKeyColumnArray as $objColumn) { %>
- <% if ($objColumn->Identity) { %>
- <%= $strEscapeIdentifierBegin %><%= $objColumn->Name %><%= $strEscapeIdentifierEnd %> = ' . $objDatabase->SqlVariable($this-><%= $objColumn->VariableName %>) . ' AND
- <% } %><% if (!$objColumn->Identity) { %>
- <%= $strEscapeIdentifierBegin %><%= $objColumn->Name %><%= $strEscapeIdentifierEnd %> = ' . $objDatabase->SqlVariable($this->__<%= $objColumn->VariableName %>) . ' AND
- <% } %>
-<% } %><%-----%>
- ');
+ if ($this->__blnDirtyColumnArray){
+ // Perform the UPDATE query
+ $strSetStatement = '';
+ foreach ($this->__blnDirtyColumnArray as $strDirtyColumn => $strDirtyColumnVariableName){
+ $strSetStatement .= '<%= $strEscapeIdentifierBegin %>'. $strDirtyColumn .'<%= $strEscapeIdentifierEnd %> = '. $objDatabase->SqlVariable($this->{$strDirtyColumnVariableName}) .',';
+ }
+ $strSetStatement = substr($strSetStatement, 0, -1);
+ $objDatabase->NonQuery('
+ UPDATE
+ <%= $strEscapeIdentifierBegin %><%= $objTable->Name %><%= $strEscapeIdentifierEnd %>
+ SET
+ '.$strSetStatement.'
+ WHERE
+ <% foreach ($objTable->PrimaryKeyColumnArray as $objColumn) { %>
+ <% if ($objColumn->Identity) { %>
+ <%= $strEscapeIdentifierBegin %><%= $objColumn->Name %><%= $strEscapeIdentifierEnd %> = ' . $objDatabase->SqlVariable($this-><%= $objColumn->VariableName %>) . ' AND
+ <% } %><% if (!$objColumn->Identity) { %>
+ <%= $strEscapeIdentifierBegin %><%= $objColumn->Name %><%= $strEscapeIdentifierEnd %> = ' . $objDatabase->SqlVariable($this->__<%= $objColumn->VariableName %>) . ' AND
+ <% } %>
+ <% } %><%-----%>
+ ');
+ //erase dirty columns
+ $this->__blnDirtyColumnArray = array();
+ }
// Journaling
if ($objDatabase->JournalingDatabase) $this->Journal('UPDATE');
View
8 includes/qcodo/_core/codegen/templates/db_orm/class_gen/property_set.tpl
@@ -21,7 +21,13 @@
<% if (($objColumn->Reference) && (!$objColumn->Reference->IsType)) { %>
$this-><%= $objColumn->Reference->VariableName %> = null;
<% } %>
- return ($this-><%= $objColumn->VariableName %> = QType::Cast($mixValue, <%= $objColumn->VariableTypeAsConstant %>));
+ $mixValue = QType::Cast($mixValue, <%= $objColumn->VariableTypeAsConstant %>);
+ <% if ((!$objColumn->Identity) && (!$objColumn->Timestamp)) { %>
+ if ($mixValue !== $this-><%= $objColumn->VariableName %>){
+ $this->__blnDirtyColumnArray['<%= $objColumn->Name %>'] = '<%= $objColumn->VariableName %>';
+ }
+ <% } %>
+ return $this-><%= $objColumn->VariableName %> = $mixValue;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
View
7 includes/qcodo/_core/codegen/templates/db_orm/class_gen/protected_member_variables.tpl
@@ -81,3 +81,10 @@
* @var bool __blnRestored;
*/
protected $__blnRestored;
+
+ /**
+ * Protected internal member array that specifies whether or not this column was modified.
+ * Used by Save() to determine the columns involved in the UPDATE call.
+ * @var array $__blnDirtyColumnArray;
+ */
+ protected $__blnDirtyColumnArray = array();

No commit comments for this range

Something went wrong with that request. Please try again.