Reverse Engineer existing table

6 views
Skip to first unread message

tp

unread,
Mar 10, 2006, 4:19:31 PM3/10/06
to Php Object Generator
Hi,

Does pog have a script for reverse engineering an existing table e.g. I
have a table in my existing mysql db with a gazillion attributes
(fields) which I would like to pogify.

So I run a form where I pick my table and a script then runs which
creates an @link tag which takes me to the pog site and generates a pog
object for my table.

Sorry if it has been asked before: I had a quick search but couldn't
find anything on this.

Cheers
TP.

Joel

unread,
Mar 10, 2006, 5:00:08 PM3/10/06
to Php Object Generator
Hi,

unfortunately, no such thing exists right now. but if you ever
write/find something that does it, feel free to send it to us. this
could indeed be very useful to other users as well.

Thanks
Joel

Joel

unread,
Mar 10, 2006, 5:15:04 PM3/10/06
to Php Object Generator
Thinking about it now, this would be an excellent scenario to use the
SOAP API. Instead of generating the @link, it would simply generate all
the objects in 1 step.

http://groups.google.com/group/Php-Object-Generator/browse_frm/thread/0c71c3a79a70c14d

eda...@gmail.com

unread,
Mar 15, 2006, 4:37:30 PM3/15/06
to Php Object Generator
Hie...

Im new to POG, and I must say that it's an incredible idea....

Congratulations!!!


Now I'm developing a script that use the "object" object than will do
that...


When It's done I will send you


Thanks a lot for the great job


And sorry for my English! ;)

tp

unread,
Mar 17, 2006, 6:46:24 PM3/17/06
to Php Object Generator
Look forward to it.

I've got a whole database here waiting for pog :)

Cheers,
TP

Sean

unread,
Mar 29, 2006, 8:38:08 AM3/29/06
to Php Object Generator
Before discovering POG (which is great BTW) I was trying to convert a
similar class designed for PHP5 to something that would work with
previous versions of PHP. One of the things I ended up having to do was
create a seperate class/function that took the structure of my database
tables and export them into an XML schema file. Before I finished
converting the class I found POG and decided that the features in POG
were greater than he class I was trying to convert.

Anyhow, I was reading the API guide last night and was playing around
with this exact issue. I think that I can tweek my XML function to work
with POG so that you can use your existing database tables and pass
them directly to POG. I need to play with the API a bit, but I'm
working on this

Once I have it ready for testing, where should I post it? Also, if
anyone cares to help out a bit let me know.

sean [at] savetheorcas.org

Joel

unread,
Mar 29, 2006, 9:57:11 AM3/29/06
to Php Object Generator
Hi Sean,

that's a great idea... and i think there'll be many ppl who'll find
this useful.

I'd be very happy to help if you have any issues regarding the SOAP
api, having worked with it myself... please post any issues/question to
this thread if you have any.

Once you have it ready for testing, you can zip it and send it to us
directly at pog...@phpobjectgenerator.com

Thanks again.

Joel

Sean

unread,
Mar 29, 2006, 10:33:35 PM3/29/06
to Php Object Generator
Hmm, I've run into a problem. I'm coding this hack so that users can
simply enter in their database details (host, username, password, etc)
and the hack will list out all the users databases so they can quickly
POGinze multiple databases. They can also select the POG variables to
use (which version of PHP they are using, etc).

I'm designing the hack so that it will work for everyone without
knowledge of PHP. So, there are multiple options for generating the
objects. One option will use the SOAP feature described in the API.

The other option, where I'm having the problem, simply creates an @link
link to the POG website. I almost have this working properly, but I
can't figure out what the following code is from the API sample (and
from looking at my own @link link in my POG objects).

WHERE attributeList=array+%28%0A++0+%3D%3E+%27

What is the true value of this code? I've tried to decode it, but
nothing. This code apepars throughout the @link string. If I can figure
out what this it, I can get this working.

Thanks
Sean

Joel

unread,
Mar 29, 2006, 11:03:52 PM3/29/06
to Php Object Generator
Hi Sean.

your 'hack' seems pretty cool indeed,

the POG @link is urlencoded. To decode it and see what it looks like
use this to decode any @link:

http://www.albionresearch.com/misc/urlencode.php

