src/Data/Tools/BizDataObj_SQLHelper.php
public function buildUpdateSQL($dataObj)
    {
        // generate column value pairs. ignore those whose inputValue=fieldValue
        $sqlFlds = $dataObj->bizRecord->getToSaveFields('UPDATE');
        $colval_pairs = null;
        foreach ($sqlFlds as $field) {
            $col = $field->column;

            // ignore empty vallue for Date or Datetime
            if (($field->value == "" && $field->oldValue == "") && ($field->type == "Date" || $field->type == "Datetime"))
                continue;

            if ($field->valueOnUpdate != "") // ignore ValueOnUpdate field first
                continue;

            if ($field->isLobField())  // take care of blob/clob type later
                continue;

            // ignore the column where old value is same as new value; set the column only if new value is diff than the old value
            if ($field->oldValue == $field->value)
                continue;

            $_val = $field->getSqlValue();
            $colval_pairs[$col] = $_val; //($_val===null || $_val === '') ? "''" : $_val;
        }
        if ($colval_pairs == null)
            return false;

        // take care value on update fields only
        foreach ($sqlFlds as $field) {
            $col = $field->column;
            if ($field->valueOnUpdate != "") {
                $_val = $field->getValueOnUpdate();
                $colval_pairs[$col] = $_val; //($_val===null || $_val === '') ? "''" : $_val;
            }
        }

        $db = $dataObj->getDBConnection('WRITE');
        $sql = "";
        foreach ($colval_pairs as $col => $val) {
            //$queryString = QueryStringParam::formatQueryString("`$col`", "=", $val);
            $queryString = "`$col`=" . $db->quote($val);
            if ($sql != "") {
                $sql .= ", $queryString";
            } else {
                $sql .= $queryString;
            }
        }

        $sql = "UPDATE `" . $dataObj->mainTableName . "` SET " . $sql;

        $whereStr = $dataObj->bizRecord->getKeySearchRule(true, true);  // use old value and column name
        $sql .= " WHERE " . $whereStr;

        // append DataPerm in the WHERE clause
        if ($dataObj->dataPermControl == 'Y') {
            $svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE);
            $hasOwnerField = $this->_hasOwnerField($dataObj);
            $dataPermSQLRule = $svcObj->buildSqlRule($dataObj, 'update', $hasOwnerField);
            $sqlSearchRule = $this->_convertSqlExpressionWithoutPrefix($dataObj, $dataPermSQLRule);
            if ($whereStr != '') {
                $sql .= ' AND ' . $sqlSearchRule;
            } else {
                $sql .= $sqlSearchRule;
            }
        }
        return $sql;
    }
public function buildUpdateSQL($dataObj)
    {
        // generate column value pairs. ignore those whose inputValue=fieldValue
        $sqlFlds = $dataObj->bizRecord->getToSaveFields('UPDATE');
        $colval_pairs = null;
        foreach ($sqlFlds as $field) {
            $col = $field->column;

            // ignore empty vallue for Date or Datetime
            if (($field->value == "" && $field->oldValue == "") && ($field->type == "Date" || $field->type == "Datetime"))
                continue;

            if ($field->valueOnUpdate != "") // ignore ValueOnUpdate field first
                continue;

            if ($field->isLobField())  // take care of blob/clob type later
                continue;

            // ignore the column where old value is same as new value; set the column only if new value is diff than the old value
            if ($field->oldValue == $field->value)
                continue;

            $_val = $field->getSqlValue();
            $colval_pairs[$col] = $_val; //($_val===null || $_val === '') ? "''" : $_val;
        }
        if ($colval_pairs == null)
            return false;

        // take care value on update fields only
        foreach ($sqlFlds as $field) {
            $col = $field->column;
            if ($field->valueOnUpdate != "") {
                $_val = $field->getValueOnUpdate();
                $colval_pairs[$col] = $_val; //($_val===null || $_val === '') ? "''" : $_val;
            }
        }

        $db = $dataObj->getDBConnection('WRITE');
        $sql = "";
        foreach ($colval_pairs as $col => $val) {
            //$queryString = QueryStringParam::formatQueryString("`$col`", "=", $val);
            $queryString = "`$col`=" . $db->quote($val);
            if ($sql != "") {
                $sql .= ", $queryString";
            } else {
                $sql .= $queryString;
            }
        }

        $sql = "UPDATE `" . $dataObj->mainTableName . "` SET " . $sql;

        $whereStr = $dataObj->bizRecord->getKeySearchRule(true, true);  // use old value and column name
        $sql .= " WHERE " . $whereStr;

        // append DataPerm in the WHERE clause
        if ($dataObj->dataPermControl == 'Y') {
            $svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE);
            $hasOwnerField = $this->_hasOwnerField($dataObj);
            $dataPermSQLRule = $svcObj->buildSqlRule($dataObj, 'update', $hasOwnerField);
            $sqlSearchRule = $this->_convertSqlExpressionWithoutPrefix($dataObj, $dataPermSQLRule);
            if ($whereStr != '') {
                $sql .= ' AND ' . $sqlSearchRule;
            } else {
                $sql .= $sqlSearchRule;
            }
        }
        return $sql;
    }
Build update sql
UPDATE table SET col1=val1, col2=val2 ...
WHERE idcol1='id1' AND idcol2='id2'

@param BizDataObj $dataObj
@return mixed
@todo consider the record data on main table as well as join table, this function can return a sql array.