Files
nibiru-framework.com/core/a/mysql.db.php
Stephan Kasdorf ca9ff28194 Update Version 0.4.0 beta 09.07.2018
- Bugfix on the form classes, now the select option is correctly set back.
- Update for the database adapter
- Improvement of the form elements, added onchange on the select boxes, the form tag now can have no element if needed.
- Implementation of the Postgres and MySQL Adapter with propper Namespacing.
- Minor bugfixing
2018-07-09 18:48:03 +02:00

115 lines
3.0 KiB
PHP

<?php
namespace Nibiru\Adapter\MySQL;
use Nibiru\Pdo;
use Nibiru\Factory;
use Nibiru\Adapter\IDb;
/**
* Created by PhpStorm.
* User: Stephan Kadsorf
* Date: 26.01.18
* Time: 17:24
*/
abstract class Db implements IDb
{
private static $table = array();
protected static function initTable( $table = array() )
{
self::setTable( $table );
}
/**
* @return array
*/
protected static function getTable()
{
return self::$table;
}
/**
* @param array $table
*/
private static function setTable( $table = array() )
{
if( sizeof($table)>0 )
{
self::$table = $table;
}
}
public function loadPasswordByUsername( $user_name = false )
{
$result = Pdo::query("SELECT DES_DECRYPT(".self::TABLE['field']['user_pass'].", '" . Config::getInstance()->getConfig()[View::NIBIRU_SECURITY]["password_hash"] . "') AS ".self::TABLE['field']['user_pass']." FROM user WHERE " . self::TABLE['field']['user_name']. " = '" . $user_name . "';");
return array_shift($result);
}
public function loadTableAsArray()
{
$result = Pdo::fetchTableAsArray( self::getTable()['table'] );
return $result;
}
public function selectRowsetById($id = false)
{
// TODO: Implement selectRowsetById() method.
}
public function insertRowsetById($rowset = array(), $id = false)
{
// TODO: Implement insertRowsetById() method.
}
public function selectDatasetByMinMax($min = false, $max = false)
{
// TODO: Implement selectDatasetByMinMax() method.
}
/**
* @desc inserts an array into the database as on of the fields may be encrypted, but it has to be a varbinary field
* @param array $dataset
* @param bool $encrypted
*/
public function insertArrayIntoTable($dataset = array(), $encrypted = false)
{
if($encrypted)
{
Pdo::insertArrayIntoTable(self::$table['table'], $dataset, $encrypted);
}
else
{
Pdo::insertArrayIntoTable(self::$table['table'], $dataset);
}
}
public function nextInsertIndex()
{
// TODO: Implement nextInsertIndex() method.
}
/**
* @desc updates a row by a given field and field where search value
* @param bool $wherefield
* @param bool $wherevalue
* @param bool $rowfield
* @param bool $rowvalue
*/
public function updateRowByFieldWhere( $wherefield = false, $wherevalue = false, $rowfield = false, $rowvalue = false )
{
Pdo::updateColumnByFieldWhere( self::$table['table'], $rowfield, $rowvalue, $wherefield, $wherevalue );
}
/**
* @desc select a row by the selected fieldset ( field and where value )
* @param array $field
* @return mixed
*/
public function selectRowByFieldWhere( $field = array() )
{
return Pdo::fetchRowInArrayByWhere(self::$table['table'], $field['field'], $field['value']);
}
}