updates $values within $table based on $criteria.  returns the
number of rows changed by the update (including zero).

@param string $table
@param array  $values
@param array  $criteria

@throws DatabaseException
@return int
480856
public function update(string $table, array $values, array $criteria = []): int {
		
		// like our insertion methods above, this one can impact one or more rows
		// and we want to return the number of rows we alter.  unlike the insertion
		// methods, all we need to do is build our statement which isn't too hard for
		// us to do.
		
		$where = "";
		$updates = [];
		$valueColumns = array_keys($values);
		foreach ($valueColumns as $column) {
			$updates[] = sprintf("%s%s%s = ?", $this->columnPrefix, $column, $this->columnSuffix);
		}
		
		$statement = "UPDATE $table SET " . join(", ", $updates);
		
		if (sizeof($criteria) > 0) {
			$whereColumns = array_keys($criteria);
			foreach ($whereColumns as $column) {
				$where .= sprintf("%s%s%s = ?", $this->columnPrefix, $column, $this->columnSuffix);
			}
			
			$statement .= " WHERE $where";
		}
		
		// now that we've built our statement, we need to combine the values and criteria values
		// which are then bound to the statement by the ExtendedPdo object.  then, we can perform
		// the statement and return the number of affected rows.
		
		$bindings = $this->mergeBindings($values, $criteria);
		
		try {
			return $this->dbConn->fetchAffected($statement, $bindings);
		} catch (\PDOException $pdoException) {
			throw $this->prepareDatabaseException($pdoException, $statement, $bindings);
		}
	}
616938
public function seeInDatabase( $table, $criteria = array() ) {
		$query = $this->_prepareQuery( $table, 'count(*)', $criteria );
		$this->debugSection( 'Query', $query );

		$suppress_errors = $this->_wpdb->suppress_errors( true );
		$res = $this->_wpdb->get_var( $query );
		$this->_wpdb->suppress_errors( $suppress_errors );

		if ( ! empty( $this->_wpdb->last_error ) ) {
			$this->fail( 'Database error: ' . $this->_wpdb->last_error );
			return;
		}

		$this->assertGreaterThan( 0, $res, 'No matching records found' );
	}
909113
protected <T> int updateFields (
        final Table<T> table, final T object, String[] fields)
        throws PersistenceException
    {
        final FieldMask mask = table.getFieldMask();
        for (int ii = 0; ii < fields.length; ii++) {
            mask.setModified(fields[ii]);
        }
        return executeUpdate(new Operation<Integer>() {
            public Integer invoke (Connection conn, DatabaseLiaison liaison)
                throws SQLException, PersistenceException
            {
                return table.update(conn, object, mask);
            }
        });
    }
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();
    }
17278
public function countRecordsInTableMatching($table, $criteria = []): int
    {
        $where = '';
        foreach ($criteria as $field => $vale) {
            if ($where) {
                $where .= ' AND ';
            }
            if ($vale === null) {
                $where .= sprintf('%s IS NULL', $field);
            } else {
                $where .= sprintf('%s = :%s', $field, $field);
            }
        }
        $query = sprintf('SELECT count(*) AS records FROM %s WHERE %s', $table, $where);

        /** @var EntityManager $manager */
        $manager = $this->client->getContainer()->get('doctrine')->getManager();
        $rsm = new ResultSetMapping();
        $rsm->addScalarResult('records', 'records', 'integer');
        $query = $manager->createNativeQuery($query, $rsm);
        $query->setParameters($criteria);

        return (int) $query->getSingleScalarResult();
    }
193288
public function update($table, array $data, array $conditions)
    {
        $table = $this->getTable($table);
        $set = $this->buildSqlObject($data, ', ');
        $where = $this->buildSqlObject($conditions, ' AND ');

        $query = "UPDATE $table SET $set WHERE $where";
        $params = array_merge(array_values($data), array_values($conditions));
        return $this->executeUpdate($query, $params);
    }
