Thursday 10 February 2005 10:05:26 am
I have looked for an answer to this, and I have found snippets here and there, but nothing comprehensive. I have a promise for anyone who helps me answer this -- read to the bottom of the post. I need to import several hundred records from a flat, "traditional" database table to eZ publish. Consider a normal database table with these columns:
FirstName
LastName
Title Bio For each record in this table, I need to create an object in eZ from a custom class -- Person. Then I need to transfer the contents of each cell to attributes on that object and store it. For now, let's say all the datatypes are simple text datatypes. So my object looks like this:
Person
-> FirstName
-> LastName
-> Title -> Bio Some assumptions:
-- All objects will have the same node assignment (they'll be in the same folder in the tree)
-- All objects will have the same user as their owner
-- This is a one-time import -- I want to run this script from the command line Please know that I have looked for answers. I have the book, and there's a section starting on page 136 that covers the code. You can download this code as a script called "create.php". Sadly this script keeps dying when it tries to instantiate the user. I'd fiddled with it as much as possible, but it will not return a user from the "fetch" method, so the whole things comes apart there. (What bothers me is that I don't need the user. From what I can tell, I just need the user ID, which I have as an integer. Why do I need to go to all the trouble of instantiating the user just to get their ID when I have to provide the ID to instantiate the user in the first place? I have what I need already.) I found another thread on these boards here: http://ez.no/community/forum/developer/inserting_article_through_code_problem This person is having another problem with this. In this script was some code for adding a folder, but I couldn't get that to work either. I've been working at this for three hours now, and I'm no closer than I was. This strikes me as (1) a pretty common operation, and (2) a barrier to entry for new users. I'm sure some people have turned away from eZ because they didn't think they could get their data in easily. (They're right, it turns out.) I believe in what this guy wrote here: http://forum.ezpub.co.uk/showthread.php?p=326#post326 "Are those who know how to use eZ publish 3 are too busy to write usefully use case documentation, provide example source code for custom solutions ... It just seems that most people don't contribute back entire solutions which implement the same key changes that just about every user must figure out, implement, and over come in order to configure eZ publish for use in a production web site." I believe in community, and I believe in giving back when someone helps you. So, my offer is this: if someone helps me to what I'm trying to do above, I will write an import script and documentation. I will document the crap out of the code and make it utterly, crystal clear to newbies how they can get their data out of Access or some other flat database table and quickly and easily turn it into objects in eZ. I'm a pretty decent writer, and I have no doubt that if I can understand it, I can get other people to understand it too. Will someone please take me up on this? Deane
|