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!