Solved

Run an sql script within Joomla

Posted on 2016-10-24
3
15 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
Comment Utility
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
Comment Utility
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
Comment Utility
Fixed it
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 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

11 Experts available now in Live!

Get 1:1 Help Now