Table update method

@param  KDatabaseRowInterface $row A KDatabaseRow object
@return boolean|integer  Returns the number of rows updated, or FALSE if insert query was not executed.
182291
public function update(KDatabaseRowInterface $row)
    {
        // Create query object.
        $query = $this->getObject('lib:database.query.update')
            ->table($this->getBase());

        // Create commandchain context.
        $context = $this->getContext();
        $context->table     = $this->getBase();
        $context->data      = $row;
        $context->query     = $query;
        $context->affected  = false;

        if ($this->invokeCommand('before.update', $context) !== false)
        {
            foreach ($this->getPrimaryKey() as $key => $column)
            {
                $context->query->where($column->name . ' = :' . $key)
                    ->bind(array($key => $context->data->$key));
            }

            // Filter the data and remove unwanted columns.
            $data = $this->filter($context->data->getProperties(true));

            foreach ($this->mapColumns($data) as $key => $value) {
                $query->values($key . ' = :_' . $key)->bind(array('_' . $key => $value));
            }

            // Execute the update query.
            $context->affected = $this->getAdapter()->update($context->query);

            // Set the status and data before calling the command chain
            if ($context->affected !== false)
            {
                if ($context->affected) {
                    $context->data->setProperties($this->mapColumns($data, true), true)->setStatus(KDatabase::STATUS_UPDATED);
                } else {
                    $context->data->setStatus(KDatabase::STATUS_FAILED);
                }
            }

            $this->invokeCommand('after.update', $context);
        }

        return $context->affected;
    }
589596
public void update(final T row)
	{
		final int index = data.indexOf(row);
		if (index != -1)
		{
			data.set(index, row);
			fireTableDataChanged();
		}
	}
1325111
public function update($table, $data = false)
    {
        if ($data == false) {
            $data = $table;
        } else {
            $this->table($table);
        }

        // Escape SQL 
        foreach ($data as $key => $value) {
            $data[$key] = $this->quote($value);
        }

        $this->queryCompiler->getQuery()->update($data);

        $this->queryCompiler->compile('update');

        return $this->getResult('get');
    }
1056001
private function doUpdateByQueries(array $row): void
    {
        $data = $this->generateFakeData();

        $queryBuilder = $this->dbUtils->getConn()->createQueryBuilder();
        $queryBuilder = $queryBuilder->update($this->entity);
        foreach ($data as $field => $value) {
            $value = empty($row[$field]) ?
                $this->dbUtils->getEmptyValue($this->entityCols[$field]['type']) :
                $value;

            $condition = $this->dbUtils->getCondition($field, $this->entityCols[$field]);
            $queryBuilder = $queryBuilder->set($field, $condition);
            $queryBuilder = $queryBuilder->setParameter(":$field", $value);
        }
        $queryBuilder = $queryBuilder->where("{$this->priKey} = :{$this->priKey}");
        $queryBuilder = $queryBuilder->setParameter(":{$this->priKey}", $row[$this->priKey]);

        $this->returnRes === true ?
            array_push($this->queries, $this->dbUtils->getRawSQL($queryBuilder)) :
            null;

        if ($this->pretend === false) {
            $queryBuilder->execute();
        }
    }
1338386
public function setDbDataFromRow(array $rowData)
    {
        // If there are less row data than properties, use rows as starting point (optimization)
        if (count($rowData) < count(static::$dbProperties)) {
            foreach ($rowData as $dbFieldName => $value) {
                $propertyName = static::getDbPropertyName($dbFieldName);
                if (isset(static::$dbProperties[$propertyName])) {
                    $this->setDbValue($propertyName, $value, false);
                }
            }
        // If there are more row data than properties, use properties as starting point
        } else {
            foreach (array_keys(static::$dbProperties) as $propertyName) {
                $fieldName = static::getDbFieldName($propertyName);
                if (array_key_exists($fieldName, $rowData)) {
                    $this->setDbValue($propertyName, $rowData[$fieldName], false);
                }
            }
        }

        $this->updatePrimaryDbValueFromDbData();
    }
1305498
public function update($query, array $data) {
        $stmt = $this->executeQuery($query, $data);

        return $stmt->rowCount();       
    }
105470
public function execute($rowCount = false)
    {
        $stmt = $this->getStmt();

        if ($rowCount === true) {
            return $stmt->rowCount();
        } else {
            return true;
        }
    }
918675
function RowLock($tables,$where,$col=false)
	{
		if ($this->autoCommit) {
			$this->BeginTrans();
		}
		$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
		return 1;
	}
971496
protected function _update(array $data)
    {
        $data = $this->_setData($data);
        $pmk = $this->getPrimaryKey();
        unset($data[$pmk]);
        $sql = Sql::createSql($this->getAdapter())->update($this->getTableName());
        $event = new Save([
            'action' => Save::UPDATE,
            'data' => $data,
            'abort' => false
        ]);
        $this->getEventManager()->trigger(Save::BEFORE_SAVE, $this, $event);
        if ($event->abort) {
            return false;
        }
        $sql->set($event->data)
            ->where(["{$pmk} = :id" => [':id' => $this->$pmk]])
            ->execute();
        $this->getEventManager()->trigger(Save::AFTER_SAVE, $this, $event);
        return true;
    }
