In Revo 2.0 and then in 2.1 is this the correct way to connect to a different database?
<?php
include "my/file/configCustom.inc.php";
$dbase = ltrim($dbase, "`");
$dbase = rtrim($dbase, "`");
$xpdo = new xPDO('mysql:host=local;dbname=myDataBase', $database_user, $database_password, '');
$sql = 'SELECT * FROM `table`';
$rs = $xpdo->query($sql);
while($row = $modx->db->getRow($rs))
{
/* do whatever I want */
}
I’ve seen what Bob did, but wow, way over my head. (And I think too much work for one or two queries.)
http://bobsguides.com/custom-db-tables.html
You may or may not want to use the code I write. It's probably all against the syntax rules of php and MODx.
Carpet Cleaning
You can’t use xPDO without going through the process of creating the schema and the class and map files. If you want to avoid that, you can use PDO.
http://php.net/manual/en/book.pdo.php
So, it shouldn’t be working?
I put it in some code last night in 2.0.7 and it worked fine. Is that bad?
So instead of the above I would use this? (I’m not trying to hack stuff. I’m trying to learn and start with simple stuff.)
<?php
include "my/file/configCustom.inc.php";
$dbase = ltrim($dbase, "`");
$dbase = rtrim($dbase, "`");
$pdo = new PDO('mysql:host=local;dbname=myDataBase', $database_user, $database_password);
$sql = 'SELECT * FROM `table`';
$rs = $pdo->query($sql);
while($row = $modx->db->getRow($rs))
{
/* do whatever I want */
}
You may or may not want to use the code I write. It's probably all against the syntax rules of php and MODx.
Carpet Cleaning