Alexander Bokovoy wrote:

> [...]
> One unique feature of Repligard which I strongly wish to implement, is
> automatic  update  of  IDs  which  can  be  found in PHP scripts being
> transferred  via  Repligard. The issue is in unnecessary identical IDs
> in  different  databases.  Solution  is  to replace IDs with IDPs when
> dumping  and  replace  them  vice  versa  when  other database will be
> updated. It requires lookup table for ID and IDP correspondence but we
> already  have  it as repository. The main trick is to scan script body
> and  change  all  occurrences  of  mgd_xxx  functions  with  exact  ID
> arguments  by  their  portable equalents. For example, suppose we have
> the following script:
>
> <?php
>   $topic=mgd_get_topic(15);
> ?><h1>&(topic.name);</h1><?
>   $articles=mgd_list_topic_articles($id);
>   while($articles && $articles->fetch())
>   {
>     ?><b>&(article.title);</b>: &(article.abtract);<br><?
>   }
> ?>
>
> It  will  be  changed  like  this one (the real syntax for writing IDP
> inside PHP scripts will probably differ):
>
> <?php
>   $topic=mgd_get_topic(<<@@a65a65a7fae72919283cba3b2@@>>);
> ?><h1>&(topic.name);</h1><?
>   $articles=mgd_list_topic_articles($id);
>   while($articles && $articles->fetch())
>   {
>     ?><b>&(article.title);</b>: &(article.abtract);<br><?
>   }
> ?>
>
> The  only  problem  which  still  remains  unsolved is when real ID is
> assigned  to  some  variable  first  and  the  latter one is used as a
> reference  later.  But  I  don't  see  any  solution  for it, and this
> technique is not good anyway.
>
> I would like to see any comments for Repligard behaviour.

To solve this problem, we can use a function mgd_xxx_id.
Like:
<?php
  // this defines $id as a topic id
  $id = mgd_topic_id(15);
  $articles=mgd_list_topic_articles($id);
?>
replicated to:
<?php
  $id = mgd_topic_id(<<@@a65a65a7fae72919283cba3b2@@>>);
  $articles=mgd_list_topic_articles($id);
?>
with:
<?php
  function mgd_topic_id($id) {
    return $id;
  }
?>

Backward compatibility cannot be assumed without small changes.




--
This is The Midgard Project's mailing list. For more information,
please visit the project's web site at http://www.midgard-project.org

To unsubscribe the list, send an empty email message to address
[EMAIL PROTECTED]

Reply via email to