-1

I'm developing a module at Opencart.

I don't know much about mysql.

What I want to do is;

phpMyAdmin -> oc_product_description -> meta_description

I want to convert the data type of the column from varchar to text.

-OCMOD- How should I change this in the XML file?

The codes are all right, but I can't get what I want without changing it.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • You can not do it by ocmod XML file. You need to add code in "install()" function of your module or in ocmod file "install.php" or "install.sql" – jay padaliya Jan 23 '19 at 05:34

1 Answers1

1

I do not understand your question, but if you mean you want to change column type, in opencart you can ran this string:

$this->db->query("ALTER TABLE `" . DB_PREFIX . "tablename` MODIFY `columnname` TEXT");

where you need to change it.

in controller file place something like this:

public function install(){ 
           $this->load->model('module/yourmodule');
           $this->model_module_yourmodule->install();
             }

in coresponding model:

public function install(){
$this->db->query("ALTER TABLE `" . DB_PREFIX . "tablename` MODIFY `columnname` TEXT");
}
K. B.
  • 1,388
  • 2
  • 13
  • 25
  • Thanks dude. Where should I add this code to the ocmod xml file? $this->db->query("ALTER TABLE `" . DB_PREFIX . "oc_product_description` MODIFY `meta_description` TEXT"); That's the way it should be, huh? – Bülent Çelik Jan 22 '19 at 18:40
  • this line should be added to yourmodule.php model file under some public function. than you can run this function in your corresponding controller file. How to build OCMOD you can find using google. https://webocreation.com/blog/ocmod-documentation – K. B. Jan 22 '19 at 20:56
  • thanks. My xml file is ready and running. but I don't know how to edit the sql file. I need to add the xml file, or I need to create a file called install.sql. – Bülent Çelik Jan 22 '19 at 21:13
  • if you need edit sql once you can make it via phpmyadmin in sql tab by runing this: `ALTER TABLE oc_tablename MODIFY columnname TEXT`. Or do like I have explained in my first comment. I edited how in my first answer. – K. B. Jan 22 '19 at 21:33