-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
550ad19
commit 52f07e1
Showing
12 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.