Refactor and enhance database and form operations
Significant changes have been implemented in the database operations, particularly in update and insert functions, ensuring more stable and efficient handling of queries. Form capabilities have been enhanced by adding new attributes for processing decimal steps, further improving data input methods. This update also includes considerable refactoring and security enhancements in the PDO class.
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace Nibiru\Module\Users\Interfaces;
|
||||
/**
|
||||
* @desc this file is for the autoloader to function properly,
|
||||
* you might as well use it as the primary user interface for your
|
||||
* application
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 28.08.18
|
||||
* Time: 11:21
|
||||
*/
|
||||
|
||||
interface Users
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace Nibiru\Module\Users\Plugins;
|
||||
/**
|
||||
* Class Users
|
||||
* @package Nibiru\Module\Users\Plugins
|
||||
* @author: Stephan Kasdorf
|
||||
* @date: 04.09.20
|
||||
* @copyright: 2020 Nibiru Framework, you may copy the code,
|
||||
* but have to inform the author about where it
|
||||
* is used. So happy copying.
|
||||
* @licence: BSD 4-Old License
|
||||
*/
|
||||
class Users
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
[USERS]
|
||||
name = "users"
|
||||
path = "/application/module/users"
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace Nibiru\Module\Users\Traits;
|
||||
/**
|
||||
* @desc this file is for the autoloader to function properly,
|
||||
* you might as well use it as the primary user trait for your
|
||||
* application
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 28.08.18
|
||||
* Time: 11:24
|
||||
*/
|
||||
|
||||
trait Users
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace Nibiru\Module\Users;
|
||||
/**
|
||||
* @desc this file is for the autoloader to function properly,
|
||||
* you might as well use it as the primary user class for your
|
||||
* application, the interface an the trait are currently implemented
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 28.08.18
|
||||
* Time: 11:22
|
||||
*/
|
||||
use Nibiru\Module\Users\Interfaces;
|
||||
use Nibiru\Module\Users\Traits;
|
||||
|
||||
class Users implements Interfaces\Users
|
||||
{
|
||||
use Traits\Users;
|
||||
}
|
||||
@@ -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": [
|
||||
@@ -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
core/a/module.php
Normal file
21
core/a/module.php
Normal file
@@ -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
core/c/Module.php
Normal file
63
core/c/Module.php
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace Nibiru;
|
||||
* @category - [PLEASE SPECIFIY]
|
||||
* @license - BSD License
|
||||
*/
|
||||
final class Pdo extends Mysql implements IPdo
|
||||
final class pdo extends Mysql implements IPdo
|
||||
{
|
||||
private static $section = false;
|
||||
|
||||
@@ -55,11 +55,11 @@ final class Pdo extends Mysql implements IPdo
|
||||
|
||||
|
||||
/**
|
||||
* @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))
|
||||
@@ -84,14 +84,14 @@ final class Pdo extends Mysql implements IPdo
|
||||
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))
|
||||
@@ -168,10 +168,10 @@ final class Pdo extends Mysql implements IPdo
|
||||
* @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;
|
||||
@@ -250,12 +250,12 @@ final class Pdo extends Mysql implements IPdo
|
||||
* @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 )
|
||||
{
|
||||
@@ -360,9 +360,9 @@ final class Pdo extends Mysql implements IPdo
|
||||
* @return int|string
|
||||
*/
|
||||
public static function getLastInsertedID()
|
||||
{
|
||||
return parent::getInstance( self::getSettingsSection() )->getConn()->lastInsertId();
|
||||
}
|
||||
{
|
||||
return parent::getInstance( self::getSettingsSection() )->getConn()->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tablename
|
||||
@@ -407,7 +407,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
* @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();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class TypeCheckbox extends FormAttributes implements IForm
|
||||
*/
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,29 +20,29 @@ require_once __DIR__ . '/c/settings.php';
|
||||
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';
|
||||
@@ -53,7 +53,7 @@ require_once __DIR__ . '/c/model.php';
|
||||
/**
|
||||
* @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';
|
||||
@@ -85,16 +85,22 @@ require_once __DIR__ . '/c/typeopendiv.php';
|
||||
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
|
||||
|
||||
15
core/i/IModule.php
Normal file
15
core/i/IModule.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Nibiru\Adapter;
|
||||
/**
|
||||
* interface IModule
|
||||
* @project src
|
||||
* @desc This is a PHP interface file, please specify the use
|
||||
* @author stephan - Maschinen Stockert Großhandels GmbH
|
||||
* @date 27.03.24
|
||||
* @time 11:42
|
||||
* @package ${NAMESPACE}
|
||||
*/
|
||||
interface IModule
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user