Jump to content
mrjasongorman

Processwire Data Objects

Recommended Posts

I have a friend who uses Silverstripe, and he was telling me about the Data Objects and the ORM it uses, for things like "has many", "one to one", "one to many" relations etc.

Maybe i'm not thinking about things correctly, but in the Processwire world, would a Page essentially be a data object?

Just want to get my head around how to think about structuring a web application in Processwire.

I'm familiar with traditional MVC (rails, code igniter) based structures.

The API may already enable this kind of functionality, but i was wondering if not, would Processwire ever get an ORM? or can an ORM be bolted onto Processwire?

If anyone could help me figure this out that'd be great.

Thanks

Share this post


Link to post
Share on other sites

If I understand that right (never used any of those cms's / frameworks) than you should look at WireArray and WireData. These are the basic building blocks of ProcessWire and are basically the single and multi-entity data blocks. All other Datatypes build on this e.g.:

  • User > Pagetype > Page > WireData
  • PageArray > WireArray
  • ….

But I don't know of any specific "one to one" or "has many" relation, while "one to many" is just done by hierarchy (FieldtypeWrapper (Field) -> children (FieldsArray)).

  • Like 1

Share this post


Link to post
Share on other sites

Page field is one to many or one to one relationship, depending on how it is configured.

Share this post


Link to post
Share on other sites

Over time we have often had discussions about the nature of Pages and the fact that the term 'Pages', in context of ProcessWire(PW), can be misleading. Pages can represent a lot of things and serve multiple goals.  (fun read: https://processwire.com/talk/topic/2296-confused-by-pages/ )

You are right that Pages can be seen as (URL accessible) data objects. What data a particular Page can hold is defined via the page his Template and the Fields added to that template. So a Template can, amongst other things, be seen as a data model.

ProcessWire has its own way of organizing and relating data. While the underlying database structure might be different than most MVC-ish systems, the Page tree and the Page fieldtype allow for really flexible ways of achieving most, if not all, of the traditional model associations like in Rails' Active Record. Finding and working with pages/data couldn't be easier thanks to the great API, so i don't think there is a need for an 'ORM' because in a way PW already has this.

  • Like 4

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By skoskie
      Hi. I'm working on building my first processwire site, and I want to make sure I'm getting it right. I'd appreciate any feedback. 
      I have a `vendor.php` template/model that will contain companies.
      I need to give users the ability to rate (1-5) that vendor. So I think I need to build a `vendor_rating.php` model/template  with fields `rating` (int), `user` (ref), `vendor` (ref), and perhaps a textarea for `review`.  Then, in the vendor template I will call and cache the average vendor rating for display. I don't actually want to display the individual ratings anywhere, so I guess I still need to figure out how to do an ajax call from the front end. 
      ###
      Here's the thing. This structure is almost identical to "comments" with only one extra field for the `rating`. So should I just extend that in some way? Or stick to my current path and make a new model/template?
      Thanks!
       
    • By DooM
      Hello guys,
      I'm trying to figure out how to sync fields and templates between staging and production environments.
      I've found Migrations module by Lostkobrakai, but with use of it all the fields and templates must be created by API, which is kind of uncomfortable.
      I also tried ProcessDatabaseBackups module which can export only certain tables, but I don't think it's the best practice to do that.
      How do you guys solve this problem? It's very annoying to setup everything three times (dev, staging, production).
      Thanks a lot :)
    • By iipa
      Hi everybody!
      I have been reading about Multisite, but it kinda bugs me that every topic talks about having both admin and database same for multiple sites.
      I have a project where customer tests it by adding content to the site, while I still need to do some changes here and there in code, maybe some in database. If something crashes for a while, customer can't keep testing, which is a bit problematic.
      Is there any way that I could have two separate versions of one site ("production" and development) that share the same database, but are otherwise independent? Just the thought of having to migrate database every time I want to show client something new gives me anxiety 😁
    • By Falk
      Hi!
      After temporarily using Module Image Extra, which I completely removed, I had some troubles with my imagefield (unused table columns).
      So I just imported a previous version of this column via PHPmyAdmin, which worked pretty well.
      Anyways, in Processwire Backend all image tags are gone, although they are OK in the database.
      Other image related things work (thumbnail, title etc are OK).
      Is there any way to recreate all the images or something? Or may this be an cache-related issue?
       
      Thanks in advance 😃
       
    • By anttila
      We have many booking calendars made with ProcessWire (own databases) and I want to do a web app (SQL) which allows user to log in. First, the user chooses the right calendar and then (s)he have to log in. The user can be from any of those calendars and the app is not running on ProcessWire (it can if necessary). So if there any way to make sure that the user has rights to the calendar (s)he tries to log in and if the password is correct.
      Is there any better way to do this? I could also use PIN codes or something, but those need to be encrypted too.
      Multiple ProcessWires A lot of users per ProcessWire Everyone can log in to the web app (when using right calendar)
×
×
  • Create New...