Vizzuality / cartodbclient-php

A CartoDB client for PHP
http://developers.cartodb.com
BSD 4-Clause "Original" or "Old" License
33 stars 17 forks source link

Update function issues #5

Open mikegiddens opened 12 years ago

mikegiddens commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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

jatorre commented 12 years ago

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 commented 12 years ago

Added.

On 08/10/2012, at 19:26, mikegiddens notifications@github.com 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.