1. Go to this page and download the library: Download milantex/daw 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/ */
milantex / daw example snippets
use Milantex\DAW\DataBase;
# Open a connection using the DAW
$daw = new DataBase('localhost', 'bayou', 'root', '');
# Write an SQL query (no parameters)
$query1 = 'SELECT * FROM `post` WHERE `visible` = 1;';
# Execute the query and retrieve all result set rows
$visiblePosts = $daw->selectMany($query1);
# Print out the dump of the result
echo '<pre>' . print_r($visiblePosts, true) . '</pre>';
# Write an SQL query (with one parameter for the username)
$query2 = 'SELECT * FROM `user` WHERE `username` = :username AND `active` = 1;';
# Prepare the parameter associative array
$params2 = [ ':username' => 'milantex' ];
# Execute the query and retrieve a single result set
$user = $daw->selectOne($query2, $params2);
# Print out the dump of the result
echo '<pre>' . print_r($user, true) . '</pre>';
# Write an SQL query (with an unnamed parameter placeholder)
$query3 = 'DELETE FROM `post` WHERE `post_id` = ?;';
# Prepare the ordered parameter array
$params3 = [ 130 ];
# Execute the query and retrieve a single result set
$result3 = $daw->execute($query3, $params3);
# Check the result
if (!$result3) {
# Print out the dump of error information if the result is bad
echo '<pre>' . print_r($daw->getLastExecutionError(), true) . '</pre>';
} else {
# Print out how many records were affected
$affectedRows = $daw->getLastExecutionAffectedRownCount();
echo 'Deleted record count: ' . $affectedRows . '<br><br>';
}
# Write an SQL query (with unnamed parameter placeholders)
$query4 = 'INSERT INTO `post` (`user_id`, `title`, `link`, `content`) '.
'VALUES (:user_id, :title, :link, :content);';
# Prepare the parameter associative array
$params4 = [
':user_id' => 1,
':title' => 'A test post',
':link' => 'a-test-post',
':content' => '<p>This is the content of the new test post.</p>'
];
# Execute the query and retrieve a single result set
$result4 = $daw->execute($query4, $params4);
# Check the result
if (!$result4) {
# Print out the dump of error information if the result is bad
echo '<pre>' . print_r($daw->getLastExecutionError(), true) . '</pre>';
} else {
# Get the ID of the new post
$postId = $daw->getLastInsertId();
echo 'The ID of the new post is: ' . $postId . '<br><br>';
}