<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 6.00.6000.16705" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>try something like this:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>$counter = 0;<BR>foreach ($feature->attributes as $key
=> $val) {<BR> $val = ($val == '') ? 'NULL' :
<BR> sprintf("'%s'",
Encoder::decode(Utils::addslashes($val),
<BR>
'config'));<BR> if (in_array($key, $editableAttributes))
{<BR> $attributesFieldsSql .=
"$key";<BR> $attributesValuesSql .=
"$val";<BR> }<BR> if ($counter <
sizeof($feature->attributes)) {<BR>
$attributesFieldsSql .= ",";<BR>
$attributesValuesSql .= ",";
<BR> }<BR> $counter ++;<BR>}</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=chastagnol.claire@wanadoo.fr
href="mailto:chastagnol.claire@wanadoo.fr">Claire Chastagnol</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=cartoweb-users@lists.maptools.org
href="mailto:cartoweb-users@lists.maptools.org">cartoweb-users@lists.maptools.org</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, September 26, 2008 12:08
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Cartoweb-users] edit
plugin</DIV>
<DIV><BR></DIV>
<P
style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"
align=left>Hi everybody,<BR><BR>I'm trying to extend the edit plugin because I
need to update some geographic data with atrributes which come from a
different table.<BR><BR><BR><BR>The sql query generated isn't right : I have
some "," problems:<BR>I have this error message indeed:<BR><BR><PRE style="BORDER-RIGHT: 0pt; BORDER-TOP: 0pt; BORDER-LEFT: 0pt; BORDER-BOTTOM: 0pt">Userinfo: INSERT INTO public.evenements_evolution (id_route, id_ev, id_etat, localisation_pr, date, heure, description<FONT color=#ff0000>,</FONT> )<BR>VALUES ('850', '2', '2', 'pr8 pr9', '1 octobre 08', '12h', 'chaussee glissante'<FONT color=#ff0000>,</FONT> ) [nativecode=ERREUR: erreur de syntaxe sur ou près de « ) »<BR>LINE 1: ..._etat, localisation_pr, date, heure, description, )VALUES ('...</PRE><BR>This
is the code I put in my extension for updating:<BR><BR>
protected function updateFeature($feature)
{<BR> $db =
$this->getDb($this->layer);<BR>
<BR> $editableAttributes =
$this->getEditableAttributes($this->attributes);<BR>
<BR>
$this->editSchema = 'public';<BR>
$this->editTable = $this->getMetadataValueString($this->layer,
'edit_table');<BR> $editTables =
explode(',', $this->editTable);<BR>
<BR><BR> if
(isset($feature->attributes) && $feature->attributes)
{<BR>
$attributesFieldsSql = $attributesValuesSql =
'';<BR>
foreach ($feature->attributes as $key => $val)
{<BR>
$val = ($val == '') ? 'NULL' :
<BR>
sprintf("'%s'", Encoder::decode(Utils::addslashes($val),
<BR>
'config'));<BR>
if (in_array($key, $editableAttributes))
{<BR>
$attributesFieldsSql .= "$key,
";<BR>
$attributesValuesSql .= "$val,
";<BR>
}<BR>
}<BR> if
($attributesValuesSql ==
'')<BR>
$attributesValuesSql = NULL;<BR> }
else {<BR>
$attributesFieldsSql =
'';<BR>
$attributesValuesSql = NULL;<BR>
}<BR> $sql = sprintf
('INSERT INTO %s.%s (%s)' .<BR>
"VALUES (%s) ",<BR>
$this->editSchema,<BR>
$editTables[1],<BR>
$attributesFieldsSql,<BR>
$attributesValuesSql<BR>
); <BR>
$this->log->debug($sql);<BR>
$queryId = $db->query($sql);<BR>
<BR> Utils::checkDbError($queryId,
'Unable to insert feature in edit database');<BR>
return $queryId;<BR>
<BR> }<BR><BR><PRE style="BORDER-RIGHT: 0pt; BORDER-TOP: 0pt; BORDER-LEFT: 0pt; BORDER-BOTTOM: 0pt">How can I do? (I tried with the substr function but without success...)<BR><BR>Thanks.<BR>Claire<BR></PRE><BR><BR><BR>
<P></P>
<P>
<HR>
<P></P>_______________________________________________<BR>Cartoweb-users
mailing
list<BR>Cartoweb-users@lists.maptools.org<BR>http://lists.maptools.org/mailman/listinfo/cartoweb-users<BR></BLOCKQUOTE></BODY></HTML>