Once after updating the ABillS billing system, when opening the Maintenance>Hardware>PON menu and selecting a device, an SQL error occurred:
Tag Archives: SQL
ABillS. Problem with payments between 00:00 and 01:00
In 2018, I ran into a problem when the user ran out of money on the account, at midnight he turned off the billing, the user immediately made a payment, the money was debited and the service turned on, and at 1 am it was turned off again, because the billing system tried to withdraw the monthly fee again. I’ll just post a simple script here that allows you to receive email notifications with a list of users who made a payment at night between 00:00 and 01:01, so that later you can manually correct it.
Continue reading “ABillS. Problem with payments between 00:00 and 01:00”How to change user login in WordPress
To change the WordPress user login, you need to execute an SQL query to the database, since this cannot be done through the admin panel menu.
Continue reading “How to change user login in WordPress”PHP script “TOP debtors of the Nika billing system”
Let me give you an example of a PHP script displaying a list of debtors from the Nika ASRM database:
Continue reading “PHP script “TOP debtors of the Nika billing system””Creating an External Zabbix Validation for SQL SELECT Query
Once I added a graph that draws the amount of payments from the MySQL billing database from another server.
Continue reading “Creating an External Zabbix Validation for SQL SELECT Query”How to pull data from one column of a mysql table
To see data from one column, it is enough to execute the SQL query (where “abcd” is the name of the column in the table):
SELECT abcd FROM table;
To export to a file, just run the command in Linux:
mysql -u root -e "SELECT abcd FROM database;" -s -N > file.txt
Here is an example of exporting email addresses from a mysql table to an http page using PHP.
The thought immediately came to this plan (create a php file and open it through the browser):
<?php // Connecting to mysql server mysql_connect("localhost", "USER", "PASSWORD") or die (mysql_error ()); // Choosing a database mysql_select_db("users") or die(mysql_error()); // SQL query $rows = "SELECT * FROM account"; // Run this SQL query $d = mysql_query($rows); // Each row becomes an array ($row) using the mysql_fetch_array while($row = mysql_fetch_array($d)) { // Display the values of the email column echo $row['email'] . "<br />"; } // Close the connection to the database mysql_close(); ?>
SQL queries for ABillS
In this article I will give examples of some SQL queries for the base of the ABillS billing system.
Continue reading “SQL queries for ABillS”How to change a WordPress theme through MySQL
To change the WordPress theme via MySQL, first see what theme is specified at the moment, for this, execute the SQL query via phpMyAdmin or MySQL client:
SELECT * FROM wp_options WHERE option_name = 'template' OR option_name = 'stylesheet' OR option_name = 'current_theme';
Next, see what themes are in the /wp-content/themes/ directory.
For example, to change to the standard Twenty Fifteen theme, let’s execute three SQL queries:
UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'template'; UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'stylesheet'; UPDATE wp_options SET option_value = 'Twenty Fifteen' WHERE option_name = 'current_theme';
How to disable the WordPress plug-in via MySQL
To disable all WordPress plugins via MySQL, you must:
1) Be sure to make a backup copy of the database.
2) Open the phpMyAdmin or MySQL client from the terminal:
mysql -u USER -p
3) Execute the SQL query (if necessary, specify the correct prefix wp_):
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
After that, all plug-ins will be disabled and you can activate them again one by one in the admin panel.
You can also temporarily disable the plugin by renaming the directory with its files, the plugins are in the /wp-content/plugins/ directory.
SQL queries for Zabbix
I will write some useful examples of sql queries for the Zabbix database:
Search for a host by name:
SELECT * FROM hosts WHERE host like '%name%'; SELECT * FROM hosts WHERE name like '%name%';
Find the data items of the specified host:
SELECT * FROM items WHERE hostid = '10105';
Find the history of the values for the specified data item:
SELECT * FROM history WHERE itemid = '24526';
Delete the whole history of the data element until 01.11.2014 (the time is specified in Unix format, converters can be found through the search engine):
DELETE FROM history WHERE itemid = '24526' AND clock < '1414800000';
Delete all data history until 01.11.2014:
DELETE FROM history WHERE clock < '1414800000';
Massively changed the interval and dynamics of changes to the data elements of templates and hosts, I have the following queries (the first identifies the template ID or host, the second changes the intervals):
SELECT * FROM `hosts` WHERE host="Template ICMP Ping"; UPDATE items SET delay=3600 WHERE hostid=10105 AND delay=600; UPDATE items SET trends=180 WHERE hostid=10047 AND trends=365;