81845
protected function isExistingRow($row, $attribute)
    {
        $rowAttributes = $row;
        unset($rowAttributes[$this->relationalData[$attribute]['junctionColumn']]);

        foreach ($this->relationalData[$attribute]['oldRows'] as $oldRow) {
            $oldModelAttributes = $oldRow;
            unset($oldModelAttributes[$this->relationalData[$attribute]['junctionColumn']]);
            if ($oldModelAttributes == $rowAttributes) {
                return true;
            }
        }

        return false;
    }
839414
public function update($data)
    {

        if (is_array($data)) {
            if ($this->isAssocStr($data)) {

                $query = "UPDATE " . self::$table . ' SET ';

                $this->values = array_values(array_map(function ($c) {
                    return self::sanitize($c);
                }, $data));

                $this->columns = array_keys($data);

                $columnParam = array_map(function ($column) {
                    return self::sanitize($column) . '=?';
                }, $this->columns);

                $query .= $this->columnize($columnParam);

                if (!empty($this->whereby)) {

                    $query = $query . ' WHERE ' . $this->whereby;
                }

                try {
                    $stm = Connect::getConn()->prepare($query);
                } catch (Exception $e) {

                    static::$response["status"] = "error";
                    static::$response["response"] = $e->getMessage();
                    static::$response["code"]=$e->getCode();
                    return self::terminate(static::$response);
                }

                try {

                    $stm->execute($this->values);

                    static::$response["status"] = "success";
                    static::$response["response"] = "success";
                    static::$response["code"] = 200;

                    return static::terminate(static::$response);

                } catch (Exception $e) {
                    static::$response["status"] = "error";
                    static::$response["response"] = $e->getMessage();
                    static::$response["code"]=$e->getCode();
                    return self::terminate(static::$response);
                }
            }

            static::$response["status"] = "error";
            static::$response["response"] = "Associative array expected in update function but sequential array passed";
            static::$response["code"]=6501;
            return self::terminate(static::$response);

        }
        static::$response["status"] = "error";
        static::$response["response"] = "Unrecognized data. Associative array expected in update function";
        static::$response["code"]=6500;
        return self::terminate(static::$response);
    }
1155624
public static function isRowActions($row)
    {
        return (count($row) == count(static::makeEmptyActionRow())) && isset($row[Metrics::INDEX_NB_ACTIONS]);
    }
1115659
public function updateRows(string $table, array $set, array $where): int
    {
        $update = new Update($this->options);
        $sqlParams = $update->buildQuery($table, $set, $where);
        return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
    }
881788
function Set(&$row)
	{
	global $ACTIVE_RECORD_SAFETY;

		$db = $this->DB();

		if (!$row) {
			$this->_saved = false;
			return false;
		}

		$this->_saved = true;

		$table = $this->TableInfo();
		$sizeofFlds = sizeof($table->flds);
		$sizeofRow  = sizeof($row);
		if ($ACTIVE_RECORD_SAFETY && $table->_colsCount != $sizeofRow && $sizeofFlds != $sizeofRow) {
			# <AP>
			$bad_size = TRUE;
			if($sizeofRow == 2 * $table->_colsCount || $sizeofRow == 2 * $sizeofFlds) {
				// Only keep string keys
				$keys = array_filter(array_keys($row), 'is_string');
				if (sizeof($keys) == sizeof($table->flds)) {
					$bad_size = FALSE;
				}
			}
			if ($bad_size) {
				$this->Error("Table structure of $this->_table has changed","Load");
				return false;
			}
			# </AP>
		}
		else {
			$keys = array_keys($row);
		}

		# <AP>
		reset($keys);
		$this->_original = array();
		foreach($table->flds as $name=>$fld) {
			$value = $row[current($keys)];
			$this->$name = $value;
			$this->_original[] = $value;
			if(!next($keys)) {
				break;
			}
		}
		$table =& $this->TableInfo();
		foreach($table->_belongsTo as $foreignTable) {
			$ft = $foreignTable->TableInfo();
			$propertyName = $ft->name;
			foreach($ft->flds as $name=>$fld) {
				$value = $row[current($keys)];
				$foreignTable->$name = $value;
				$foreignTable->_original[] = $value;
				if(!next($keys)) {
					break;
				}
			}
		}
		foreach($table->_hasMany as $foreignTable) {
			$ft = $foreignTable->TableInfo();
			foreach($ft->flds as $name=>$fld) {
				$value = $row[current($keys)];
				$foreignTable->$name = $value;
				$foreignTable->_original[] = $value;
				if(!next($keys)) {
					break;
				}
			}
		}
		# </AP>

		return true;
	}
954643
public function insertRow($row)
    {
        if ($row instanceof Row) {
            $this->rows []= $row;
        } elseif (is_array($row)) {
            $newRow = new Row;
            foreach ($row as $cell) {
                $newRow->setCell($cell);
            }
            $this->insertRow($newRow);
        } else {
            throw new \InvalidArgumentException(
                "Argument 1 must be an instance of DataTable\Row or an array of DataTable\Cell"
            );
        }

        return $this;
    }
352871
public function insertBatch(array $row) {
		$this->batch[] = $row;
		if(count($this->batch) >= $this->batch_size) {
			$this->flushBatch();
			return true;
		}
		return false;
	}
656814
public function insertFast(array $row): int
    {
        $connect = $this->connectWrite();

        $count = count($row);
        $prepare = implode(',', array_keys($row));
        $params = trim(str_repeat('?,', $count), ',');
        $sql = 'INSERT' . ' INTO ' . $this->name() . '(' . $prepare . ') VALUES(' . $params . ')';
        $statement = $connect->prepare($sql);
        $statement->execute(array_values($row));
        return intval($connect->lastInsertId());
    }