Skip to main content
edited tags, formatting
Source Link
Fabian Schmengler
  • 66.1k
  • 25
  • 188
  • 422

I am trying to UPDATE values inside of the directory_country table using a data-upgrade script but hit a brick wall with the syntax for updating a table using this method as I am trying to avoid using direct SQL.

Here's what I have so far but it doesn't work at the moment: $installer = $this;

    <?php 
  $installer = $this;
$installer->startSetup();
    
    $installer->run("
    UPDATE `{$installer->getTable('directory_country')}` SET (`country_id`, `iso2_code`, `iso3_code`, `restriction_set`) WHERE
    ('GG', 'GG', 'GGY', '0'),('AD', 'AD', 'ADY', '7'),('AI', 'AI', 'AIA', '7'),('AG', 'AG', 'ATG', '7');
    ");

    $installer->endSetup();

Could anyone suggest the best way to do this please?

I am trying to UPDATE values inside of the directory_country table using a data-upgrade script but hit a brick wall with the syntax for updating a table using this method as I am trying to avoid using direct SQL.

Here's what I have so far but it doesn't work at the moment: $installer = $this;

    <?php 
    $installer->startSetup();
    
    $installer->run("
    UPDATE `{$installer->getTable('directory_country')}` SET (`country_id`, `iso2_code`, `iso3_code`, `restriction_set`) WHERE
    ('GG', 'GG', 'GGY', '0'),('AD', 'AD', 'ADY', '7'),('AI', 'AI', 'AIA', '7'),('AG', 'AG', 'ATG', '7');
    ");

    $installer->endSetup();

Could anyone suggest the best way to do this please?

I am trying to UPDATE values inside of the directory_country table using a data-upgrade script but hit a brick wall with the syntax for updating a table using this method as I am trying to avoid using direct SQL.

Here's what I have so far but it doesn't work at the moment:

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

$installer->run("
UPDATE `{$installer->getTable('directory_country')}` SET (`country_id`, `iso2_code`, `iso3_code`, `restriction_set`) WHERE
('GG', 'GG', 'GGY', '0'),('AD', 'AD', 'ADY', '7'),('AI', 'AI', 'AIA', '7'),('AG', 'AG', 'ATG', '7');
");

$installer->endSetup();

Could anyone suggest the best way to do this please?

Source Link
user1704524
  • 2.5k
  • 13
  • 60
  • 106

How can I update values in database table using an upgrade script?

I am trying to UPDATE values inside of the directory_country table using a data-upgrade script but hit a brick wall with the syntax for updating a table using this method as I am trying to avoid using direct SQL.

Here's what I have so far but it doesn't work at the moment: $installer = $this;

    <?php 
    $installer->startSetup();
    
    $installer->run("
    UPDATE `{$installer->getTable('directory_country')}` SET (`country_id`, `iso2_code`, `iso3_code`, `restriction_set`) WHERE
    ('GG', 'GG', 'GGY', '0'),('AD', 'AD', 'ADY', '7'),('AI', 'AI', 'AIA', '7'),('AG', 'AG', 'ATG', '7');
    ");

    $installer->endSetup();

Could anyone suggest the best way to do this please?