From fb9dbcf05b6ca1692dcee4f913ec50acd2d76d31 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 20 Jul 2009 14:24:42 +0200 Subject: [PATCH] MFB: Fix sequence name, catch errors. --- ingo/scripts/upgrades/convert_datatree_shares_to_sql.php | 16 ++++++++++------ .../scripts/upgrades/convert_datatree_shares_to_sql.php | 16 ++++++++++------ .../scripts/upgrades/convert_datatree_shares_to_sql.php | 16 ++++++++++------ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ingo/scripts/upgrades/convert_datatree_shares_to_sql.php b/ingo/scripts/upgrades/convert_datatree_shares_to_sql.php index 73ad51414..89816eb67 100755 --- a/ingo/scripts/upgrades/convert_datatree_shares_to_sql.php +++ b/ingo/scripts/upgrades/convert_datatree_shares_to_sql.php @@ -24,6 +24,7 @@ require_once 'MDB2.php'; $config = $GLOBALS['conf']['sql']; unset($config['charset']); $db = MDB2::factory($config); +$db->setOption('seqcol_name', 'id'); $error_cnt = 0; $delete_dt_data = false; @@ -37,23 +38,26 @@ if ($answer != 'y') { } /* Get the share entries */ -$sql = 'SELECT datatree_id, datatree_name FROM horde_datatree WHERE ' - . 'group_uid = \'horde.shares.ingo\''; -$shares_result = $db->query($sql); +$shares_result = $db->query('SELECT datatree_id, datatree_name FROM horde_datatree WHERE group_uid = \'horde.shares.ingo\''); if (is_a($shares_result, 'PEAR_Error')) { die($shares_result->toString()); } +$query = $db->prepare('SELECT attribute_name, attribute_key, attribute_value FROM horde_datatree_attributes WHERE datatree_id = ?'); while ($row = $shares_result->fetchRow(MDB2_FETCHMODE_ASSOC)) { $share_id = $row['datatree_id']; $share_name = $row['datatree_name']; /* Build an array to hold the new row data */ - $data = array('share_id' => $db->nextId('ingo_shares'), + $nextId = $db->nextId('ingo_shares'); + if (is_a($nextId, 'PEAR_Error')) { + $cli->message($nextId->toString(), 'cli.error'); + $error_cnt++; + continue; + } + $data = array('share_id' => $nextId, 'share_name' => $share_name); - $sql = 'SELECT attribute_name, attribute_key, attribute_value FROM horde_datatree_attributes WHERE datatree_id = ?'; - $query = $db->prepare($sql); $query_result = $query->execute($share_id); $rows = $query_result->fetchAll(MDB2_FETCHMODE_ASSOC); $users = array(); diff --git a/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php b/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php index ff3f48ac4..bdd845ce8 100755 --- a/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php +++ b/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php @@ -23,6 +23,7 @@ require_once HORDE_BASE . '/config/conf.php'; $config = $GLOBALS['conf']['sql']; unset($config['charset']); $db = MDB2::factory($config); +$db->setOption('seqcol_name', 'id'); $error_cnt = 0; $delete_dt_data = false; @@ -36,23 +37,26 @@ if ($answer != 'y') { } /* Get the share entries */ -$sql = 'SELECT datatree_id, datatree_name FROM horde_datatree WHERE ' - . 'group_uid = \'horde.shares.kronolith\''; -$shares_result = $db->query($sql); +$shares_result = $db->query('SELECT datatree_id, datatree_name FROM horde_datatree WHERE group_uid = \'horde.shares.kronolith\''); if (is_a($shares_result, 'PEAR_Error')) { die($shares_result->toString()); } +$query = $db->prepare('SELECT attribute_name, attribute_key, attribute_value FROM horde_datatree_attributes WHERE datatree_id = ?'); while ($row = $shares_result->fetchRow(MDB2_FETCHMODE_ASSOC)) { $share_id = $row['datatree_id']; $share_name = $row['datatree_name']; /* Build an array to hold the new row data */ - $data = array('share_id' => $db->nextId('kronolith_shares'), + $nextId = $db->nextId('kronolith_shares'); + if (is_a($nextId, 'PEAR_Error')) { + $cli->message($nextId->toString(), 'cli.error'); + $error_cnt++; + continue; + } + $data = array('share_id' => $nextId, 'share_name' => $share_name); - $sql = 'SELECT attribute_name, attribute_key, attribute_value FROM horde_datatree_attributes WHERE datatree_id = ?'; - $query = $db->prepare($sql); $query_result = $query->execute($share_id); $rows = $query_result->fetchAll(MDB2_FETCHMODE_ASSOC); $users = array(); diff --git a/turba/scripts/upgrades/convert_datatree_shares_to_sql.php b/turba/scripts/upgrades/convert_datatree_shares_to_sql.php index 6a11185c3..2ff26b3ac 100755 --- a/turba/scripts/upgrades/convert_datatree_shares_to_sql.php +++ b/turba/scripts/upgrades/convert_datatree_shares_to_sql.php @@ -25,6 +25,7 @@ require_once 'MDB2.php'; $config = $GLOBALS['conf']['sql']; unset($config['charset']); $db = MDB2::factory($config); +$db->setOption('seqcol_name', 'id'); $error_cnt = 0; $delete_dt_data = false; @@ -38,23 +39,26 @@ if ($answer != 'y') { } /* Get the share entries */ -$sql = 'SELECT datatree_id, datatree_name FROM horde_datatree WHERE ' - . 'group_uid = \'horde.shares.turba\''; -$shares_result = $db->query($sql); +$shares_result = $db->query('SELECT datatree_id, datatree_name FROM horde_datatree WHERE group_uid = \'horde.shares.turba\''); if (is_a($shares_result, 'PEAR_Error')) { die($shares_result->toString()); } +$query = $db->prepare('SELECT attribute_name, attribute_key, attribute_value FROM horde_datatree_attributes WHERE datatree_id = ?'); while ($row = $shares_result->fetchRow(MDB2_FETCHMODE_ASSOC)) { $share_id = $row['datatree_id']; $share_name = $row['datatree_name']; /* Build an array to hold the new row data */ - $data = array('share_id' => $db->nextId('turba_shares'), + $nextId = $db->nextId('turba_shares'); + if (is_a($nextId, 'PEAR_Error')) { + $cli->message($nextId->toString(), 'cli.error'); + $error_cnt++; + continue; + } + $data = array('share_id' => $nextId, 'share_name' => $share_name); - $sql = 'SELECT attribute_name, attribute_key, attribute_value FROM horde_datatree_attributes WHERE datatree_id = ?'; - $query = $db->prepare($sql); $query_result = $query->execute($share_id); $rows = $query_result->fetchAll(MDB2_FETCHMODE_ASSOC); $users = array(); -- 2.11.0