Questions tagged [jdatabase]

Joomla Database connector class

Filter by
Sorted by
Tagged with
0
votes
2answers
111 views

Accessing Jdatabase via JavaScript Or Passing PHP varibles to JavaScript

I want to use this SVG Pie Chart on my Joomla site but the problem is I need to access data from Jdatabase and feed it to its index.js $(function(){ $("#pieChart").drawPieChart([ { title: "Cash"...
6
votes
2answers
197 views

Combining 'ANDs' and 'ORs' in a complex WHERE query - Part 2

I have been pulling my hair out with this query for the last 2 days and have read and re-read the 2 other similar posts with no luck. Scenario: I am gathering two inputs from a user: Test ID Code and ...
5
votes
1answer
1k views

SQL Injections using Jfactory::getDBO and setQuery()

$db = JFactory::getDBO(); $searchP = JRequest::getVar('key'); $sql = "SELECT name FROM people LIKE " . "'%" . $searchP . "%'"; $db->setQuery($sql); $fileR = $db->loadObjectList(); Will ...
4
votes
3answers
3k views

How can I get the names of the columns in an object or table with Joomla's SQL?

With the existing output I have from a basic query, what would be the best way to get the names of the columns in the resultant output object without having to run an additional COLUMNS query on the ...
3
votes
2answers
947 views

JDatabase JOIN on multiple values

What is the JDatabase syntax for a JOIN statement that joins two tables on a variable that is either equal to x or is null? Eg it joins on multiple values. I have found some examples that show me you ...
21
votes
1answer
13k views

How to combine ANDs and ORs in the WHERE clause using a Query Object?

Given the desired SQL below, where Cond1 and Cond2 must be met OR Cond3 must be met for selection, what is the correct way to use getQuery() to achieve it? Desired SQL: Condition1 and Condition2 ...
0
votes
1answer
68 views

Downloading large data sets

My site has a facility to download a potentially large body of data from my database as a CSV file. This is currently implemented using a view.csv.php file that serves this data by first setting the ...
1
vote
1answer
57 views

What's the proper chaining for WHERE

This statement works: $query = " SELECT COUNT(*) FROM " . $this->s_createtableName . " WHERE tm BETWEEN UNIX_TIMESTAMP(DATE(NOW())) AND UNIX_TIMESTAMP(DATE(NOW()) + INTERVAL 1 DAY)"; In ...
2
votes
2answers
174 views

Using JDatabase standalone, ie. without Joomla application bootstrapping

Can one instantiate a jdatabase object without the Joomla application? The obvious use case is when you want to open a direct endpoint into some standalone code in your site for an api or cron etc. ...
4
votes
2answers
149 views

Joomla plugin to override table prefix

Overview: I have a single Joomla website that have various copies of the database tables all in the same database, but with different table prefixes. Depending on which user is accessing the site, i ...
4
votes
2answers
1k views

How to write an Insert Select Statement?

This Method for creating a subquery using JDatabase provides some great insight and I think it would be beneficial to have a agreed method of subquery documented. I came across this because I am ...
2
votes
1answer
442 views

Multiple Count from same table

I used to get multiple COUNT in one query using the SUM(CASE WHEN $db =& JFactory::getDBO(); $query = "SELECT SUM(CASE WHEN last_name LIKE 'A%' THEN 1 ELSE 0 END) as alpha, SUM(...
0
votes
1answer
91 views

JDatabase Update +1

I am trying to update the database with the original column's value plus (+1) or minus (-1) $column_name = 'mycolumnname'; $table_name - 'mytablename'; $db = JFactory::getDbo(); $query = $db->...
3
votes
1answer
127 views

Using JDatabaseQuery::union() causes errors

I'm getting errors when using JDatabaseQuery::union() to create a database query. With Debug disabled I get this at the bottom of the page, presumably when trying to disconnect: Warning: mysqli::...
2
votes
1answer
2k views

How to check whether a specific row exists in a JDatabase table?

What would be the best way to check whether a specific row exists already in a JDatabase table? Instead of INSERT INTO Command, I need to execute a UPDATE command if the row already exists. Help ...
2
votes
1answer
510 views

JDatabase, SQL statement template

Is there a way to use a statement template, like by Hibernate HQL? SQLQuery sql=s.createSQLQuery("SELECT AVG(RATING) as r, COUNT(*) as c FROM RATINGS WHERE ADVENTURE_ID = ?"); sql.setParameter(0, ...
2
votes
1answer
208 views

Cannot get num rows with the database driver

Any idea how to fix this? $dbo = JFactory::getDbo(); $query = 'SELECT `#__example`.`example_value` AS `value` FROM `#__example`'; $dbo->setQuery($query); $rowsCount = $dbo->getNumRows(); $...
0
votes
2answers
47 views

Cannot query Joomla database as a guest user

I have a site mostly targeted for registered users but I want to provide guests (potential new users) with registration form. This registration form is a Menu item publicly available (it consists of a ...
2
votes
2answers
969 views

Global PHP functions?

How can I make few global php functions which can be called from any Joomla custom module? E.g I wish to make a global function executing a select database query: function select($row,$table_name,$...
0
votes
1answer
229 views

Select newly inserted record in JDatabase [duplicate]

I am manually adding a record using PHP (sourcerer) into Jdatabase. I wish to select the record that was added using the insert query below. Is there a wayout without using another query with where ...
1
vote
3answers
656 views

PHP function with JDatabase queries

I have these two blocks of identical code in one of my PHP modules. The only difference between these two blocks is that in first block it is ... active = ' .$db->q('1')); and in the second block ...
0
votes
1answer
79 views

Custom Admin Dashboard: Manual Menu Assignment to Modules

I need to create a custom Admin dashboard for my client. He should be able to add, edit custom modules via this dashboard. As far as I know I need to play with #__modules table (jdatabase).I figured ...
1
vote
1answer
102 views

Example form on posting data through JInput class

I've been told numerous times to use JInput Class as opposed to using 'method="post" on my forms. I have no problem finding example of how to retrieve data using JInput, but after searching numerous ...
1
vote
1answer
38 views

No syntax errors & Query works without one parameter

The following query will not return any results... if (empty($from_date)) { $from_date = 2000-01-01; } if (empty($to_date)) { $to_date = 3000-01-01; } if (empty($_POST['supervisor'])) { $...
2
votes
1answer
983 views

JDatabase Like Operator

I would like to know how to perform pattern search using JDatabase Here's my code: $query->select('Common_name'); $query->from($db->quoteName('common_name')); $query->where($db->...
0
votes
1answer
103 views

Get HWD media share video thumbnail url from Joomla database

I have videos on my site component HWDmedia share. They haven't schema.org integration and trying add markup to videos. For videoobject have 4 types and i add 3 of them (name,description and date) but ...
1
vote
0answers
15 views

Need some suggestion regarding strategy of scraping article view times from another webpage to use in K2 item

I am building a video blog page using Joomla 3.0 + k2 hosted on my own Ubuntu 14.04 server, the videos will be uploaded to sites like youtube or vimeo too. I want to show the viewed times of the ...
2
votes
3answers
708 views

Ordering a UNION

I have two queries that I am unioning and would like to order them. I would like to order them on the second element, the date. My queries look like this: $query2 ->select ($db->quoteName(...
0
votes
2answers
791 views

Select code not working in article Joomla 3

I need to display data in an article in tabular form. I am using sourcerer by NoNumber for adding the select code in the article: <?php defined('_JEXEC') OR die("Restricted access"); $user =&...
0
votes
1answer
162 views

JDatabase subQuery not work [duplicate]

I have products table and brads table, i want show record from brands table whit product count. The query: SELECT a.*, ( SELECT COUNT(*) FROM jos_products AS p WHERE ...
1
vote
1answer
698 views

Joomla JFactory::getDBO() - Prefix is wrong?

I am pretty new to Joomla, and I'm stuck! I'm trying to access the Joomla DB from a PHP script, using the JFactory::getDBO(); method. I noticed all my queries were returning '0' results, even though ...
2
votes
1answer
1k views

JDatabaseQuery quote correctly the items into select

I have written a database query, like so: $query = $db->getQuery(true) ->select("u.*,ju.username,ju.email,ju.lastvisitDate as last_login") ->from("#__component_users AS u") ->...
2
votes
2answers
2k views

Get ID of deleted database-entry

I would like to create a delete-method, which deletes an entry in a table AND the attached entries in a second table. This is my source so far: // Delete entry in users_handles $db = ...
1
vote
1answer
176 views

Very slow query using JDatabase vs Manual

I have a simple query that is taking almost a minute using JDatabase but takes less than a second when I use sqlsrv_connect. $time_pre = microtime(true); $conn_array = array ( "...
1
vote
1answer
1k views

How to select a blank(dummy) column in a JDatabse UNION query

I have two queries that I am combining using a UNION statement. I know that I need both queries to get the same number and type of arguments to work. I have one query that only really needs three ...
0
votes
2answers
2k views

How to use Oracle database for populating a list in a form

In using the MySQL Database, here is the default query in populating lists: $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('name', 'email', 'username')) ->...
1
vote
1answer
1k views

I can load data from Joomla database and external database?

It is possible to join 2 databases at the same time in a single query? For example: I want to see how many users I have on my server and how many users I have on an external server, all in a single ...
5
votes
1answer
568 views

JDatabaseDriver->replacePrefix( ) Allowed memory size of … bytes exhausted

Reported via Issue Tracker Item #33711 When trying to insert a BLOB > 3MB in the database, the following error occurs: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to ...
3
votes
2answers
156 views

View Users Front End - php code

I am using http://www.nonumber.nl/extensions/sourcerer in order to place some custom php code in an article to display all my registered users in the front end of my Joomla 3.3 site. I am new to this ...
4
votes
1answer
2k views

Selecting data from multiple JDatabase tables?

I am trying to select data from multiple Jdatabase tables and use a IF-ELSE statement with this : $db = JFactory::getDbo(); $user = JFactory::getUser(); $query = $db->getQuery(true); $query->...
-2
votes
1answer
576 views

Allowing Registered Users To Edit Only Specific JDatabase records?

I have prepared a script which allows registered users to edit some records (which belong to them) in a table of JDatabase. Here's how? This is the first script which detects the logged in user and ...
7
votes
2answers
245 views

Is there a way to detect the database changes that were made by third party extensions?

I work in a development / staging / production environment and I've run into some challenges promoting code from one environment to another, especially when upgrades to Joomla and other third party ...

1
2