0

I am trying to make a collate change (DEFAULT CHARSET=utf8 COLLATE utf8_general_ci) to db but not sure how? (magento1.9)

<?php
$installer = $this;
$installer->startSetup();

$installer->getConnection()

// how to do collate change here?

Help much appreciated,

Thanks G

0

1 Answer 1

0

You can run a SQL query in your install script:

$installer->run("ALTER TABLE `{$this->getTable('your/table')}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;");

Edit:

I think there is no built-in method to change tables charset. There is only a method to change columns ...

$installer->getConnection()->changeColumn($tableName, $oldColumnName, $newColumnName, $definition);

Example from magento update script:

$installer->getConnection()->changeColumn($this->getTable('sales_flat_quote_item'),
    'weee_tax_applied', 'weee_tax_applied',
    'text CHARACTER SET utf8'
);
2
  • Hi @sv3n thanks that is what I currently have but we are looking for a "Zend-esque"/ORM way of doing it (if possible) Commented Mar 22, 2018 at 12:23
  • 1
    @gvanto as far as i know there is no Varien/Zend/Magento method to achieve this. Commented Mar 22, 2018 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.