737697
public function findRecords(string $table, array $criteria = []): array
    {
        $url = $this->getEndpoint($table);

        if (count($criteria) > 0) {
            $formulas = [];
            foreach ($criteria as $field => $value) {
                $formulas[] = sprintf("%s='%s'", $field, $value);
            }

            $url .= sprintf(
                '?filterByFormula=(%s)',
                implode(' AND ', $formulas)
            );
        }

        /** @var Response $response */
        $response = $this->browser->get(
            $url,
            [
                'content-type' => 'application/json',
            ]
        );

        $data = json_decode($response->getContent(), true);

        return array_map(function (array $value) {
            return new Record($value['id'], $value['fields']);
        }, $data['records']);
    }
226475
public function buildUpdateSQL(array $values) {
		if(count($values) == 0)
			throw new \Exception('Update values should not be empty.');
		$params = [];

		if($this->db->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql') {
			list($jointures, $joinparams) = $this->buildJointures();
			$params = $joinparams;

			$set = [];
			foreach($values as $k=>$v) {
				if($v instanceof static) {
					$sql = $v->buildSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k).'=('.$sql.')';
				}
				elseif($v instanceof Raw) {
					$sql = $v->getSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k).'='.$sql;
				}
				else {
					$params[] = $v;
					$set[] = $this->replace($k).'=?';
				}
			}
			$str = ' SET '.implode(', ', $set);

			list($tables, $tableparams) = $this->buildTables(true);
			$params = array_merge($params, $tableparams);

			#can't mix order by and joins in update
			if($this->joins)
				$orderBy = '';
			else {
				list($orderBy, $orderByParams) = $this->buildOrderBy();
				$params = array_merge($params, $orderByParams);
			}
			$limit = $this->buildLimit();

			list($where, $whereparams) = $this->buildWhere();
			$params = array_merge($params, $whereparams);
			$sql = 'UPDATE '.$tables.$jointures.$str.$where.$orderBy.$limit;
		}
		elseif($this->joins || $this->limit || $this->offset) {
			$set = [];
			foreach($values as $k=>$v) {
				if($v instanceof static) {
					$sql = $v->buildSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'=('.$sql.')';
				}
				elseif($v instanceof Raw) {
					$sql = $v->getSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'='.$sql;
				}
				else {
					$params[] = $v;
					$set[] = $this->replace($k, false).'=?';
				}
			}
			$str = ' SET '.implode(', ', $set);

			$selectDal = clone $this;
			$selectDal->select('1')->from($this->getDefaultTable(true).' thisIsAUniqueAlias');

			$selectDal->replaceTable($this->getDefaultTable(), 'thisIsAUniqueAlias');

			foreach($this->db->getSchema()->table($this->getDefaultTable(true))->getColumns() as $colName=>$col)
				$selectDal->where('(thisIsAUniqueAlias.'.$colName.' IS NULL AND '.$this->getDefaultTable(true).'.'.$colName.' IS NULL OR thisIsAUniqueAlias.'.$colName.' = '.$this->getDefaultTable(true).'.'.$colName.')');

			$selectSql = $selectDal->buildSQL();

			$params = array_merge($params, $selectDal->getParameters());

			list($tables, $tableparams) = $this->buildTables(false);
			$params = array_merge($params, $tableparams);

			$sql = 'UPDATE '.$tables.$str."\n".'WHERE EXISTS ('.$selectSql.')';
		}
		else {
			$set = [];
			foreach($values as $k=>$v) {
				if($v instanceof static) {
					$sql = $v->buildSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'=('.$sql.')';
				}
				elseif($v instanceof Raw) {
					$sql = $v->getSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'='.$sql;
				}
				else {
					$params[] = $v;
					$set[] = $this->replace($k, false).'=?';
				}
			}
			$str = ' SET '.implode(', ', $set);

			list($tables, $tableparams) = $this->buildTables(false);
			$params = array_merge($params, $tableparams);

			list($where, $whereparams) = $this->buildWhere();
			$params = array_merge($params, $whereparams);

			$sql = 'UPDATE '.$tables.$str.$where;
		}

		$this->replaceArrayParams($sql, $params);
		$this->replaceRaws($sql, $params);

		$this->params = $params;

		return $sql;
	}
