$host = 'localhost'; $user = 'username'; $pass = 'password'; $db = 'database_name'; // Create a new database connection $conn = JFactory::getDBO(); // Set the connection parameters $conn->set('host', $host); $conn->set('user', $user); $conn->set('password', $pass); $conn->set('db', $db); // Connect to the database $conn->connect();
// Create a new database connection $conn = JFactory::getDBO(); // Execute a SELECT query $query = 'SELECT * FROM customers'; $result = $conn->query($query); // Loop through the result set and print the data while ($row = $result->fetch()) { echo $row['first_name'] . ' ' . $row['last_name'] . 'This example demonstrates how to execute a SELECT query and loop through the result set to print the data. Overall, php JFactory is a package library that provides an easy-to-use interface for connecting to and interacting with MySQL databases in PHP web development.
'; }