Instantly share code, notes, and snippets.

View pdo row count
//connect to db
$query = $handler->query("SLECT * FROM tbl_name");
$data = [];
if ($query->rowCount()) {
$data = $query->fetchAll(PDO::FETCH_OBJ);
} else {
echo "NO RESULT";
}
View pdo prepare statement
// good for insert query
//connect to db
$name = 'Rob';
$message = 'Test';
$sql = "INSERT INTO guestBook (name, message, posted) VALUES(?, ?, NOW())";
View PDO: fetching all result
<?php
//connect to database
$query = $db->query('SELECT * FROM tbl_name');
$row = $query->fetch(); //get first row
//itirate to all data
$row = $query->fetchAll(PDO::FETCH_OBJ);
View PHP PDO Connect
<?php
try {
$conn = new PDO('mysql:host=127.0.0.1;dbname=app', 'root', '');
$connt->setAttr(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo $e->getMessage();
}
View CompanyController.php
public function store(Request $request)
{
$db = new Db($request, new CompanyDatabase);
$db->add();
return $db->getResult();
}
View mockIlluminateUploadedFile.php
private function file()
{
return new Illuminate\Http\UploadedFile(
base_path('/tests/pdf/test.pdf'),
'test.pdf',
'application/pdf',
filesize(base_path('/tests/pdf/test.pdf')),
null,
true
);
View vuejs class binding
:class="['list-group-item', {'active' : isFirstPanelActive}]"
View vueDefaultValueForProps.vue
export default {
data() {
return {
size: "100px"
}
},
props: ['size']
}
View copyright.php
View mouseWheelEvent.js
/*
* Author URL: http://adomas.org/javascript-mouse-wheel/
*/
/** This is high-level function.
* It must react to delta being more/less than zero.
*/
function handle(delta) {
if (delta < 0)
…;