Skip to content

Commit

Permalink
Merge pull request #18 from alllinux/v1.0.1
Browse files Browse the repository at this point in the history
Refactor and enhance database and form operations
  • Loading branch information
alllinux authored Mar 27, 2024
2 parents b6068ce + e92091f commit f27267c
Show file tree
Hide file tree
Showing 27 changed files with 160 additions and 111 deletions.
16 changes: 0 additions & 16 deletions application/module/users/interfaces/users.php

This file was deleted.

16 changes: 0 additions & 16 deletions application/module/users/plugins/users.php

This file was deleted.

3 changes: 0 additions & 3 deletions application/module/users/settings/users.ini

This file was deleted.

16 changes: 0 additions & 16 deletions application/module/users/traits/users.php

This file was deleted.

18 changes: 0 additions & 18 deletions application/module/users/users.php

This file was deleted.

27 changes: 20 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nibiru/nibiru-framework",
"type": "framework",
"description": "PHP MVC rapid prototyping framework",
"keywords": ["php","mvc","prototyping","nibiru","template-engine","database","navigation","router","rapid"],
"keywords": ["php","mmvc","prototyping","nibiru","template-engine","database","navigation","router","rapid","mvc"],
"license": "BSD-4-Clause",
"homepage": "https://github.com/alllinux/Nibiru",
"authors": [
Expand All @@ -14,16 +14,29 @@
}
],
"config": {
"vendor-dir": "core/l"
"vendor-dir": "core/l",
"allow-plugins": {
"php-http/discovery": true
}
},
"require": {
"php": ">=8.1.0",
"php": ">=8.2.0",
"smarty/smarty": "^3.1",
"phpmailer/phpmailer": "^6.1",
"phpmailer/phpmailer": "^6.9.1",
"dasprid/enum": "^1.0.3",
"bacon/bacon-qr-code": ">=1.0.3",
"mevdschee/php-crud-api": "^2.14",
"symfony/psr-http-message-bridge": "^2.1",
"laminas/laminas-diactoros": "^2.24"
"laminas/laminas-diactoros": "^2.24",
"guzzlehttp/guzzle": "^7.8.1",
"brick/date-time": "^0.4.1",
"ext-memcached": "*",
"ext-gd": "*",
"ext-pdo": "*",
"openai-php/client": "^v0.8.4",
"elasticsearch/elasticsearch": "7.17.0",
"ext-curl": "*",
"picqer/php-barcode-generator": "^2.4",
"bacon/bacon-qr-code": "^2.0",
"enjin/php-blockchain-tools": "^1.15"
}
}
}
21 changes: 21 additions & 0 deletions core/a/module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace Nibiru\Adapter;

use Nibiru\IModule;
abstract class Module implements IModule
{
/**
* @desc will return the value of the requested property
* @param string $name
* @return mixed
*/
abstract protected function _get(string $name);
/**
* @desc will set a given property for this class
* @param string $name
* @param $value
* @return void
*/
abstract protected function _set(string $name, $value): void;

}
63 changes: 63 additions & 0 deletions core/c/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
namespace Nibiru;

