5 Commits

Author SHA1 Message Date
795784f02e Improved Search Functionality 2025-01-30 18:13:12 -05:00
b1e74f9652 Readme update 2025-01-27 22:54:56 -05:00
bcd73d58f9 composer updates 2025-01-27 00:07:05 -05:00
3b8e099491 composer bumps 2025-01-21 21:02:57 -05:00
e7dc2186a8 composer bump 2025-01-21 20:51:01 -05:00
6 changed files with 87 additions and 34 deletions

View File

@ -637,10 +637,29 @@ class Database {
return true;
}
public function search( $table, $column, $param ) {
public function searchColumn( $table, $column, $param ) {
return $this->action( 'SELECT *', $table, [$column, 'LIKE', '%' . $param . '%'] );
}
public function search( $table, $columns, $param ) {
if ( empty( $columns ) || ! is_array( $columns ) ) {
Debug::log( 'No columns provided for search' );
return [];
}
$conditions = [];
foreach ( $columns as $column ) {
$conditions[] = $column;
$conditions[] = 'LIKE';
$conditions[] = '%' . $param . '%';
$conditions[] = 'OR';
}
array_pop( $conditions );
return $this->action( 'SELECT *', $table, $conditions );
// return $this->action( 'SELECT ' . implode( ',', $columns ), $table, $conditions ); // need to find a way to casually make this the default....
}
/**
* Selects data from the database.
*

View File

@ -17,8 +17,9 @@ use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Bedrock;
class DatabaseModel extends Model {
public $databaseMatrix;
public $tableName;
public $databaseMatrix;
public $searchFields;
public function __construct() {
parent::__construct();
@ -190,4 +191,19 @@ class DatabaseModel extends Model {
}
return $this->filter( $data->results() );
}
public function search($param) {
if (empty($this->searchFields)) {
Debug::log('searchFields is empty');
return [];
}
$result = self::$db->search($this->tableName, $this->searchFields, $param);
if ( $result->count() ) {
return $this->filter( $result->results() );
}
return [];
}
}

View File

@ -99,11 +99,11 @@ class Check {
* @return {bool}
*/
public static function imageUpload( $imageName ) {
if ( !Config::getValue( 'uploads/images' ) ) {
if ( ! Config::getValue( 'uploads/images' ) ) {
self::addUserError( 'Image uploads are disabled.' );
return false;
}
if ( !isset( $_FILES[$imageName] ) ) {
if ( ! isset( $_FILES[ $imageName ] ) ) {
self::addUserError( 'File not found.', $imageName );
return false;
}

View File

@ -1,31 +1,52 @@
# Tempus Project Core
###### Developer(s): Joey Kimsey
Bedrock is the core functionality used by [The Tempus Project](https://github.com/TheTempusProject/TheTempusProject) a rapid prototyping framework. This Library can be utilized outside of the TempusProject, but the functionality has not been tested well as a stand alone library.
# Bedrock
## Developer(s): Joey Kimsey
This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications fast and simple.
Bedrock is the core functionality used by [The Tempus Project](https://github.com/TheTempusProject/TheTempusProject) a rapid prototyping framework. It provides database support, configuration, base models, and base controller functionality a in addition to a host of other integrated functions.
This Library can be utilized outside of TheTempusProject, but the functionality has not been tested well as a stand-alone library.
**Notice: This Library is provided as is, please use at your own risk.**
## Installation and Use
The easiest way to use Bedrock in your application is to install and initialize it via composer.
```
The easiest way to use Bedrock in your application is to install it via composer and extend the main app inside of the bin folder.
`Composer.json`
```json
"require": {
"TheTempusProject/Bedrock": "*",
},
"autoload": {
"psr-4": {
"Bedrock\": "vendor/TheTempusProject/Bedrock"
"TheTempusProject\\Bedrock\\": "vendor/thetempusproject/bedrock",
}
}
```
If you prefer to handle auto-loading via other means, you can simply clone this repository wherever you need it. Please note, you will need to install and load the [TempusDebugger](https://github.com/thetempusproject/TempusDebugger) library in order to utilize the debug to console options.
`app.php`
```php
<?php
namespace MyApp;
use TheTempusProject\Bedrock\Bin\Bedrock;
class MyApp extends Bedrock {
// Stuff and Things
}
?>
```
If you prefer to handle auto-loading via other means, you can simply clone this repository wherever you need it.
### To-Do
### WIP:
- [ ] Expansion of PDO to allow different database types
- [ ] template stuff should really only be called from template/controllers
- [ ] Update installer to account for updates.
- [ ] Implement uniformity in terms of error reporting, exceptions, logging.
- [ ] Updates for configs and models to re-build based on a delta model, to make version changes simpler. (Migration system)
- [ ] Implement better uniformity in terms of error reporting, exceptions, logging.

View File

@ -22,9 +22,9 @@
"require":
{
"php": ">=8.1.0",
"thetempusproject/canary": ">=1.0",
"thetempusproject/hermes": ">=1.0",
"thetempusproject/houdini": ">=1.0"
"thetempusproject/canary": "1.0.6",
"thetempusproject/hermes": "1.0.3",
"thetempusproject/houdini": "2.0.2"
},
"autoload":
{

29
composer.lock generated
View File

@ -4,20 +4,19 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4467bdc4b2a87dc7540fc9854ebd9384",
"content-hash": "6621b1244b732ba3424ec89affa7161e",
"packages": [
{
"name": "thetempusproject/canary",
"version": "dev-main",
"version": "1.0.6",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
"reference": "35415fbf3c5888ccdb8a8695989176a120026c7f"
"reference": "44b2ad688cff933964ec2ff50b408d94c7f51e40"
},
"require": {
"php": ">=8.1.0"
},
"default-branch": true,
"type": "library",
"autoload": {
"files": [
@ -48,20 +47,19 @@
"thetempusproject",
"tools"
],
"time": "2024-08-20T10:26:09+00:00"
"time": "2025-01-22T01:39:34+00:00"
},
{
"name": "thetempusproject/hermes",
"version": "dev-main",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
"reference": "31c51c1a5bad2871df800c89f27ace0a49848583"
"reference": "4b4e06a98f0f01695bda18de240bb3294d096ef4"
},
"require": {
"php": ">=8.1.0"
},
"default-branch": true,
"type": "library",
"autoload": {
"files": [
@ -92,22 +90,21 @@
"thetempusproject",
"tools"
],
"time": "2024-08-20T10:26:47+00:00"
"time": "2025-01-22T01:43:15+00:00"
},
{
"name": "thetempusproject/houdini",
"version": "dev-main",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
"reference": "d9e61d3f8f5d10f3fa7ba31907a4b3c1edc76614"
"reference": "fb027a4ebc327e709ad3da29a4cf112894c2b7e6"
},
"require": {
"php": ">=8.1.0",
"thetempusproject/canary": ">=1.0",
"thetempusproject/hermes": ">=1.0"
"thetempusproject/canary": "1.0.6",
"thetempusproject/hermes": "1.0.3"
},
"default-branch": true,
"type": "library",
"autoload": {
"files": [
@ -137,7 +134,7 @@
"thetempusproject",
"tools"
],
"time": "2024-08-20T10:30:48+00:00"
"time": "2025-01-27T05:02:14+00:00"
}
],
"packages-dev": [],
@ -150,5 +147,5 @@
"php": ">=8.1.0"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.3.0"
}