public static function update($id, $keysValues, $table, $idAttribute = 'id', $limit = 1)
    {
        //Work with arrays
        if (is_object($keysValues)) {
            $keysValues = (array)$keysValues;
        }

        $queryKeys = implode('" = ?,"', array_keys($keysValues));
        $queryValues = array_values($keysValues);

        //Push id to the end
        $queryValues[] = $id;

        $tableName = '';

        //Work with array
        if (is_object($table)) {
            $table = (array)$table;
        }

        if (is_array($table)
            && isset($table['schema'])
            && isset($table['table'])
        ) {

            $tableName = sprintf(
                '"%s"."%s"',
                $table['schema'],
                $table['table']
            );
        } else {
            $tableName = sprintf(
                '"%s"',
                $table
            );
        }

        $query = sprintf(
            'UPDATE %s SET "%s" = ?
              WHERE "%s" = ?
              %s',
            $tableName,
            $queryKeys,
            $idAttribute,
            (
                $limit === null
                ? ''
                : '' //'LIMIT ' . $limit
            )
        );

        //Return number of rows affected
        $result = Database::execute($query, $queryValues);

        return $result;
    }