/**
* Class Module
* @project src
* @desc This is a PHP class file, please specify the use
* @author stephan - Maschinen Stockert Großhandels GmbH
* @date 27.03.24
* @time 11:39
* @package Nibiru
*/
class Module extends Adapter\Module
{
/**
* @desc Instance of the Module class
* @return Module
*/
public function __construct()
{
return $this;
}

/**
* @desc will set a given property for this class
* @param string $name
* @param $value
* @return void
*/
protected function _set(string $name, $value): void
{
try {
$_class_properties = get_class_vars(__CLASS__);
if (array_key_exists($name, $_class_properties))
{
$this->$name = $value;
}
} catch (\Exception $e) {
error_log("Exception in _set method: " . $e->getMessage());
} catch (\Error $e) {
error_log("Error in _set method: " . $e->getMessage());
}
}
/**
* @desc will return the value of the requested property
* @param string $name
* @return mixed
*/
protected function _get(string $name): mixed
{
try {
$_class_properties = get_class_vars(__CLASS__);
if (array_key_exists($name, $_class_properties))
{
return $this->$name;
}
} catch (\Exception $e) {
error_log("Exception in _get method: " . $e->getMessage());
} catch (\Error $e) {
error_log("Error in _get method: " . $e->getMessage());
}
}
}
42 changes: 21 additions & 21 deletions core/c/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @category - [PLEASE SPECIFIY]
* @license - BSD License
*/
final class Pdo extends Mysql implements IPdo
final class pdo extends Mysql implements IPdo
{
private static $section = false;

Expand Down Expand Up @@ -55,11 +55,11 @@ protected static function loadTableNames(): array


/**
* @param string $string
*
* @return array
*/
public static function query( $string = self::PLACE_NO_QUERY )
* @param string $string
*
* @return array|bool
*/
public static function query( $string = self::PLACE_NO_QUERY ): array|bool
{

if(!strstr($string, IOdbc::PLACE_SQL_UPDATE))
Expand All @@ -84,14 +84,14 @@ public static function query( $string = self::PLACE_NO_QUERY )
else
{
$query = parent::getInstance( self::getSettingsSection() )->getConn();
$query->exec($string);
return $query->exec($string);
}
}

/**
* @return array
*/
private static function convertFetchToAssociative( array $result ): array
private static function convertFetchToAssociative( array $result ): array
{
$resultset = [];
if(array_key_exists(0, $result))
Expand Down Expand Up @@ -168,10 +168,10 @@ public static function selectDatasetByFieldAndValue($tablename = self::PLACE_TAB
* @param string $where_value
*/
public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME,
$column_name = IMysql::PLACE_COLUMN_NAME,
$parameter_name = IMysql::PLACE_SEARCH_TERM,
$field_name = IMysql::PLACE_FIELD_NAME,
$where_value = IMysql::PLACE_WHERE_VALUE )
$column_name = IMysql::PLACE_COLUMN_NAME,
$parameter_name = IMysql::PLACE_SEARCH_TERM,
$field_name = IMysql::PLACE_FIELD_NAME,
$where_value = IMysql::PLACE_WHERE_VALUE )
{
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
$query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name;
Expand Down Expand Up @@ -250,12 +250,12 @@ public static function updateRowById(string $tableName, array $columnNames, arra
* @param bool $id
* @return array
*/
public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID )
{
public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID )
{
$result = array();
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
$describe = $statement->query('DESC ' . $tablename);
$describe->execute();
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
$describe = $statement->query('DESC ' . $tablename);
$describe->execute();
$tableInformation = $describe->fetchAll( \PDO::FETCH_ASSOC );
foreach ( $tableInformation as $entry )
{
Expand Down Expand Up @@ -360,9 +360,9 @@ public static function fetchRowsInArrayByWhere($tablename = IMysql::PLACE_TABLE_
* @return int|string
*/
public static function getLastInsertedID()
{
return parent::getInstance( self::getSettingsSection() )->getConn()->lastInsertId();
}
{
return parent::getInstance( self::getSettingsSection() )->getConn()->lastInsertId();
}

/**
* @param string $tablename
Expand Down Expand Up @@ -407,7 +407,7 @@ public static function fetchTableAsArray( $tablename = self::PLACE_TABLE_NAME, $
* @param bool $encrypted
* @return bool
*/
public static function insertArrayIntoTable( $tablename = IMysql::PLACE_TABLE_NAME, $array_name = IMysql::PLACE_ARRAY_NAME, $encrypted = IMysql::PLACE_DES_ENCRYPT ): bool
public static function insertArrayIntoTable( $tablename = IMysql::PLACE_TABLE_NAME, $array_name = IMysql::PLACE_ARRAY_NAME, $encrypted = IMysql::PLACE_DES_ENCRYPT ): bool
{
$statement = parent::getInstance( self::getSettingsSection() )->getConn();

Expand Down
2 changes: 1 addition & 1 deletion core/c/typecheckbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function loadElement( $attributes )
*/
private function _setElement( )
{
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" ID CLASS checked="CHECKED" CHECKED>' . ' VALUE<br>' . "\n";
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" ID CLASS CHECKED>' . ' VALUE' . "\n";
}


Expand Down
32 changes: 19 additions & 13 deletions core/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@
require_once __DIR__ . '/c/config.php';
require_once __DIR__ . '/c/registry.php';
require_once __DIR__ . '/c/router.php';
require_once __DIR__ . '/i/engine.php';
require_once __DIR__ . '/i/IEngine.php';
require_once __DIR__ . '/c/engine.php';
require_once __DIR__ . '/l/autoload.php';
/**
* @desc Database connectivity
*/
require_once __DIR__ . '/i/mysql.php';
require_once __DIR__ . '/i/IMysql.php';
require_once __DIR__ . '/c/mysql.php';
require_once __DIR__ . '/i/pdo.php';
require_once __DIR__ . '/i/IPdo.php';
require_once __DIR__ . '/c/pdo.php';
/**
* @desc Database ODBC support
*/
require_once __DIR__ . '/i/odbc.php';
require_once __DIR__ . '/i/IOdbc.php';
require_once __DIR__ . '/c/odbc.php';
require_once __DIR__ . '/i/postgres.php';
require_once __DIR__ . '/i/IPostgres.php';
require_once __DIR__ . '/c/postgres.php';
require_once __DIR__ . '/i/psql.php';
require_once __DIR__ . '/i/IPsql.php';
require_once __DIR__ . '/c/psql.php';
require_once __DIR__ . '/i/postgresql.php';
require_once __DIR__ . '/i/IPostgresql.php';
require_once __DIR__ . '/c/postgresql.php';
require_once __DIR__ . '/i/db.php';
require_once __DIR__ . '/i/pageination.php';
require_once __DIR__ . '/i/IDb.php';
require_once __DIR__ . '/i/IPageination.php';
require_once __DIR__ . '/a/mysql.db.php';
require_once __DIR__ . '/a/postgres.db.php';
require_once __DIR__ . '/a/postgresql.db.php';
Expand All @@ -53,7 +53,7 @@
/**
* @desc MVC functionality
*/
require_once __DIR__ . '/i/form.php';
require_once __DIR__ . '/i/IForm.php';
require_once __DIR__ . '/f/form.php';
require_once __DIR__ . '/t/form.php';
require_once __DIR__ . '/c/formattributes.php';
Expand Down Expand Up @@ -85,16 +85,22 @@
require_once __DIR__ . '/c/typeclosediv.php';
require_once __DIR__ . '/c/typeopenany.php';
require_once __DIR__ . '/c/typecloseany.php';
require_once __DIR__ . '/i/view.php';
require_once __DIR__ . '/i/IView.php';
require_once __DIR__ . '/c/view.php';
require_once __DIR__ . '/i/controller.php';
require_once __DIR__ . '/i/IController.php';
require_once __DIR__ . '/c/controller.php';
require_once __DIR__ . '/a/controller.php';
require_once __DIR__ . '/c/jsonnavigation.php';
/**
* @desc MMVC functionality
*/
require_once __DIR__ . '/i/IModule.php';
require_once __DIR__ . '/a/module.php';
require_once __DIR__ . '/c/module.php';
/**
* @desc currently unfinished
*/
require_once __DIR__ . '/i/auth.php';
require_once __DIR__ . '/i/IAuth.php';
require_once __DIR__ . '/c/auth.php';
/**
* @desc main application starters
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f27267c

Please sign in to comment.