the important parts of the @link is the attributelist as you mentioned
and the typelist variables, which are string representation of arrays
obtained by var_export. (http://ca.php.net/var_export)

hope this helps.

Joel

Sean

unread,
Mar 30, 2006, 12:14:04 AM3/30/06
to Php Object Generator
Yes, it helps alot. Not that I have a starting point I'll play around
with implementing the urlencode function.

With any luck I'll have the @link generator available by tomorrow. It
won't look pretty, but it will functional so that people can start
using while I add the other features and attempt to add a GUI that
matches the current POG template.

I've run into another problem with the SOAP function of the hack -
actually it's more of a problem working with arrays within the class
that loops through the database and extracts all the tables. I'm
working on it though.

I can't tell you how much I LOVE POG!! I'll have to post a short
description of what I've been through trying to get other objects like
this to work. I was using another open-source class which worked for a
while, then it just stopped working and corrupted my database.

I'll email you later tonight with the package.

sean

Joel

unread,
Mar 30, 2006, 1:22:51 AM3/30/06
to Php Object Generator
looking forward to seeing your project.

don't worry about the interface too much, if we have time, we can try
adding it to the setup interface later on.

however, i thought a little bit about the functionality you're
implementing: i can foresee 2 needs coming up pretty soon because of
POG's own shortcomings currently:

- the POG API needs to let you disable encoding/decoding, and it's
currently not available yet.
- the POG API needs to let you generate objects with non-lower case
tables.

these 2 requirements will occur because users with existing tables will
have data that's not encoded and might have tables with non-lower case
names. So, we'll work on those asap and squeeze those in for 2.0
release

thanks again.

Joel

Sean

unread,
Mar 30, 2006, 3:57:39 AM3/30/06
to Php Object Generator
I can probably create another function that can automatically convert
all the users database content into the encoded format. Once they use
the class I'm working on to generate their code, they can run an
addition script that will loop through all the records sets in the
table and convert all non-numeric data to the base_64_encoded format.

The only disadvantage to this would be that this could take a while if
there are lots of records to loop through. I would imagine that one
could also write in an "elseif" function that could be added to the POG
database class where POG would convert the data as it's called. In
other words, when a record is called from the POG CRUD class, it would
check to see if the data is encoded, if it's not the elseif clause
would kick and encode the content.

I'll have to look into this further to see if this would work.

Nonetheless, I'm making some great progress on the hack. You'll
probably have it tomorrow afternoon.

Sean

Sean

unread,
Mar 30, 2006, 4:57:59 PM3/30/06
to Php Object Generator
I got the @link function working almost perfectly until we get the to
the typeList variables. The link populates the phpobjectgenerator site
with all the right field names, but produces the following error:

Parse error: parse error, unexpected '\'' in
/home/phpob/public_html/index.php(36) : eval()'d code on line 1

The actual values for the attribute types are replaced with "a", "r"
... in each of th form fields, spelling out array.

I'm working on this. I did get it to where it worked but it populated
all the attribute types as VARCHAR(255) and not the actual values from
the database.

Sean

Sean

unread,
Apr 1, 2006, 5:17:31 PM4/1/06
to Php Object Generator
Joel,

Just wanted to give you a status update. I got things working pretty
well as far as the auto-generation is concerned. I'm still working on
some other features. I didn't occur to me at first, but after reading
your post, I realized that in order for this script to be useful to
most people, it needs to convert their existing data to the encoded
format. Otherwise, this extension is only going to be useful for
creating new database objects, which can already be done easily through
your site.

I'm currently working on a conversion function that will do the
conversion automatically. Since we're talking about working with live
databases, and since there's always the chance that something can go
wrong, the script will make a copy of all the tables in the database
and work on the new tables only, thus leaving the original data in
tact. The script will then encode all the non-numeric data and
interface with POG API to create the object files.

Of course, the simplest solution would simply be to comment out the
encoding functions within POG, but I personally thing that the
advantages of encoding far outweighs the need for simplicity.

I'm going to start uploading my nightly builds of what I have so far to
my website for people here to take a look at things make suggestions.
I'm working on this full-time, so hopefully the script will be
available to everyone shortly.

Sean

Joel Wan

unread,
Apr 1, 2006, 9:20:58 PM4/1/06
to Php-Object...@googlegroups.com
hi sean,
 
yes, there is indeed the solutions you mentioned. there is also however a second simpler solution that is almost complete on the POG API as well. while using the POG api, you can specify you don't want encoding, and it will automatically "comment out" the encoding/decoding on POG's side.
 
I will give you more inforamtion about this very shortly. You can then consider this as an alternative solution. then you don't need to mess with data as things can indeed go wrong that way.

reidab

unread,
Apr 2, 2006, 7:53:30 PM4/2/06
to Php Object Generator
This is very exciting and exactly what I'm looking for for a project
that I'm working on at the moment. One thing that I see as a possible
problem that may need to be addressed (since i haven't seen it
mentioned here yet) is that POG seems to be set up to deal only with
lowercase table and column names. When creating objects from existing
tables, this conversion should probably be disabled.

Joel

unread,
Apr 2, 2006, 8:10:13 PM4/2/06
to Php Object Generator
correct. we'll need to address this soon.

Reply all
Reply to author
Forward
0 new messages