Solved

Run an sql script within Joomla

Posted on 2016-10-24
3
22 Views
Last Modified: 2016-10-29
Goal: run a custom script inside Joomla to get usable data back. I was doing the following as a test:
<?php
$db = JFactory::getDbo();
 
// Create a new query object.
$query = $db->getQuery(true);
$query
    ->select('count (*) from jos_users');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results = $db->loadObjectList();
print_r($results);
?>

Open in new window

and i put it together with other scripts running queries. It would not run - how do i get it to run?
0
Comment
Question by:CEHJ
  • 2
3 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41856857
What does "would not run" mean?  Were there any error messages or logs?  Was there any output?  Please give us a little more to go on, thanks.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 0 total points
ID: 41856858
Sorry Ray - i've got it fixed now. The reason was all sorts of bootstrapping code was apparently required
0
 
LVL 86

Author Closing Comment

by:CEHJ
ID: 41865076
Fixed it
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now