Menu

help with prefix

Help 2.02
galati
2004-09-20
2013-04-08
  • galati

    galati - 2004-09-20

    need to install phpay and use prefix for table name, i know i have to modify the source but i don't know if phpay supports prefixes.

    i tryed to modify in db_func.inc.php prefix="";

    and added prefix to table name in create_db.inc.php ...

    i have an error table phpay.currency it's not created

    if someone worked with prefix pls help and if you have any ideas ...

     
    • Andreas Kansok

      Andreas Kansok - 2004-09-20

      Prefix is only  a little bit supported by phPay.
      Lot of changes have to be done by hand.
      First is to set $prefix in db_func.inc.php (dont forget to change file in admin dir too).

      Creating tables:
      Either you change all table names in create_db.inc.php
      or you create tables without prefix and renames them with phpMyAdmin or similar.

      Regular Expression is not perfect to replace tablenames with prefix+tablename. In some queries you have to add space or tablename to make it work.

      In some cases, too much is replaced or not enough. It will be a could idea, to use only phPay's WITH prefix in one database.
      Otherwise it my be happen, if replacing fails, tables without prefix are accessed. Some strange errors will appear ...

      This is a modified RE. I had good experiences with.
      foreach ($tables as $table)
      {
        if (ereg("\ ".$table, $query))
        {
          if ($table!="user") $query=preg_replace("/\ ".$table."(?!([a-z]|ID|gr|:|=|_))/"," ".TBL_PREFIX.$table, $query);
          else $query=preg_replace("/\ ".$table."(?!([a-z]|ID|gr|_))/"," ".TBL_PREFIX.$table, $query,1);
        }
      }

      Step by step I replace tablenames in SQL-queries directly with TBL_PREFIX."tablename", so RE isn't needed anymore. That's a lot of work ...
      May be you can use search&replace of a good texteditor to change all files in one step (Ultraedit can do it), but I don't thrust them ;-)

      Perhaps it is easier to rent another database ;-)

      Greetings,
      Andreas.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.