Solved

Run an sql script within Joomla

Posted on 2016-10-24
3
29 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 109

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Creating and Managing Databases with phpMyAdmin in cPanel.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

832 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