You've already forked OpenShorte.old
							
							
		
			
				
	
	
		
			28 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?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 );
 | 
						|
        }
 | 
						|
    }
 | 
						|
?>
 |