Data transformation

Discussion in 'PHP' started by stephan2307, Dec 13, 2011.

  1. #1
    Hi,

    Right this is what happened so far

    I need to get data from an old system which runs on pervasive sql to a new system running on mysql.

    So via a odbc link I exported the tables from the pervasive sql to mysql database.

    Now I need to write a script which takes the data and puts it into the new system. While doing this I ran into an issue.

    The old system has a credit limit field. When looking into the mysql db there are 2 fields called cuCredLim_1 and cuCredLim_2. The values they should hold make no sense ie 137 and 2046820352. cuCredLim_1 is smallint(6) and cuCredLim_2 is int(11).

    Now this is where I am at.

    I found out that the way they save the data is called split integer or similar.

    I have found a way to transform it to a normal int or float but it is not in php and I don't understand it.

    Here is the link.
    https://www.dbforums.com/pervasive-sql/1670684-convert-split-integer-currency-value.html

    can anyone convert the code they show on that page to php?

    Thanks
     
    stephan2307, Dec 13, 2011 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    That article is referencing functions that don't exist in php so it definitely wont work without being able to see the source of those. Also, from what I can tell, the data storage is in reference to how the integer is stored in memory. I can't even find any solid reference explaining how to perform a conversion. When you access the database via ODBC are you able to pull the actual integer values? I would probably post this question on stack overflow. This is way beyond the scope of most php programmers that don't have experience with pervasive and or this specific method of storing data in reference dis disk or memory.
     
    jestep, Dec 13, 2011 IP
  3. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #3
    I did some research and I think the functions do exist but they are slightly different. While BINTOC and CTOBIN accept a flag (I guess equivalent to parameter in php) while the php functions don't have second parameters.

    BINTOC => decbin
    CTOBIN => bindec

    also just found base_convert which might be what I was looking for. but need to run some tests first.
     
    stephan2307, Dec 13, 2011 IP
  4. tiamak

    tiamak Active Member

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    58
    #4
    there are no bin2oct nor oct2bin functions in php but you can do binary to octal (and vice versa) conversion with base_convert() function (see php manual)
    this should be what you are looking for or at least should give you a good start
     
    tiamak, Dec 13, 2011 IP
  5. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #5
    We are not talking about octal. look at my last post.
     
    stephan2307, Dec 13, 2011 IP