On Jul 19, 2016, at 5:45 AM, Ryan Schmidt wrote:
> On Jul 15, 2016, at 11:51 PM, Kumbhani Bhavesh wrote:
>
>> i got error in update query plz check i use postman for test and this is my
>> update query value of usercolumns [ 'name', 'price', 'duration', 'gender',
>> 'service_category_id' ] dbValues [ 'newservice', '1200', '2016-08-13',
>> 'male', '1' ] id 2
>>
>> sqlconnect.query('UPDATE service SET ? = ? WHERE
>> id=?',[usercolumns,dbValues,id],function(err,uprows){
>
> What error did you get?
Looking at this a little closer, it looks like you're saying usercolumns is an
array of column names, and dbValues is an array of values, and you're expecting
"UPDATE service SET ? = ?" to set each column in the usercolumns array to the
corresponding value in the dbValues array. I'm not sure what library
"sqlconnect" is, or what database server you're connecting to, but I've never
heard of that usage, and that might be the problem. If I were writing this, I
would have written something more like:
sqlconnect.query("UPDATE service SET name=?, price=?, duration=?, gender=?,
service_category_id=? WHERE id=?", ["newservice", 1200, "2016-08-13", "male",
1, 2], function (err, uprows) {...});
Note I also removed the quotes around the price (1200) and the
service_category_id (1), on the assumption that those db columns are defined as
numbers, not strings; maybe that was your problem.
Instead of positional parameters and a numerically-indexed array, many database
servers support named parameters; you might want to look into that, as it's
easier to read and harder to break when you add or remove columns as your code
evolves in the future.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/927E7340-8BC4-4522-93E6-A162D6C423D8%40ryandesign.com.
For more options, visit https://groups.google.com/d/optout.