You've already forked OpenShorte.old
first version of the website, it works as intended.
This commit is contained in:
27
functions.php
Normal file
27
functions.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once ( 'config.php' );
|
||||
function db_connect ( ) {
|
||||
global $config;
|
||||
$connection = new MySQLi ( $config [ 'db' ] [ 'host' ], $config [ 'db' ] [ 'username' ], $config [ 'db' ] [ 'password' ], $config [ 'db' ] [ 'name' ], $config [ 'db' ] [ 'port' ] );
|
||||
if ( $connection->connect_errno ) {
|
||||
die ( "Database connection failed." );
|
||||
}
|
||||
return $connection;
|
||||
}
|
||||
function db_prepare ( MySQLi $connection, string $query ) {
|
||||
if ( ! ( $statement = $connection -> prepare ( $query ) ) ) {
|
||||
die ( "Prepare failed: (" . $connection->errno . ") " . $connection->error );
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
function db_bind ( MySQLi_stmt $statement, array $params ) {
|
||||
if ( ! call_user_func_array ( array ( $statement, "bind_param" ), array_merge ( $params [ 0 ], $params [ 1 ] ) ) ) {
|
||||
die ( "Binding parameters failed: (" . $statement->errno . ") " . $statement->error );
|
||||
}
|
||||
}
|
||||
function db_execute ( $statement ) {
|
||||
if ( ! $statement->execute ( ) ) {
|
||||
die ( "Execute failed: (" . $statement->errno . ") " . $statement->error );
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user