1075752
public function count($column = '*', $criteria = array(),
            $return = Table::RETURN_DEFAULT) {
        $this->query = 'SELECT COUNT(' . Util::camelTo_($column) . ') as rows FROM `' . $this->name . '`';
        $this->where($criteria);

        $this->setExpectedResult($return, true);
        if ($ret = $this->execute()) {
            return ($ret) ? $ret[0]['rows'] : 0;
        }
        return 0;
    }
502945
function insertUpdate(string $tableName, array $values, array $wheres)
  {
    $wClause = implode(" and ", $this->makeClauses($wheres));

    if ($this->queryValue("select count(*) from $tableName where $wClause") != 0)
    {
      if (count($values))
      {
        $v = [];
        foreach ($values as $key => &$value)
          $v[] = "`$key`=".$this->quote($value);

        $this->q
        (
          "update $tableName set ".
          implode(",",$v).
          " where $wClause"
        );
      }
      return null;
    }
    else
    {
      return $this->insert($tableName, array_merge($values, $wheres));
    }
  }
273015
public function update(array $values): array
	{
		$sql  = $this->query->getPrefix();
		$sql .= 'UPDATE ';
		$sql .= $this->escapeTable($this->query->getTable());
		$sql .= ' SET ';
		$sql .= $this->updateColumns($values);
		$sql .= $this->wheres($this->query->getWheres());

		return ['sql' => $sql, 'params' => $this->params];
	}
413546
public function updateRow(int $idNumber, array $values): void
    {
        $this->connection->update($this->tableName, $values, ['id' => $idNumber]);
    }
772541
public function update($table, array $values = null)
    {
        $this->table($table);
        if( !empty($values) ) {
            $this->values($values);
        }
        return $this;
    }
88202
public function getNumberOf(string $table, array $fields, array $values, string $connectionPhrase = "AND"): int
    {
        try {
            $this->db->beginTransaction();

            $query = "SELECT count(*) as numberOfEntities FROM $table ";

            $query = $query . $this->buildWhereCondition($fields, $connectionPhrase);

            /** @var PDOStatement $stmt */
            $stmt = $this->db->prepare($query);
            $stmt->execute($values);

            $this->db->commit();
            $result = $stmt->fetch();

            return $result['numberOfEntities'];
        } catch (PDOException $e) {
            $this->db->rollBack();
            throw new PDOException($e);
        }
    }
539823
public static boolean updateRow(Connection conn,
                                    String table,
                                    String[] columns,
                                    String[] values,
                                    String uniqueColumn,
                                    boolean[] numeric) throws SQLException {
        return instance.i_updateRow(conn,
                                    table,
                                    columns,
                                    values,
                                    uniqueColumn,
                                    numeric);
    }
772264
public function update($table, array $data, array $conditions, $filter = true)
    {
        if ($filter) {
            $data = $this->filterValues($table, $data);
        }

        if (empty($data)) {
            return 0;
        }

        $farray = array();
        foreach (array_keys($data) as $key) {
            $farray[] = "$key=:$key";
        }

        $carray = array();
        foreach (array_keys($conditions) as $key) {
            $carray[] = "$key=:$key";
        }

        $fields = implode(',', $farray);
        $sql = "UPDATE $table SET $fields WHERE " . implode(' AND ', $carray);

        $stmt = $this->pdo->prepare($sql);

        foreach ($data as $key => $value) {
            $stmt->bindValue(":$key", $value);
        }

        foreach ($conditions as $key => $value) {
            $stmt->bindValue(":$key", $value);
        }

        $stmt->execute();
        $this->executed[] = $sql;
        return $stmt->rowCount();
    }
822041
public function update($table, array $values = null)
    {
        $builder         = new Update($this->driver);
        $this->lastQuery = $builder;

        if ($values) {
            $builder->values($values);
        }

        return $builder->update($table);
    }