cssabc123 Posted September 28, 2015 Share Posted September 28, 2015 Does Processwire have a built-in ORM if not what is the recommended ORM for it? Link to comment Share on other sites More sharing options...
felix Posted September 28, 2015 Share Posted September 28, 2015 No need for ORM. Processwire's way is to build your Model using Pages and Templates. 1 Link to comment Share on other sites More sharing options...
cssabc123 Posted September 28, 2015 Author Share Posted September 28, 2015 What if I have a large dataset already that I need to access/fetch then render in html? How do I access records in that database and render in html? PDO or ORM? Or is there a Processwire way? Link to comment Share on other sites More sharing options...
SteveB Posted September 28, 2015 Share Posted September 28, 2015 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. 2 Link to comment Share on other sites More sharing options...
cssabc123 Posted September 28, 2015 Author Share Posted September 28, 2015 Can you give example or at least tell me what those APIs are in PW? Link to comment Share on other sites More sharing options...
teppo Posted September 29, 2015 Share Posted September 29, 2015 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. 8 Link to comment Share on other sites More sharing options...
alxndre Posted October 13, 2015 Share Posted October 13, 2015 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. 1 Link to comment Share on other sites More sharing options...
MatthewSchenker Posted October 26, 2015 Share Posted October 26, 2015 (edited) 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 October 26, 2015 by MatthewSchenker Correction based on Macrura's point below. 3 Link to comment Share on other sites More sharing options...
Macrura Posted October 26, 2015 Share Posted October 26, 2015 echo $author->FirstName(); echo $author->FirstName; just curious - in PW the field usually doesn't have arguments (?) Link to comment Share on other sites More sharing options...
MatthewSchenker Posted October 26, 2015 Share Posted October 26, 2015 Greetings, Thanks Macrura -- I fixed that! Thanks, Matthew Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now