Skip to content

Commit

Permalink
Release/2.0.0 (#57)
Browse files Browse the repository at this point in the history
Merging this a little early so we can get Composer support in a stable version. I've been running this for a few months now and it seems to work fine.

* Move classes to PSR-4 compliant src structure

* Add composer, autoloader support & gitignore

* Add use to fix missing class issue after file move

* Date: Remove duplicate "use" statement.

* Query: non-functional clean-up.

This change normalizes a bunch of variable names, docs, punctuation, and aliased functions (like join vs implode) - consistency!

* Query: add copy_item() method. (#89)

This change introduces a way to allow for copying an existing item/Row in the database, with the option to override that data via the $data parameter.

The goal of including this method as a low-level API is to reduce the amount of code necessary to support this action higher up in the application layer (global functions, etc...)

* Table: fix format of query inside index_exists(). (#90)

This change prevents quotes around the $column value by not preparing it, and also by making sure its value is only 1 of 2 intended columns: Key_name and Column_name.

This fixes incorrectly generated SQL, allowing this method to function as intended instead of incorrectly returning no results.

Props @ashleyfae. Fixes #87.

* First pass autoloader for non-Composer setups.

Props szepeviktor.

* Check if 'where' is empty before using #101 (#102)

* Check if 'where' is empty before using #101
* Added protection against empty "where" clauses #101

Co-authored-by: John James Jacoby <[email protected]>

Co-authored-by: danieliser <[email protected]>
Co-authored-by: Ashley Gibson <[email protected]>
  • Loading branch information
3 people authored Jul 12, 2021
1 parent 550ad19 commit 52f07e1
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
50 changes: 50 additions & 0 deletions autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Autoloader.
*
* @package Database
* @copyright Copyright (c) 2021
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.0.0
*/

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

// Register a closure to autoload BerlinDB.
spl_autoload_register(

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

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

// Bail if class is not in this namespace.
if ( 0 !== strncmp( $project_namespace, $class_name, $length ) ) {
return;
}

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

// Parse class and namespace to file.
$file = sprintf( $format, $path, $name );

// Bail if file does not exist.
if ( ! is_file( $file ) ) {
return;
}

// Require the file.
require_once $file;
}
);
12 changes: 12 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "berlindb/core",
"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": "GPL-2.0-only",
"require": {},
"autoload": {
"psr-4": {
"BerlinDB\\": "src/"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 52f07e1

Please sign in to comment.