Select rows from Mysql with PDO

Connect, query, fetch and return rows from Mysql based on PDO.

php
fork add to bundle source
function pdo_select_rows($sql, $bind = []) { $handle = new PDO('mysql:host=127.0.0.1;dbname=db', 'user', 'pwd'); $st = $handle->prepare($sql); $st->execute($bind); while ( $row = $st->fetch( PDO::FETCH_ASSOC ) ) $list[] = $row; return $list; }

usage

load_function('pdo_select_rows'); $users = pdo_select_rows('SELECT * FROM users'); print_r($users); // ...
← how to use this in app?
create log ...inout