Jump to content

Processwire ORM


cssabc123
 Share

Recommended Posts

Several ways. I'd suggest thinking about how best to represent the data using Processwire's Templates, Fields, Pages (specific PW terms) and then write a script to use the API to read your existing data and build those PW pages. It can have a very relational database feel to it and have tree-style hierarchy available too.

There also are various ways to incorporate a separate database table (look in modules, fieldtypes, etc.).

If that dataset has to stay where it is (maybe something else maintains it) you could use PW's very flexible API to interface to it. Wrap all your back and forth logic up in a module. Maybe hook into some Page functions to make it seem more built in.

  • Like 2
Link to comment
Share on other sites

Can you give example or at least tell me what those APIs are in PW?

Not APIs, API.

Hopefully I don't sound too rude (in a bit of a hurry here), but please check out the docs section. It's all explained there. In addition to that, I'd suggest taking the time to browse through some of the tutorials, in case you prefer a hands-on approach.

The kind of questions you're asking here are perfectly understandable from someone just getting started with the system, but it also sounds like you haven't really bothered checking out the docs either. Also, the forum is filled with answers to very similar questions, so you might want to try looking around a bit.

To be fair most of your current confusion seems to stem from not understanding many of the basic concepts of ProcessWire, including how it handles content and content types. While it's a bit outdated by now, Ryan's excellent overview video is still a very good starting place in this regard; the UI will look different from what you'll see on your site and your site will have more options and settings to play with, but the basic concepts are the same.

  • Like 8
Link to comment
Share on other sites

  • 2 weeks later...

Hi, I'm also looking into this. I've built a handful of small websites using ProcessWire, so I think I have a pretty good grasp of the "ProcessWire Way".

But I think this is still a valid question when you're thinking of building an application with a large back-end. I'm currently looking to build a loyalty/marketing campaign platform for a medium sized company with possibly 100,000+ users and thousands of rows of data being entered daily, and I think it makes sense to store the data separately from the PW tables, especially because exporting the data to other forms (for paperbased reports, charts, etc) is one of our biggest concerns.

I know the $db exists, but I was hoping to save some time and sanity by going ORM. I'd like to know if some of the veterans here have any input or experience in doing this. I was playing around with Propel (http://propelorm.org/) and thinking of using it with ProcessWire, and see where it goes.

Or, is it really 100% better to stick with pages+templates to maintain a database of this size?

As always, thank you wonderful people of ProcessWire. :)

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Greetings,

Responding late to this one, but I think it's a good discussion, and may help bring more people into the ProcessWire world!  I like Propel, and have often used it as my comparison for other systems.  In fact, I often look at Propel and think, "How do we do this in ProcessWire?"

Propel is a great ORM.  A lot of Propel's CRUD functions are handled with ProcessWire in a similar fashion. Think of ProcessWire's $page and $pages elements as the equivalent of the query functions in Propel.  ProcessWire essentially slims down the database calls into more readable elements.

So in Propel you do this:

$author = AuthorQuery::create()->findOneByFirstName('Jane');

In ProcessWire you do this:

$author = $pages->find("parent=authors, FirstName=jane");

In Propel you do this:

$authors = AuthorQuery::create()->find();
foreach($authors as $author) {
  echo $author->getFirstName();
}

In ProcessWire you do this:

$authors = $pages->find("parent=authors);
foreach($authors as $author) {
  echo $author->FirstName;
}

There are other examples, but I think this gets the idea across.

Thanks,

Matthew

Edited by MatthewSchenker
Correction based on Macrura's point below.
  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...