Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.1.0 - WIP #119

Draft
wants to merge 39 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5a4adb2
PR/115 - Recommendations from phpstan. (#118)
JJJ Aug 31, 2021
aeb83f6
Make booleans much better (#120)
szepeviktor Aug 31, 2021
d5fd271
Add composer.lock.
JJJ Aug 31, 2021
793ad1c
Merge branch 'release/2.1.0' of github.com:berlindb/core into release…
JJJ Aug 31, 2021
674764d
Merge remote-tracking branch 'origin' into release/2.1.0
JJJ Sep 8, 2021
5a1375d
Query: change the parameter order of private method transition_item()
JJJ Sep 9, 2021
15f8a3a
Create dynamic hook after an item is deleted (#133)
robincornett Apr 29, 2022
ec5452a
Merge branch 'master' into release/2.1.0
JJJ Apr 29, 2022
3be9949
Update composer deps.
JJJ Apr 29, 2022
5670fb5
Table: add support for table comment.
JJJ May 26, 2022
9bd5c4e
WIP - Issue/137 (#140)
JJJ Jun 27, 2022
7c515b0
More readme edits
JJJ Jun 27, 2022
811e399
Remove temporary variable (#141)
szepeviktor Jun 27, 2022
678cae9
Base: minor refactor to magic methods, and is_success()
JJJ Jun 28, 2022
de87164
Query: MySQL 8 support
JJJ Jun 28, 2022
5a0675a
Merge branch 'release/2.1.0' into issue/128
JJJ Jun 28, 2022
72a2266
WIP - Issue/128 (#143)
JJJ Jun 28, 2022
70b0c92
Resolve PHPStan Level 0 errors (#144)
szepeviktor Jun 29, 2022
66796c4
Merge branch 'release/2.1.0' of github.com:berlindb/core into issue/128
JJJ Jun 29, 2022
5b16eed
Query: bail early with obvious results (not $retval)
JJJ Jun 29, 2022
a5efe05
Base/Query: prevent fatals when get_db() returns false
JJJ Jun 30, 2022
fa64a8e
Table/Query: more database fatal prevention.
JJJ Jun 30, 2022
fe344b7
Table: softer language in inline comment
JJJ Jun 30, 2022
c6b4d1d
Schema/Query: mark linked classes as protected.
JJJ Jun 30, 2022
85ea827
Column: missed a spot
JJJ Jun 30, 2022
77310ed
Column: I promise I'm usually better than this
JJJ Jun 30, 2022
e54dfc9
Schema: correct a default param value
JJJ Jun 30, 2022
5f924b0
Query: improve readability & docs in set_found_items()
JJJ Jun 30, 2022
4ee4f51
Issue/55 - Query: Add support for query handlers. (#123)
JJJ Jul 2, 2022
563848d
Table: add repair & status methods
JJJ Jul 2, 2022
db020bf
Table: add rename() method, and some clean-up
JJJ Jul 2, 2022
3054f26
Table: rename some vars
JJJ Jul 2, 2022
195785b
Query: rename query_handlers to query_var_parsers
JJJ Jul 2, 2022
824b046
Queries: limit calls to get_db()
JJJ Jul 2, 2022
9757dbe
Query: group "shape" methods together
JJJ Jul 4, 2022
838dc9a
Query: clean-up parse_where_search()
JJJ Jul 4, 2022
98a5eb9
Update src/Database/Query.php
JJJ Jul 5, 2022
4853bde
Fix boolean handling in Table (#151)
szepeviktor Jul 13, 2022
c6e06ae
Set db version default to 1 (#157)
robincornett Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 50 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,68 @@
# BerlinDB

BerlinDB is a collection of PHP classes and functions that aims to provide an <a href="https://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a>-like experience and interface to WordPress database tables.
BerlinDB is a collection of PHP classes & methods to provide an <a href="https://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a>-like interface to database tables in WordPress.

This repository contains all of the code that is required to be included in your WordPress project.
Use it to move data out of custom Post Types & Taxonomies and into custom database tables.

The most common use-case for BerlinDB is a WordPress Plugin that needs to create custom database tables, but more advanced uses are possible, including managing and interfacing with the WordPress Core database tables themselves.
Ensure perform reliably and scale effortlessly in highly available WordPress based web applications.

Future repositories in this organization will contain examples, extensions, drop-ins, unit tests, and more.
## Mission
The primary mission of BerlinDB is to democratize data storage.

----
### Phase 1 - 2022
Minimize the effort required to perform routine & repetitive database interactions.

The name of this project comes from WordCamp Europe 2019, where it was <a href="https://jjj.blog/wceu-2019/">originally announced</a> as an unnamed library. Thank you to <a href="https://peterwilson.cc">Peter Wilson</a> for the idea to pay homage to such a wonderful audience.
### Phase 2 - 2022
Achieve platform agnosticism through smart abstractions and interoperability layers.

----
### Phase 3 - 2022
Generate the custom code that is necessary from any existing database table structure.

The code in this repository represents the cumulative effort of dozens of individuals across multiple projects, spanning multiple continents, native languages, and years of conceptual development:
### Phase 4 - 2023
Automate database table structure changes for a seamless upgrade/rollback experience.

### Phase 5 - 2023
Manage all database connections to directly support reads, writes, clones, splitting, and sharding.

## Name

This project is named for [WordCamp Europe 2019](https://europe.wordcamp.org/2019/) which took place in the beautiful & historic capital city of Berlin, Germany, where it was <a href="https://jjj.blog/wceu-2019/">originally exhibited & announced</a> as an unnamed utility being used by the Sandhills Development engineering team.

<a href="https://peterwilson.cc">Peter Wilson</a> recommended naming it "Berlin" to commemorate everyone in attendance for its unveiling. Thanks, Peter! 🙏

## Beginnings

The code in this repository represents the cumulative effort of dozens of individuals across multiple projects, spanning several continents, native languages, and years of conceptual development & iteration:

* BuddyPress (<a href="https://buddypress.org">inspired by</a>)
* WordPress Multisite (<a href="https://make.wordpress.org/core/components/networks-sites/">inspired by</a>)
* Easy Digital Downloads (<a href="https://github.com/easydigitaldownloads/easy-digital-downloads/tree/release/3.0">3.0 and higher</a>)
* Sugar Calendar (<a href="https://github.com/sugarcalendar/sugar-event-calendar-lite">2.0 and higher</a>)
* Restrict Content Pro (<a href="https://github.com/restrictcontentpro">3.1 and higher</a>)
* WordPress Multisite (<a href="https://make.wordpress.org/core/components/networks-sites/">inspired by</a>)
* BuddyPress (<a href="https://buddypress.org">inspired by</a>)

These projects all require custom database tables to acheive their goals (and to meet the expecations that their users have in them) to perform and scale flawlessly in a highly available WordPress based web application.
## Contributions

Interested in contributing? See the [contributing guide](/CONTRIBUTING.md).

## Support

Have a question? [Open a new issue](https://github.com/berlindb/core/issues/new) and someone will try to help.

## License

MIT. Please enjoy this code freely & openly, [as is](/LICENSE).

If you are using BerlinDB in a commercial product, please consider [becoming a sponsor](https://github.com/sponsors/jjj?frequency=recurring&sponsor=jjj).

## Created By

Each of these projects originally implemented their own bespoke approaches to database management, resulting in a massive amount of code duplication, rework, and eventual fragmentation of approaches and ideas.
- [@JJJ](https://twitter.com/JJJ) - https://jjj.blog

This project helps avoid those issues by (somewhat magically) limiting how much code you need to write to accomplish the same repetitive database related tasks.
## Credits

----
This organization is currently managed by <a href="https://jjj.software">Triple J Software, Inc.</a>.

This organization was created by (and is managed by) <a href="https://sandhillsdev.com">Sandhills Development, LLC</a>, where we aim to craft superior experiences through ingenuity, with <a href="https://sandhillsdev.com/commitments/">deep commitment</a> to (and appreciation for) the human element.
Special thanks to:
- <a href="https://sandhillsdev.com">Sandhills Development, LLC</a>
- <a href="https://awesomemotive.com">Awesome Motive, Inc.</a>
- All of JJJ's generous sponsors 💛
28 changes: 15 additions & 13 deletions autoloader.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
<?php
/**
* Autoloader.
* BerlinDB Autoloader.
*
* @package Database
* @copyright Copyright (c) 2021
* @subpackage Autoloader
* @copyright 2021-2022 - JJJ and all BerlinDB Contributors
* @license https://opensource.org/licenses/MIT MIT
* @since 2.0.0
*/

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

// Register a closure to autoload BerlinDB.
/**
* Register a closure to autoload BerlinDB classes.
*/
spl_autoload_register(

/**
* Closure of the autoloader.
* Closure for the autoloader.
*
* @param string $class_name The fully-qualified class name.
* @since 2.0.0
* @param string $class_name A fully-qualified class name.
* @return void
*/
static function ( $class_name = '' ) {

// Project namespace & length.
$root_namespace = 'BerlinDB\\';
$project_namespace = 'BerlinDB\\Database\\';
$root_namespace = 'BerlinDB\\';
$project_namespace = $root_namespace . 'Database\\';
$length = strlen( $project_namespace );

// Bail if class is not in this namespace.
Expand All @@ -33,11 +34,12 @@ static function ( $class_name = '' ) {
}

// Setup file parts.
$format = '%1$s/src/%2$s.php';
$path = __DIR__;
$name = str_replace( '\\', DIRECTORY_SEPARATOR, str_replace( $root_namespace, '', $class_name ) );
$strip = str_replace( $root_namespace, '', $class_name );
$name = str_replace( '\\', DIRECTORY_SEPARATOR, $strip );

// Parse class and namespace to file.
$format = '%1$s/src/%2$s.php';
$path = __DIR__;
$file = sprintf( $format, $path, $name );

// Bail if file does not exist.
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"description": "A collection of PHP classes and functions that aims to provide an ORM-like experience and interface to WordPress database tables.",
"type": "library",
"license": "MIT",
"require": {},
"autoload": {
"psr-4": {
"BerlinDB\\": "src/"
}
},
"require-dev": {
"szepeviktor/phpstan-wordpress": "^0.7.7",
"phpstan/extension-installer": "^1.1"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
Expand Down
Loading