Questions tagged [jdatabase]
Joomla Database connector class
105 questions
2 votes
1 answer
73 views
Joomla 6.x - Best way to use the database in an InstallerAdapter
Up to Joomla 5, I used this in my installation script public function update(InstallerAdapter $adapter): bool { $db = $adapter->getParent()->getDbo(); } In Joomla 6, this is not possible, ...
0 votes
1 answer
72 views
Joomla 4.x Query chaining with ON DUPLICATE KEY?
I am replacing all the string queries in an old plugin with chaining queries. So far so good, but today I had a doubt about this one: INSERT INTO `table` (`id`, `name`, `age`) VALUES (1, 'A', 19) ON ...
0 votes
1 answer
69 views
Join one to many with helper table JDatabase
I'm currently using a two step solution to get all linked teams to a player (a player can be linked to multiple teams) that way for my backend list view: first regular SELECT from Players Then loop ...
0 votes
1 answer
687 views
MySQL "LOAD DATA LOCAL INFILE" with database connection object in Joomla 4
In order to import large CSV files into a Joomla database table, I use the MySQL "LOAD DATA LOCAL INFILE" command as follows: $db = $this->getDbo(); $sql = "LOAD DATA LOCAL INFILE '&...
0 votes
1 answer
244 views
Using MySQL "LOAD DATA LOCAL INFILE" with the Joomla database connection object
In a Joomla 3 component I use the MySQL "LOAD DATA LOCAL INFILE" command to import large CSV files into a Joomla database table. When moving to a new server, it is no longer possible to ...
0 votes
2 answers
886 views
How to display order data with simple SQL query?
I am trying to run a simple query in Joomla 4 to retrieve order data to display in a module. Testing the query with phpMyAdmin works fine, but despite generating no errors (set to Maximum) the below ...
1 vote
2 answers
134 views
How do I create a new PHP variable for a blog override from the result of JDatabase join query?
In a category blog override I am attempting to reflect the featured status of an article. In order to find out whether it is currently actively featured - i.e. not 'pending' or 'expired' I am querying ...
0 votes
0 answers
326 views
Connecting to an external database in Joomla 4 - further problem
I have seen the earlier question on this subject and tried the suggested code: $db = (new Joomla\Database\DatabaseFactory)->getDriver('mysqli', $options); but get an error: An error has occurred ...
1 vote
1 answer
1k views
Connecting to an external database in Joomla 4
Connecting to an external database in Joomla 3 is easy following this documentation and works like a charm. But JDatabaseDriver->getInstance method is deprecated in Joomla 4. What is the ...
0 votes
2 answers
1k views
Join tables where one column value has leading zeros and the other doesn't
I am trying to LEFT JOIN a table, but the two columns used for relating rows are not identically formatted. My problem is the value in a.vendor, it has leading zeros on it, and c.No doesn't have ...
0 votes
1 answer
337 views
Decode json strings from a database table column
I have a column in my database that essentially creates an array and I am essentially trying to explode it but I cannot figure out how to get it to work. Its also going into SQL with { characters ...
2 votes
2 answers
613 views
SQL syntax error in query with subquery using JDatabase
I'm coding my first Joomla! 4 component. There are two tables for the component: pfx_list, and pfx_member_to_list. Table pfx_list hash primary key id, and table pfx_member_to_list has foreign key ...
1 vote
0 answers
35 views
MySQL - Is a query with many results or several queries with one result more efficient? [duplicate]
I need to get category titles for which I am using the a model where $result returns all the data from the categories table, what I need is only the titles, that by making a loop to $result and a ...
0 votes
0 answers
28 views
Translate query from PHP to Jdatabase [duplicate]
This query: SELECT rank() over (ORDER BY max(fs_score) desc) AS nr, nome_e_cognome AS "Player Name", max(fs_score) AS "Best score" FROM scheda_atleta INNER JOIN at on at.id=...
1 vote
2 answers
626 views
Selecting data from two tables and make a ranking in an HTML table
I want take the result from scheda_atleta table for every player and make an HTML table with the best result. I've two tables: first named: at +----+----------------+ | id | nome_e_cognome | +----+----...