Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php namespace slsql;

class Config
{
const dbType = 'mysql',
dbName = 'Default',
host = '127.0.0.1:3306',
user = 'root',
password = '';
}
2 changes: 2 additions & 0 deletions src/model/model.php → src/Model/Model.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace slsql\Model;

use slsql\Slsql\Slsql;

/*
* WTFPL License (http://www.wtfpl.net/) - https: //github.com/CrBast/PHP-SQL_SimpleLife/blob/master/LICENSE
*
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 13 additions & 11 deletions src/slsql/slsql.php → src/Slsql/Slsql.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace slqsl\slqsl;
<?php namespace slsql\Slsql;

use slsql\Config;
use \Error;
use \PDO;

/**
* WTFPL License (http://www.wtfpl.net/) - https: //github.com/CrBast/PHP-SQL_SimpleLife/blob/master/LICENSE
Expand Down Expand Up @@ -114,7 +118,7 @@ public function createDB()

/**
* Send Request.
* the parameters are in the .env file
* the parameters are in the Config class file (slsql\Config)
*
* Return :
* [value] = result,
Expand All @@ -124,7 +128,7 @@ public function createDB()
public static function go($request, $array = array())
{
try {
$db = slsql::getPDO();
$db = Slsql::getPDO();
$stmt = $db->prepare($request);
$stmt->execute($array);
//var_dump($stmt);
Expand All @@ -137,7 +141,7 @@ public static function go($request, $array = array())

/**
* Send Transaction.
* the parameters are in the .env file
* the parameters are in the Config class file (slsql\Config)
*
* Return :
* [value] = result,
Expand All @@ -146,7 +150,7 @@ public static function go($request, $array = array())
*/
public static function goT(SLTransaction $trans)
{
$db = slsql::getPDO();
$db = Slsql::getPDO();
try {
$db->beginTransaction();
foreach ($trans->get() as $transaction) {
Expand All @@ -164,13 +168,11 @@ public static function goT(SLTransaction $trans)

private static function getPDO()
{
try {
require '../.env';
} catch (Exception $e) {
throw new Error("Error Processing Request");
if (!class_exists("\slsql\Config")) {
throw new Error("Cannot find <\slsql\Config>");
}
try {
$db = new PDO($env['DBType'] . ':dbname=' . $env['DBName'] . ';host=' . $env['Host'], $env['User'], $env['Password']);
$db = new PDO(Config::dbType . ':dbname=' . Config::dbName . ';host=' . Config::host, Config::user, Config::password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $db;
} catch (PDOException $e) {
Expand All @@ -195,7 +197,7 @@ public function get()

public function go()
{
return slsql::goT($this);
return Slsql::goT($this);
}
}

Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions src/example.env

This file was deleted.