PHP code example of mk / database-connection-handler
1. Go to this page and download the library: Download mk/database-connection-handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use \MK\DB;
$dbc_handler = DatabaseConnectionHandler::getInstance();
$searched_name = "Jack"
$searched_age = 21
$result = $dbc_handler = $dbc_handler->query("INSERT INTO my_table (name, age) VALUES (?, ?);", array($searched_name, $searched_age));
//Last insert id
$last_insert_id = $result->getLastInsertID();
//Loop through result
$result2 = $dbc_handler->query("SELECT id, name, age FROM my_table;", array());
foreach($result2->fetchAll() as $row) {
print_r($row);
}
//Get single (estimated) result
$result3 = $dbc_handler->query("SELECT id, name, age FROM my_table WHERE name = ?;", array($searched_name));
if($result3->getSelectedRows() > 0) { //Is there an result?
$searched_row = $result3->nextRow();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.