Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Run an sql script within Joomla

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

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

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 …
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 …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

856 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