Reputation: 159
I have an error whenever I try to test my endpoint for the database it says "code": "ER_PARSE_ERROR"
so this is my model for mysql database:
let query = `UPDATE tbl_branch_info
SET
${whats === undefined ? `` : `whats=${whats},`}
${twitter === undefined ? `` : `twitter='${twitter}',`}
${facebook === undefined ? `` : `facebook='${facebook}',`}
${snapchat === undefined ? `` : `snapchat='${snapchat}',`}
${instagram === undefined ? `` : `instagram='${instagram}',`}
${phone === undefined ? `` : `telephone=${phone},`}
${address === undefined ? `` : `address='${address}',`}
${email === undefined ? `` : `email='${email}',`}
${city_id === undefined ? `` : `city_id=${city_id},`}
${category_id === undefined ? `` : `category_id=${category_id},`}
${subCategoryId === undefined ? `` : `sub_cat_id=${subCategoryId},`}
${lon === undefined ? `` : `lon=${lon},`}
${lat === undefined ? `` : `lat=${lat}`}
WHERE branch_id = ${branch_id}`;
it gives me this error :
but then if I change the last line before the the branch_id which is the lat to this
lat='${lat}'
it will pass data just fine, so what could be the problem here ?
Upvotes: 1
Views: 1174
Reputation: 42728
let query = `UPDATE tbl_branch_info
SET
${whats === undefined ? `` : `whats=${whats},`}
${twitter === undefined ? `` : `twitter='${twitter}',`}
${facebook === undefined ? `` : `facebook='${facebook}',`}
${snapchat === undefined ? `` : `snapchat='${snapchat}',`}
${instagram === undefined ? `` : `instagram='${instagram}',`}
${phone === undefined ? `` : `telephone=${phone},`}
${address === undefined ? `` : `address='${address}',`}
${email === undefined ? `` : `email='${email}',`}
${city_id === undefined ? `` : `city_id=${city_id},`}
${category_id === undefined ? `` : `category_id=${category_id},`}
${subCategoryId === undefined ? `` : `sub_cat_id=${subCategoryId},`}
${lon === undefined ? `` : `lon=${lon},`}
${lat === undefined ? `` : `lat=${lat},`}
${`branch_id = ${branch_id}`}
WHERE branch_id = ${branch_id}`;
Upvotes: 1