UFront-ORM table creation...and what and where is UFAdmin?

81 views
Skip to first unread message

aheatedatom

unread,
Oct 29, 2014, 5:33:27 PM10/29/14
to haxe...@googlegroups.com
I'd like to create a haxe application, for the PHP target, that manages a mySQL database.

Ufront-ORM looks ideal for what I'm trying to accomplish, but I've been confused by the bits of documentation scattered between comments, the "old" haxe website, github, and so on.

I would like to model my data in haxe and generate the tables programatically.

I created two simple objects extending ufront.db.Object.  They have a many to many relationship to each other defined as per the bit of docs on the ufront-orm git page.

So far, so good.  But how do I create the tables?  There's bits of talk about "UFAdmin", which sounds lovely.  But google doesn't turn it up.  Haxelib install ufadmin reports no such library.  Searching github for UFAdmin does not turn it up.  Where is it, how do I get it, does it work with php?  (And on a related note- lots of mentions of 'clientDS' - but what's that?  Where do I get it?  Again, can't find it on haxelib or elsewhere...)

Giving up on that for a moment, I inspected the code in the ufront hello world and copied some relevant bits from the tasks to create the tables.  It looks like this:

var cnx=Mysql.connect({
host:"localhost",
port:null,
user:"uftestuser",
pass:"test",
database:"uftestdb",
socket:null
});
Manager.cnx=cnx;
CompileTime.importPackage("uftest.model");

for (model in CompileTime.getAllClasses(Object))
{
var manager=Reflect.field(model, "manager");
var meta=Meta.getType(model);

if (Reflect.hasField(meta, "noTable")==false && manager!=null && TableCreate.exists(manager)==false)
{
TableCreate.create(manager);
}
}
Didn't run at first, php target complained about missing meta functions - fiddled around with build settings and got it going.

Inspected my database after the functions above.  Excellent, two tables have been created for my two Objects!

But they have manytomany relations defined...so there should be a 'join table' also, but there isn't.  Makes sense, because iterating over the CompileTime.getAllClasses() isn't going to come up with a Join Table.

So what do I do?  How do I programatically get the database set up and ready to go completely based on my model?

Thanks in advance friends!

aheatedatom

unread,
Oct 29, 2014, 9:40:05 PM10/29/14
to haxe...@googlegroups.com
I'm making very slow progress creating the join table by hand.  I deduced from the source that it should be called _join_x_y and it must have two columns "r1" and "r2" that are foreign keys to the related tables.  but it seems to also need an id column.  so far I'm getting errors with the ManyMany parser, if anybody could point me towards code meant to create a join table for ufront-orm or show me the schema for one that would be super awesome!

Jason O'Neil

unread,
Oct 30, 2014, 9:26:07 AM10/30/14
to haxe...@googlegroups.com
I worked through this with Alex off list, but the short of it is I have now added:

ManyToMany.createJoinTable( aModel, bModel );

to use when you're not using "ufront-ufadmin".   See

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages