Using getAll() in BxDolConnection.php
Howdy,
I'm a bit lost in terms of using the database connection class.
I have this working in PDO:
function run_sql_test_pdo($pdo, $user_id, $recepient_id){
$stmt = $pdo->prepare('SELECT lot_id, user_id
FROM final_folly.bx_messenger_jots
WHERE user_id = ? OR user_id = ?
ORDER BY lot_id ASC');
$stmt->execute([$user_id, $recepient_id]);
$result = $stmt->fetchAll();
}
But translating the function into the DB class used by UNA is proving to be of some difficulty. I'm guessing it's something like this:
$sSql = $aObject::getAll("SELECT lot_id, user_id FROM final_folly.bx_messenger_jots WHERE user_id = 1");
But it's even not close. Getting this error:
E_NOTICE Error in file »BxDolConnection.php« at line 271: Undefined variable: aObject Fatal error: Uncaught Error: Class name must be a valid object or a string in /var/www/html/inc/classes/BxDolConnection.php:271 Stack trace: #0 /var/www/html/inc/classes/BxDolConnection.php(213): BxDolConnection->_action('9', 3, 'addConnection', '_sys_conn_err_c...', true) #1 /var/www/html/conn.php(24): BxDolConnection->actionAdd() #2 {main} thrown in /var/www/html/inc/classes/BxDolConnection.php on line 271 E_ERROR Error in file »BxDolConnection.php« at line 271: Uncaught Error: Class name must be a valid object or a string in /var/www/html/inc/classes/BxDolConnection.php:271 Stack trace: #0 /var/www/html/inc/classes/BxDolConnection.php(213): BxDolConnection->_action('9', 3, 'addConnection', '_sys_conn_err_c...', true) #1 /var/www/html/conn.php(24): BxDolConnection->actionAdd() #2 {main} thrown
Any ideas? Any advice on these database handlers functions?
-
-
·
LeonidS
- ·
Hello gigperfect !
getAll isn't a static method. So you need to change your code like
$aResults = BxDolDb::getInstance()->getAll();
BTW - for the cases with unique indexes you'd better use the getRow method. And better don't use the direct variables in the query:
$aRow = BxDolDb::getInstance()->getRow("SELECT lot_id, user_id FROM final_folly.bx_messenger_jots WHERE user_id = :id", array(
'id' => $iId) );
-
·
LeonidS
-
Hi@LeonidS.
Thanks worked brilliantly!