Although this may technically work, the code you wrote is the last way you should do this.
In Magento, you really should use the models provided by the code and not write database queries yourself.
In your case, if you need to update attributes for 1 or many products, you can do it very quickly (and quite safely).
If you look at: /app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php, you will find that this controller is designed to quickly update several products.
If you look in the saveAction () function, you will find the following line of code:
Mage::getSingleton('catalog/product_action') ->updateAttributes($this->_getHelper()->getProductIds(), $attributesData, $storeId);
This code is responsible for updating all the product identifiers you want, and only the changed attributes for any single store at a time.
The first parameter is basically an array of product identifiers. If you only want to update one product, just put it in an array.
The second parameter is an array containing the attributes that you want to update for these products. For example, if you want to update the price to $ 10 and weight to 5, you must pass the following array:
array('price' => 10.00, 'weight' => 5)
Then, finally, the third and last attribute is the identifier of the store with which you need these updates. Most likely, this number will be equal to 1 or 0.
I would play around with this function call and use this instead of writing and supporting your own database queries.