1. forget VQMod, use OCModwh1t3man2nd wrote: ↑Thu Aug 01, 2019 5:47 amI'm just starting to develop some simple opencart extensions with the use of vqmod and i'd like to ask where should i place the sql alteration code of the db in order to add a new column in the db..
2. simply add the code for the database inside the main controller of the extension
3. if you do not use any controller, only with VQMod or OCMod touching the database is not possible
If you plan to publish that extension, then:
4. if you want to manipulate an existing table, forget that also
5. create a new table (do not touch existing tables)
otherwise you can do what you want.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
This, of course, is not true. You can do whatever you want with the database by adding queries to any places you need. And yes, it includes creating new tables as well
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Partly correct.
You cannot add code to any VQMod or OCMod which manipulates directly the database.
What is possible, is to create some lines which are added to any controller or model - and there you can do what you need/want.
Which is aquivalent to:
Which is also not 100% correct, because you cannot add such queries inside template files (.php and/or .tpl or/and .twig) (have seen such already!)... by adding queries to any places you need ..
@krotek: if you answer a question, then in a way it is clear and noobs do not misunderstand!
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Partly correct and "touching the database is not possible" are two different things, which was the point. It doesn't really matter, if you use a controller to create a table or XML file to add a corresponding function to another controller. One way or another you have to execute the controller class. So it's actually "possible" versus "not possible". It's not only possible, but very much valid in most cases, when you need to complete a simple task. Instead of creating a whole controller, you can create a simple modification, which will do the same, but with the less code.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Well, what i did was to create a basic module controller and then create a "protected" function that checks for the existence of the db column.OSWorX wrote: ↑Thu Aug 01, 2019 4:08 pm1. forget VQMod, use OCModwh1t3man2nd wrote: ↑Thu Aug 01, 2019 5:47 amI'm just starting to develop some simple opencart extensions with the use of vqmod and i'd like to ask where should i place the sql alteration code of the db in order to add a new column in the db..
2. simply add the code for the database inside the main controller of the extension
3. if you do not use any controller, only with VQMod or OCMod touching the database is not possible
If you plan to publish that extension, then:
4. if you want to manipulate an existing table, forget that also
5. create a new table (do not touch existing tables)
otherwise you can do what you want.
As for the one you say about creating a new table i find it a bit useless for this particular function, since it will be an "on - off" switch for showing a particular field of the product.
In my case i've just created an index controller and created a function that checks for the db fields.thekrotek wrote: ↑Thu Aug 01, 2019 5:23 pmPartly correct and "touching the database is not possible" are two different things, which was the point. It doesn't really matter, if you use a controller to create a table or XML file to add a corresponding function to another controller. One way or another you have to execute the controller class. So it's actually "possible" versus "not possible". It's not only possible, but very much valid in most cases, when you need to complete a simple task. Instead of creating a whole controller, you can create a simple modification, which will do the same, but with the less code.
That has a good reason!wh1t3man2nd wrote: ↑Thu Aug 01, 2019 9:10 pmAs for the one you say about creating a new table i find it a bit useless for this particular function, since it will be an "on - off" switch for showing a particular field of the product.
In the case you (or somebody else) create a new extension and want to publish it in the OpenCart Marketplace (there also compatible for the OpenCart Cloud), you are not allowed to manipulate existing tables!
You are only allowed to create a new table and call the values of that newly created table additionally.
That's why.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Ok finally found it! Had to check it for my own, since i had to understand the install and uninstall function!OSWorX wrote: ↑Fri Aug 02, 2019 1:06 amThat has a good reason!wh1t3man2nd wrote: ↑Thu Aug 01, 2019 9:10 pmAs for the one you say about creating a new table i find it a bit useless for this particular function, since it will be an "on - off" switch for showing a particular field of the product.
In the case you (or somebody else) create a new extension and want to publish it in the OpenCart Marketplace (there also compatible for the OpenCart Cloud), you are not allowed to manipulate existing tables!
You are only allowed to create a new table and call the values of that newly created table additionally.
That's why.
I've added the queries in those two functions! Thanks though for any help provided!!
Just to add what is meant.wh1t3man2nd wrote: ↑Tue Aug 06, 2019 1:48 amOk finally found it! Had to check it for my own, since i had to understand the install and uninstall function!
I've added the queries in those two functions! Thanks though for any help provided!!
Since OpenCart 2.x the core has 2 included functions (can be found inside the file admin/controller/extension/extension/XXXX.php).
XXXX has to be replaced by module, payment, and so on ..
These 2 funtions are:
1. install
2. uninstall
Both are installing/uninstalling the extension and set correct user permissions (only for the user who is installing it !).
And inside both, they check if the extension itself has also these 2 functions: install and uninstall.
IF they exist, the developer can add inside whatever he wants to be installed (or also uninstalled).
Also creating new database tables.
That's all in short.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Users browsing this forum: No registered users and 44 guests