Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@P2GR
Copy link
Owner

@P2GR P2GR commented Nov 21, 2025

No description provided.

Copy link
Collaborator

@jamieburchell jamieburchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a mix of camel case and snake case property and method names. E.g. in the HasTimestamps trait, but in other places too.

Personally I only have a couple of legacy CI3 projects left now that use Datamapper, so I probably won't be updating them to support the new features (I'm careful not to blindly use from_array() for example) but if I do get an opportunity, I'll see if any of the changes break one of my existing sites.

@P2GR
Copy link
Owner Author

P2GR commented Nov 24, 2025

@jamieburchell The 2.0.0 update is meant to bring the DataMapper more in-line with more modern ORMs (e.g. Eloquent).
This mainly because we still have one big project relying on CI3 and DataMapper, migration is planned for the future but that's going to be one hell of a job.

Getting DataMapper updated to support new features found in modern ORMs is therefor quite beneficial for us, and maybe a few others as well.

I've ran some tests with the new datamapper on our project and we've found it's a drop-in replacement for the older 1.8.3.3 version. Allowing us to these modern features found elsewhere without having to rewrite our whole project... yet.

I'll fix the issues you've mentioned. and thanks for taking the time to do some tests on your end :)

@jamieburchell
Copy link
Collaborator

Wondering if the trait filenames should be snake-case too, or is that intentional due to how composer is loading them?

There's more camel case method and property names in DMZ_FileCache, DMZ_MemcachedCache, DMZ_RedisCache and DMZ_LazyCollection

Aside - can you help me understand with() vs. include_related() ?

@P2GR
Copy link
Owner Author

P2GR commented Nov 25, 2025

@jamieburchell
include_related() leaves everything in one big join, which can slow down big result sets and copies the related columns straight onto the parent model.

with() runs separate focused queries for each relation, gives you full related objects, and lets you add filters per relation. Its usually quicker unless you really need the flattened columns that include_related() spits out.

Trait filenames should be good as-is, composer currently has no issue autoloading them.

@jamieburchell
Copy link
Collaborator

jamieburchell commented Nov 25, 2025

Giving this a spin now in an existing project.

Just realised my lib file is Datamapper.php not datamapper.php - I just had both co-existing in Linux with only the former (old) being used.

I remember having to go through an exercise between CI2 and 3 to make controller/model/library file case consistent. Wondering if this should be changed here too?

@P2GR
Copy link
Owner Author

P2GR commented Nov 25, 2025

@jamieburchell I'm noticing the same on my end now funnily enough.
our linux environment has Datamapper.php and my windows environment has datamapper.php
But i've not noticed any issues with this.

@jamieburchell
Copy link
Collaborator

jamieburchell commented Nov 25, 2025

In Linux, I have to rename it to Datamapper.php otherwise CI won't load it:

Unable to load the requested class: Datamapper

@jamieburchell
Copy link
Collaborator

CI3 comes with an inflector_helper. does DM need its own?

@P2GR
Copy link
Owner Author

P2GR commented Nov 25, 2025

@jamieburchell inflector_helper is there mainly for the tests. native CI3 inflector_helper will load properly and take over when it's available due to the if (function_exists()) calls inside the DM one.

@jamieburchell
Copy link
Collaborator

jamieburchell commented Nov 25, 2025

I gave it a quick test in an existing CI3 DM project and no smoke came out of anywhere :) If my understanding of the code changes is correct, it seems that there shouldn't be any BC changes and this is an opt-in type setup.

Your new examples and use of method chaining and using with() has me pondering how I have previously got around the N+1 problem in my projects. I just found this in my code:

$users = (new User)
	->include_related('manager', array('first_name', 'surname'), true, true)
	->include_related('department', array('name'), true, true)
	->order_by('first_name')
	->where('active', 1)
	->get_iterated();

Still uses method chaining, instantiates the related manager and departments, only one query, and iterators are used. I guess the smaller focuses queries are quicker 🤷

@jamieburchell jamieburchell self-requested a review November 25, 2025 15:58
Copy link
Collaborator

@jamieburchell jamieburchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was me thinking this project was on life-support - and you go and pull this out of the bag. Good job. I can see a lot of thought and work has gone in to this.

My testing has just been on current usage and not using any of the new methods/layers and as far as I can tell there are no backwards incompatible/breaking changes from the quick tests I have done

@jamieburchell
Copy link
Collaborator

jamieburchell commented Nov 25, 2025

@P2GR I think there are lots of extra lang files in nl that aren't related to DM? The index.html in english could be dropped too.

Lennart added 2 commits November 26, 2025 10:18
…pdate DataMapper to log when missing; rely on delete_pattern()/get_stats() across all drivers.
@P2GR P2GR changed the title 2.0.0 beta1 2.0.0 Dec 3, 2025
@P2GR P2GR self-assigned this Dec 3, 2025
Lennart added 13 commits December 4, 2025 10:37
- Remove get_smart() from DMZ_QueryBuilder (unused sugar)
- Remove pluck_collection() from DMZ_QueryBuilder, DMZ_Collection, and DataMapper
- Remove pluck_values() from DMZ_QueryBuilder, DMZ_Collection, and DataMapper
- Change DMZ_QueryBuilder::get() to return model instead of DMZ_Collection
- Users wanting a collection should call collect() explicitly
- Update first() and get_array() to work with model return type
- Remove related test cases for deleted methods

API cleanup: reduces surface area and eliminates user confusion about
get() returning collections vs models.
- Document removal of get_smart(), pluck_collection(), pluck_values()
- Document QueryBuilder::get() now returns model instead of collection
- Update collections.md Query Builder Helpers section
- Update quick-reference.md examples
- Add shared dmz_camel_to_snake() helper function
- Update DMZ_QueryBuilder and DMZ_Collection to use shared helper
- Update DataMapper._camel_to_snake() to delegate to shared helper
- Remove deprecated with_deleted(), only_deleted(), without_deleted() aliases
- Remove deprecated _dm_with_deleted and _dm_only_deleted properties
- Remove legacy property checks from querybuilder.php soft-delete scope
- Fix FIXME comment in get() method (silent behavior is intentional)
- Update all extension headers to version 2.0.0
- Fix dead overzealous.com links to github.com/P2GR/datamapper2
- Fix typo in rowindex.php header (worIndex -> rowindex)
- Update CHANGELOG with all changes
- Add debug() to DataMapper and DMZ_QueryBuilder
  - Returns: model, table, SQL, result count, execution time
  - Pass FALSE to pretty-print output with syntax highlighting

- Add benchmark() to DataMapper and DMZ_QueryBuilder
  - Returns: total queries, total/avg time, memory usage, per-query breakdown
  - Optional since_query_index param to measure specific operations
  - Color-coded output: green (<10ms), yellow (<100ms), red (>100ms)

- Add get_query_index() helper to mark benchmark starting points

Usage:
  \ = \->get_query_index();
  \->with('posts')->where('active', 1)->get();
  \->benchmark(FALSE, \);  // Pretty-print benchmark

  \ = \->debug();  // Get debug info as array
- New docs/guide/datamapper-2/debugging.md
- Covers debug(), benchmark(), get_query_index(), to_sql()
- Add to sidebar and top nav in VitePress config
Users attempting nested eager loading inside a constraint callback now get
a clear error explaining to use dot notation instead:
  ->with('parent.child') instead of ->with('parent', fn(\) => \->with('child'))
- Update quick-reference.md with new debugging methods
- Add Debugging card to DataMapper 2.0 feature grid
- Add Debugging row to comparison table
Add explicit constructor to ensure property initialization works
consistently across PHP 8.1-8.5 versions in CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants