View Single Post
  #2  
Old 05-03-2016, 02:25 PM
 
BurtonTech BurtonTech is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 46
 

Default Re: Running Simple Selects on 3rd party table

Not sure if this is the best solution, but it works for MySQLi:
Code:
//Get the Connection info from X-Cart 5 $xc_conn = \XLite\Core\Database::getEM()->getConnection(); //Collect the info you need for a MySQLi connection $sql_host =$xc_conn->getHost(); $sql_db =$xc_conn->getDatabase(); $sql_user =$xc_conn->getUsername(); $sql_password =$xc_conn->getPassword(); //Collect your data using MySQLi $conn = new mysqli($sql_host, $sql_user, $sql_password,$sql_db); if ($conn->connect_error) { error_log('MySQLi could not connect: ' . $conn->connect_error); } $sql_query = "SELECT * FROM YourTable"; $db_results = $conn->query($sql_query); $results_array = $db_results->fetch_assoc(); if ($db_results->num_rows > 0) { foreach($results_array as $dbkey=>$dbvalue) { echo 'Key: '.$dbkey.' = '.$dbvalue.'<br />'; } }

Hope that helps!
__________________
X-Cart Gold 4.4.5
X-Cart Ultimate 5.2.22
X-Cart Business 5.3.2.13
X-Payments 3
Reply With Quote