Hello everyone,
have a quick look, please, what I'm doing wrong. The snippet shows below my text works perfect (with result - Connectedadminpeterjason),
but it shouldn't be, because in database "adminer" there is no table "modx_users"!
This such a table is in my main database, so the login information in header of snippet are ignored- why?:-)
(database Adminer was found for the simple filling via Adminer -
http://www.adminer.org/en/)
Thank all of you for spending time.
Peter
// Criteria for foreign Database
$host = 'localhost';
$username = 'adminer';
$password = 'password';
$dbname = 'adminer';
$port = 3306;
$charset = 'utf-8';
$dsn = "mysql:host=$host;dbname=$dbname;port=$port;charset=$charset";
$xpdo = new xPDO($dsn, $username, $password);
// Test your connection
echo $o = ($xpdo->connect()) ? 'Connected' : 'Not Connected';
// Issue queries against the foreign database:
$stmt = $modx->query('SELECT * FROM `modx_users` ORDER BY `username` ASC');
if ($stmt && $stmt instanceof PDOStatement) {
while ($row= $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['username'];
}
}