Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update function issues #5

Open
mikegiddens opened this issue Oct 8, 2012 · 4 comments
Open

Update function issues #5

mikegiddens opened this issue Oct 8, 2012 · 4 comments

Comments

@mikegiddens
Copy link

I would suggest making these changes to the update function. Remove the lastID since this is an update statement and is not needed. Also adding single quotes to the values so that it does not crash on string values.

  public function updateRow($table, $row_id, $data) {
    $keys = implode(',', array_keys($data));
    $values = implode('\',\'', array_values($data));
    $sql = "UPDATE $table SET ($keys) = ('$values') WHERE cartodb_id = $row_id;";
#    $sql .= "SELECT $table.cartodb_id as id, $table.* FROM $table ";
#    $sql .= "WHERE cartodb_id = currval('public." . $table . "_cartodb_id_seq');";
    return $this->runSql($sql);
  }
@jatorre
Copy link
Contributor

jatorre commented Oct 8, 2012

Mike.

Do you want to take control over this repo?

I am the responsabile person and I dont really have time for it.

On Oct 8, 2012, at 7:03 PM, mikegiddens wrote:

I would suggest making these changes to the update function. Remove the lastID since this is an update statement and is not needed. Also adding single quotes to the values so that it does not crash on string values.

public function updateRow($table, $row_id, $data) {
$keys = implode(',', array_keys($data));
$values = implode('','', array_values($data));
$sql = "UPDATE $table SET ($keys) = ('$values') WHERE cartodb_id = $row_id;";

$sql .= "SELECT $table.cartodb_id as id, $table.* FROM $table ";

$sql .= "WHERE cartodb_id = currval('public." . $table . "_cartodb_id_seq');";

return $this->runSql($sql);

}

Reply to this email directly or view it on GitHub.

@mikegiddens
Copy link
Author

Go ahead and put me on the list to edit this and I will make the changes.

@jatorre
Copy link
Contributor

jatorre commented Oct 8, 2012

done
Javier de la Torre
@jatorre

Vizzuality / CartoDB
148 Lafayette St. PH, New York, 10013,USA
+1 347 320 7715

www.cartodb.com
Map, analyze and build applications with your data

On Oct 8, 2012, at 7:26 PM, mikegiddens wrote:

Go ahead and put me on the list to edit this and I will make the changes.


Reply to this email directly or view it on GitHub.

@jatorre
Copy link
Contributor

jatorre commented Oct 8, 2012

Added.

On 08/10/2012, at 19:26, mikegiddens [email protected] wrote:

Go ahead and put me on the list to edit this and I will make the changes.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants