George Posted March 4, 2019 Share Posted March 4, 2019 I want to show you the wrong method of coding in Prestashop.Please have a look db.php .look there is an update function. this function do nothing specially .Whats its doing ? this function make a string that mySQL understand.there is some parameter each users want to use get parameters and make string.if you see third parameter is "Where" .Its getting a string from users.no care whats this string its going to append to the string in end of the string.This is not easy to understand whats this that we make No SQL.Imagine howmuch easy can make NO SQL.Look first line is table name.so its easy to understand and second is filds inside data base have data but third is not clear .this is open users hands however this is wrong way.Forth parameter is numeric and easy to understand and next is non value and ...........all others. This "where" is every where its not easy to change all. Db.php Link to comment Share on other sites More sharing options...
razaro Posted March 4, 2019 Share Posted March 4, 2019 Hi George I can not say that is too much wrong it is a way that class and function is made. Think it originate from earliest versions of PresstaShop. It does not do anything special, just more convenient way to write update command. Note one SQL query can be done in different ways. You can do update with query function, with update or with DBQuery class https://devdocs.prestashop.com/1.7/development/database/dbquery/ Example of use : public static function updateIsVirtual($id_product, $is_virtual = true) { Db::getInstance()->update('product', array( 'is_virtual' => (bool) $is_virtual, ), 'id_product = ' . (int) $id_product); } Note by default is is empty and it would not add anything to string. Also if you are concern that you can add any text there, that is true. But that is developer job so he gets right result. To me this is nor good or bad, it is like that and I personally did not use it much in this form. Now why it this so bad for you I can not say. You can post your code here where you have issues with No SQL. What it is missing for you and your query. Do you get any error or missing parameter? Please give more info on your code. I did not work long time with MongoDB so think as this as my poor example to compare code. But previous code could be similar to db.product.update( { id_product: (int) $id_product }, { is_virtual: (bool) $is_virtual }, { upsert: true } ) From https://docs.mongodb.com/manual/reference/method/db.collection.update/ example. So again give example of your code, if you can, where this update function brake or explain in your code how that 'where' parameter is blocking your progress. Link to comment Share on other sites More sharing options...
George Posted March 4, 2019 Author Share Posted March 4, 2019 Hi Thank you for your email.As you know i try to cancel MySQL and move to Elastic or MongoDB.I am looking for some way to give up from MySQL.This "Where " is many place and need to change all.I think very much place have this function.I think very much place use this.I think take very much time.if i can find some way to update all will be perfect Link to comment Share on other sites More sharing options...
ksaan Posted March 4, 2019 Share Posted March 4, 2019 (edited) Hi, why do you want to use NO SQL database for prestashop ? Indeed prestashop is built to work with a SQL database, and I'm not even sure it can work with PostgreSQL (at least not at 1st attempt, it would need customisation) but that's quite usual. Edited March 4, 2019 by ksaan (see edit history) Link to comment Share on other sites More sharing options...
George Posted March 5, 2019 Author Share Posted March 5, 2019 If i can find some way for this and can guarantee an architecture for prestashop no one even believe possible to do by prestashop.I can make all response of prestashop in realtime you know "where" is not bad function to give chance anyone communicate well however its not normal to make Query Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now