[turba] owner_id in turba_objects

Paul van der Vlis paul at vandervlis.nl
Mon Mar 31 20:02:55 UTC 2008


Paul van der Vlis schreef:
> Hello,
> 
> I try to upgrade, but I have some problems:
> 
> In my old table turba_objects I have 'owner_id' in this form:
> username at domain.tld
> And in the new database in the form:
> username
> 
> What can I do to convert the old owner_id's into the new type?
> (there are many users, it's a school).

I made a quick and dirty script for this problem. Maybe it can help
somebody else.
(I am not a good programmer, but it works)

-----------
<?php
$myhostname="localhost";
$dbuser="horde";
$dbpw="secret";
$database="horde";

$connection = @mysql_connect($myhostname, $dbuser, $dbpw);
$db = mysql_select_db($database, $connection);

  $connection = @mysql_connect($myhostname, $dbuser, $dbpw);
  $db = mysql_select_db($database, $connection);
  $sql = "SELECT owner_id, object_id FROM turba_objects WHERE 1";
  $result = mysql_query($sql);
  $myrow = mysql_fetch_array($result);

  while ($myrow != "") {
    $owner = $myrow['owner_id'];
    $object = $myrow['object_id'];
    $owner2 = str_replace('@wlg.nl','',$owner);
    $sql = "update turba_objects set owner_id = '$owner2' \
          where object_id='$object'";
    echo "$sql \n";
    $result2 = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
  }
?>
------------------

I am not sure about the second $sql line. Put it on one line.

With regards,
Paul van der Vlis.




-- 
http://www.vandervlis.nl/



More information about the turba mailing list