cartodbclient-php icon indicating copy to clipboard operation
cartodbclient-php copied to clipboard

Update function issues

Open mikegiddens opened this issue 13 years ago • 4 comments

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);
  }

mikegiddens avatar Oct 08 '12 17:10 mikegiddens

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.

jatorre avatar Oct 08 '12 17:10 jatorre

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

mikegiddens avatar Oct 08 '12 17:10 mikegiddens

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 avatar Oct 08 '12 17:10 jatorre

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.

jatorre avatar Oct 08 '12 18:10 jatorre