Questions tagged [mysql]
MySQL is a database system used by many websites on the Internet. Joomla is based on PHP and MySQL.
286
questions
0
votes
3
answers
37
views
Can't use method return value in write context - What is the problem?
I have found several reports of this message being associated with PHP 5.5 and 'empty()' and also containing the word 'function' in place of 'method' but they don't seem related to my instance. My ...
0
votes
0
answers
150
views
Joomla 3.10.11 on server with MySql 8.0
On my online server which has MySql 5.7 and PHP 7.4 I have three sites in joomla which have the following:
Mywebsite1 with joomla 3.10.11 and JD Boston template with Helix framework 3.0.3
Mywebsite2 ...
0
votes
0
answers
19
views
Error 0 Call to a member function get() on null on $db query in com_content category blog.php override
For a J5 site, using Cassiopeia, I have created (on a test site) a View using SQL in phpMyAdmin (which uses mySQL) that selects * from the content table linked by content.id and fields_values.item_id ...
0
votes
0
answers
95
views
_template_styles' doesn't exist
I'm getting a weird error; here is the data below.
I'll first start by telling you what I did and why.
I have a client with a hacked Joomla site. For safety's sake, I installed a new Joomla and all of ...
1
vote
2
answers
123
views
Best way to save timestamp for new or modified records in custom component
In my custom component I have two database tables for items in my component with the standard 'created' and 'modified' datetime columns to contain timestamps when those items are created or modified.
...
0
votes
1
answer
16
views
Subquery error when using 3rd Normal form - 500 Operand should contain 1 column(s)
I'm fighting to get the following structure to work. I have three tables:
players, player_teams, teams
I used the conclusion I've found here for one of my questions: Join one to many with helper table ...
1
vote
1
answer
247
views
Standalone PHP script to get username in Joomla 4?
In Joomla 3 I used the following code. What do I need to change to use it with Joomla 4?
<?php
define( 'DS', DIRECTORY_SEPARATOR );
$rootFolder = explode(DS,dirname(__FILE__));
//current level ...
2
votes
2
answers
133
views
Is insertObject sanitizing the inputs?
Let's suppose I want to insert a new record into a table.
Let's suppose that the table is of the structure of
mytable(id, my_text);
So, for example, we are to insert a new record, I would like to ...
0
votes
1
answer
463
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
166
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
37
views
UNION Query with loadAssocList($key)
So here is a small example of the query I play around with:
$db->setQuery('SELECT position, title FROM jos_modules
UNION (
SELECT position, title FROM jos_modules
)');
$data= $db->loadAssocList()...
1
vote
1
answer
288
views
Joomla 4.3.1 Web installer fails to find MariaDB (MySQL) or PostGreSQL 11
I am trying to install Joomla 4.3.1 on my Ubuntu 18.04 machine. I am running Apache 2.4.57, PHP 7.4 (for Apache, apparently), PHP 8.2 is also installed, and two installations of PostGreSQL: 10.4 (...
2
votes
3
answers
107
views
Find row with lowest column value per group, then join distinct group data to another table
I need a hint for this problem, trying for days already to solve it:
THE PROBLEM
I am working with an Joomla extension which has this 2 tables of interest:
COMPANIES
PRODUCTS
A module lists all ...
1
vote
1
answer
458
views
How to combine or merge SQL results into one row
I have a Joomla list page that I am trying to build each row from multiple tables that I haven't been able to figure out how to do efficiently with MySQL and would like some assistance. I suspect the ...
1
vote
2
answers
184
views
How to use NOW() with DatabaseDriver->insertObject()
I'm inserting an object in a database table using joomla 4, as per joomla docs:
$toInsert = new stdClass();
$toInsert->update_timestamp = 'NOW()';
$toInsert->id = null;
$db = Factory::...
0
votes
0
answers
266
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
2
answers
100
views
Insert datetime type into created column from PHP file from module/component
I can't get the created column filled when inserting items into the database. I am using this code:
function createRecordInLSFCDBTable($id, $userId) {
echo 'createRecordInLSFCDBTable: ' . $id . ',...
0
votes
0
answers
148
views
Using Like with wildcard in joomla php query
Hi I am struggling to get an output from a wildcard query.
I am using the following code which outputs the following error:
0 Unknown format specifier "$"
$iban = '...
1
vote
0
answers
59
views
workable php 7.4 function in joomla 3.10 is working weird in php 8.0
Am displaying list of news haviing
Date
News Heading
Short Descrption
The list is spread to around 100 pages, having 20 news in each page
Issue is: This is working absolute fine in php 7.4.x in ...
2
votes
0
answers
75
views
Very slow HTTP response times possibly due to SEF rules in htaccess
Im running Joomla 3.X and can't seem to pinpoint why I'm getting such high HTTP response times.
I think I narrowed it down to the SEF rules in my .htaccess
I ran some tests and thought to post my ...
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 ...
1
vote
1
answer
74
views
Mysqli query with regex to Joomla php syntax
// CODE1 (Mysql (MariaDB 10.8.3) query):
SELECT s.`p_p`, COUNT(REGEXP_SUBSTR(r.`xml`, '[0-9]+'))
FROM `#__s` AS s, `#__p` AS x, `#__v` AS r
WHERE REGEXP_SUBSTR(r.`xml`, '[0-9]+') = [user_id] AND s.`...
3
votes
2
answers
2k
views
Joomla 4 create article programmatically
I have tried a few ways to create articles programmatically in Joomla 4, but none of my attempts are working.
First is to insert data by mysql using $db->getQuery(true) -- the article shows in the ...
1
vote
1
answer
374
views
Joomla 4 - 503 service unavailable
I've set
public $error_reporting = 'maximum';
public $debug = '1';
If I go into cPanel and turn off mysqlnd nd_mysqli and nd_pdo_mysql and then turn on mysqli I get an error
MySQL server has gone ...
0
votes
1
answer
344
views
Pulling api data and saving to mySQL
So, I am trying to pull data from EA Sports API for games like NHL or FIFA. The issues with EAs API is it only shows the last 5 games played. I am trying to have a script run every minute and save ...
3
votes
1
answer
350
views
Is the following everything one should do to prevent SQL injection?
In order to sanitize the user input in an article insertion form (title and HTML content), here are the bits that I've included:
Use of JInput:
$jinput = JFactory::getApplication()->input;
get ...
0
votes
1
answer
121
views
How to return data from 2 tables to one table using a select field
My tables:
dzialki
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+---...
0
votes
1
answer
263
views
Implement SELECT query with a LEFT JOIN in J4
I want to get data from two tables using a LEFT JOIN. My query works in my current PHP code, I just don't know how to implement it with query building methods in J4. Can anyone help?
SQL:
SELECT `...
0
votes
0
answers
158
views
How to encrypt and decrypt User data in joomla
I am new to joomla, and working on joomla application which is currently running on production environment.
Application contains 1000+ registered users.
As per GDPR Policy, I have requirement for ...
2
votes
0
answers
132
views
MySQL Server has gone away with mysqli_connect to another LAMP Stack / TURNKEY Linux
I am trying to connect to another VM (192.168.16.27) from 192.168.16.28 to get Data out of the MariaDB Database (joomla).
So my Code is:
$link = mysqli_connect("192.168.16.27", "user&...
1
vote
1
answer
456
views
How to use Joomla for insert, delete, display and update data from mysql?
I'm just started to learn using Joomla and one of the things that I need to do is to build a form that can insert data and that data can be displayed to another Joomla page.
I got a few comments from ...
1
vote
1
answer
83
views
Joomla mysql query - group_contact
I have mysql query:
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$formId = 21;
$query = "select * from #...
0
votes
2
answers
7k
views
Error: Failed to start application: Failed to start the session
I have hosted web application develop using joomla in ubuntu 20 and use mysql as database.
one i hosted and viewed in the web browser it show me Error: Failed to start application: Failed to start the ...
2
votes
2
answers
988
views
How to join custom fields data to users table without extra rows in result set
I have rudimentary knowledge of SQL (when it comes to anything but single tables) and am trying to come up with a query that will give me all the custom fields for my users.
This query will give me ...
0
votes
1
answer
436
views
How to create menu item in admin menu Joomla 4 in php+mysql in module, plugin?
How to create menu item in admin menu Joomla 4 in php? From plugin/module for Joomla4?
1
vote
1
answer
66
views
PieChart For RSForm for PlotaLot based on a dropdown field
So I got this Pie Chart to display the Count of Voters vs Position and it's working fine.
SELECT Position,
COUNT(1) AS count
FROM (
SELECT
MAX(IF(FieldName = 'Position', FieldValue, NULL)) ...
0
votes
1
answer
204
views
2014 Commands out of sync - MySql query J4
I've come across this error when performing some database queries in my J4 site model:
$db->setQuery((string)$query);
try {
$rows = $db->loadObjectList();
} catch (...
1
vote
1
answer
115
views
GROUP BY and ORDER BY from different tables of CB extension as outcome to a list
I am trying to figure out how to implement this.
Table1 with subscriptions AS sub
id, status, user_id, plan_id, parent_plan, parent_subscription
Table5 users (Joomla) AS u
id
Table6 fields AS ue
...
1
vote
1
answer
399
views
View only showing one row from sql result set
I am creating a component and trying to display a list within a model. The code I have shows the multiple arrays that should be on the list, but when I add echo inside the view table, I am only ...
1
vote
3
answers
346
views
Joomla 3.9 replace zero dates with null on save/checkin (mysql zero date deprecated)
So zero dates are deprecated in MySQL. J4 has replaced them with nulls.I am trying to update a J3 component to stop J setting zeros in the modified and checked_out_time fields.
For modified I am using ...
1
vote
0
answers
51
views
Using sql field in custom component
I have a custom component, it allows admins to select a related content article from the #__content table using the following:
<field name="relatedcontent" type="sql" default=&...
1
vote
1
answer
130
views
How can I get the names of the columns with their corresponding row values as a list to use in a field (select list) of a form in Joomla MySQL
My table '#__boats' is as follows:
id category type AIG ALLIANZ LLOYDS
1 0 Motorboats
2 0 Sailingboats
3 0 Jet Ski ...
0
votes
0
answers
275
views
How to display external SQL table using Joomla?
I am looking for good free extensions I could use to display SQL tables on my website.
I have tried a couple but, they either don't work or ask for indexing which my tables don't have.
https://joodb....
1
vote
2
answers
220
views
How to use SQL statements not supported by JDatabaseQuery
Recently, I have needed to use some SQL statements that are not supported by the JDatabaseQuery class, specifically REPLACE INTO and INSERT IGNORE. The only way that I am able to get something to ...
0
votes
2
answers
67
views
Run model function in view file to insert default value into sql
I am new to Joomla and received a half-done component. It is a mostly database-dependent component. The component consists of a SQL file that inserts all the data and is able to display it. I am ...
1
vote
3
answers
376
views
Join #__content with #__fields_values then filter and sort using #__fields_values data
I wrote an override in Joomla 3.X and sorted the result from the DB using this query, which works:
$query = "SELECT content.*, fieldvalues.*
FROM #__content AS content,
#...
1
vote
0
answers
26
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 ...
2
votes
1
answer
101
views
using Ajax to save contents of html how to make safe
I am using com_Ajax to save the contents of my editor (front end of the website in a module)
Ajax and passing the content of the editor all works fine. I am concerned about security.
To get the data (...
1
vote
1
answer
104
views
How to use Joomla's query building methods to generate a query containing joined subqueries? [closed]
I am trying to write a query using Joomla's query building methods, but I cannot manage to write the subquery into the query.
Here is my desired raw sql with php variables:
"SELECT track_type,
...
1
vote
2
answers
313
views
How to show multidimensional data in my CanvasJS chart?
<?php
$db->setQuery("SELECT MartabehName, COUNT(MartabehCode) FROM `#__dimteacher` GROUP BY MartabehName");
$countMartabehName = $db->loadObjectList();
foreach($countMartabehName ...