feat: Add comprehensive documentation suite and reorganize project structure
- Created complete documentation in docs/ directory - Added PROJECT_OVERVIEW.md with feature highlights and getting started guide - Added ARCHITECTURE.md with system design and technical details - Added SECURITY.md with comprehensive security implementation guide - Added DEVELOPMENT.md with development workflows and best practices - Added DEPLOYMENT.md with production deployment instructions - Added API.md with complete REST API documentation - Added CONTRIBUTING.md with contribution guidelines - Added CHANGELOG.md with version history and migration notes - Reorganized all documentation files into docs/ directory for better organization - Updated README.md with proper documentation links and quick navigation - Enhanced project structure with professional documentation standards
This commit is contained in:
40
f_core/f_functions/functions.database.php
Normal file
40
f_core/f_functions/functions.database.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// Database utility functions
|
||||
if (!defined("_VALID_ACCESS")) { exit("Direct access not allowed"); }
|
||||
|
||||
function get_db_connection() {
|
||||
global $db;
|
||||
if ($db === null) {
|
||||
try {
|
||||
$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4";
|
||||
$db = new PDO($dsn, DB_USER, DB_PASS, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
error_log("Database connection failed: " . $e->getMessage());
|
||||
throw new Exception("Database connection failed");
|
||||
}
|
||||
}
|
||||
return $db;
|
||||
}
|
||||
|
||||
function db_query($sql, $params = []) {
|
||||
$db = get_db_connection();
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function db_fetch($sql, $params = []) {
|
||||
return db_query($sql, $params)->fetch();
|
||||
}
|
||||
|
||||
function db_fetch_all($sql, $params = []) {
|
||||
return db_query($sql, $params)->fetchAll();
|
||||
}
|
||||
|
||||
function db_execute($sql, $params = []) {
|
||||
return db_query($sql, $params)->rowCount();
|
||||
}
|
||||
Reference in New Issue
Block a user