Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Seeking Flex-Objects CRUD tutorial (PHP)

Started by Tony Shaw 3 years ago · 6 replies · 601 views
3 years ago

Where can I find online PHP code snippets (e.g. a tutorial) for performing various CRUD operations on a flex-object "record"?
Bonus points if the tutorial also addresses how to "join" 2 flex-objects and query the result.
Thanks in advance.

3 years ago

@boatful, Did you have a chance to read the docs on Flex Objects and try the demo using 'Contacts'?

Bonus points if the tutorial also addresses how to “join” 2 flex-objects and query the result.

You're using RDMS terminology, but Flex Objects is not some kind of relational database...

3 years ago

Let's focus on PHP/CRUD syntax.

  1. How (in php) does one lookup a single item/record in a flex collection and then a) update or b) delete that item/record?
  2. How (in php) does one create a unique/new item in a flex collection?

The PayPal IPN listener I'm building needs these capabilities and I'm looking for PHP code snippets to point the way.

Thanks.

3 years ago

@boatful, Let's focus on my previous question first: :-)

Did you have a chance to read the docs on Flex Objects and the demo using ‘Contacts’?

And I would like to add: Did you have a chance to search this forum?

The PayPal IPN listener I’m building needs these capabilities

Does this really need to be implemented in Flex? Do you have (tens of) thousands of objects to manage?

👍 1
last edited 04/30/23 by pamtbaau
3 years ago

@pamtbaau is there an alternative to Flex Objects for simpler structures? I want a structured and standard way to interact with data in my back-end, and an API (with a custom Plugin) to define relationships between the data, is there a simpler way to do it, other than Flex Objects?

3 years ago

@CuriousCI, If your "simpler structures" can be stored as Yaml or Json and you don't need thousands of objects, then a simple flat file would probably suffice.

and an API (with a custom Plugin) to define relationships between the data

That sounds like a feature of a relational database, which flat files and Flex are not. However, you can use an RDBMS.

👍 1
3 years ago

The README.md file for the GRAV Flex Objects Plugin states, in part: "...both objects and collections can be customized by PHP classes, which allows you to define complex behaviors and relationships between the objects."

https://github.com/trilbymedia/grav-plugin-flex-objects#readme

This suggests to me that one-to-one and/or many-to-one relationships could be defined and employed for 2 related collections or objects. Could (for example) the unique username for persons in the user/accounts collection by used to link to data stored in a separate DIY user/phones collection (a potentially many-to-one relationship)?

I am afraid to alter the OEM blueprint for the user/accounts collection itself, afraid that any future updates to the GRAV login plugin could wipe out the OEM blueprint I took it upon myself to customize.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 56 13 hours ago
Support · by Anna, 3 days ago
2 61 16 hours ago
Support · by Justin Young, 17 hours ago
1 32 17 hours ago
Support · by Duc , 1 week ago
2 66 5 days ago
Support · by Colin Hume, 1 week ago
2 59 5 days ago