Questions tagged [php]

Use ONLY if PHP is directly relevant to the question and likely to be the source of your problem, not just because you're using a PHP library to connect to a database. PHP stands for Professional Hypertext Preprocessor, a widely used platform for dynamic web applications. If you have a general programming question about PHP, please ask it on Stack Overflow instead.

Filter by
Sorted by
Tagged with
1 vote
1 answer
23 views

PosgtreSQL — Is it possible to specify a sequence name in a GENERATED BY DEFAULT AS IDENTITY column?

When using PHP’s lastInsertId() method with PostgreSQL, it’s necessary to know the name of the sequence. If I defined the column using GENERATED BY DEFAULT AS IDENTITY, I know I can get the sequence ...
Manngo's user avatar
  • 2,719
0 votes
0 answers
38 views

Trying to import large sql file in MySQL fails

I am trying to import an SQL file that is 685MB into MySQL. First I tried it through phpmyadmin - it failed. Then I tried through the command line with: mysql -u root -p database-name < file.sql ...
Petar Vasilev's user avatar
0 votes
0 answers
178 views

"The mysqli extension is missing" Tried everything but still no fix!

I recently upgraded to php 8.2.7. Everything was fine until I checked phpmyadmin and got the mysqli extention is missing. I edited the php.ini file in /etc/php/8.2/apache2 directory and added the ...
mani-hash's user avatar
  • 101
0 votes
1 answer
79 views

Transaction/For update lock for an eCommerce project

When users want to purchase their orders, The quantity of the products should be decreased. Now I'm planning to use a Transaction and a FOR UPDATE lock on the products and decrease the quantity of ...
Jacqueline's user avatar
0 votes
0 answers
49 views

What is the best way to get posts with comments from MariaDB?

I have a MariaDB DB with three tables: posts ID | title | content | author_id | likes_count -------------------------------------------------- 1 | Abcd | content_01 | 1 |...
Elgameel's user avatar
0 votes
1 answer
273 views

How to import CSV files into MariaDB in a secure and performant way?

We have a PHP based web application that allows the upload of CSV files. These CSV files with up to 2.5 million rows are to be imported into a table in a MariaDB. How can we make this import secure ...
Ste2play's user avatar
1 vote
0 answers
46 views

Issue with hash storage resulting from password_verify() output

Consider the following code: $random_token = random_bytes(32); $token_hash = password_hash( $random_token, PASSWORD_DEFAULT ); $token_base64 = sodium_bin2base64( $random_token, ...
DevelJoe's user avatar
  • 163
0 votes
1 answer
59 views

Insert rows in 3 tables in a single query, SQL SERVER 2008

I need to insert data into 3 tables in a single query Table SkillData UserIndex SkillPoint TotalSkill 1 5202 99 Table Emblems UserIndex CountEmblem Status 1 1265 1 Table Rewards UserIndex Level ...
Ichigo Kurosaki's user avatar
1 vote
1 answer
56 views

Delete records in different tables

I need to delete the records where UserIndex = 1 and ItemNumber = 5202 in all three tables, all in a single query. I am using SQL 2008 R2. Table UserInfo1 UserIndex Itemnumber ItemCount 1 5202 99 1 ...
Ichigo Kurosaki's user avatar
0 votes
0 answers
33 views

Mariadb / Mysql "Authentication switch request" slows down PHP connections to mariadb server

We switched our on premises MariaDB server to the Azure MariaDB managed service. It runs on MariaDB 10.3.23 in which we cannot tune all server values. While stress testing our PHP API application, we ...
Alex T.'s user avatar
-1 votes
1 answer
662 views

Retrieve all data from an inner join with duplicate column names in MySQL

I have a database with tables for "users" and "profiles". Every profile links back to a user. I would like to do an inner join where I am able to retrieve a set of profiles that ...
Eric Johnson's user avatar
5 votes
2 answers
214 views

Is it secure to have database login in a PHP file? Other options?

I'm a DB and SQL beginner. I'm putting together a basic PHP app that has a few SQL queries. In all my searching and learning, every example accessed the database by first logging in. Makes sense, but ...
user1934286's user avatar
0 votes
1 answer
52 views

Developing database for powerplant-- HELP!

I am network admin at a municipality that has been tasked with creating a database to log information from our powerplant. I know I don’t have the skills to do this, but since I have some knowledge on ...
cloudd2's user avatar
0 votes
1 answer
59 views

Is replication on by default on MySQL 8.0.30 ? How to stop it?

I am running MySQL 8.0.30 on Rocky Linux 9. While importing some ~100GB sql files, I noticed the /var/lib/mysql is filled with binlog.000123 files, over 100GB. I assume these are created because ...
adrianTNT's user avatar
  • 195
0 votes
1 answer
269 views

Unable to connect to server following phpMyAdmin upgrade from 5.1 to 5.2

Not sure to post on the right StackExchange forum. If not, let me know! Working environment: OpenSUSE Leap 15.4 MariaDB : mariadb Ver 15.1 Distrib 10.7.7-MariaDB PHP 8.0.25 (cli) (built: Oct 31 2022 ...
wiltomap's user avatar
  • 317
0 votes
1 answer
174 views

mysqli_fetch_array exceeds memory

I a running a relatively simple query: SELECT gb2_designs.indx, gb2_designs.response_required, gb2_designs.user_design_name, ...
rob boudrie's user avatar
0 votes
2 answers
3k views

how do I select all records that have an event datetime within 1 hour before

how do I select all records that have an event datetime within 1 hour before, for example mysql select all that time_diff less than 1 hour from datetime? its for a reminder email i want to make on a ...
uk_user2014's user avatar
0 votes
0 answers
79 views

How to remove 200 entries Google Adsense Code from Wordpress database?

I have the problem that I do not know how the Google AdSense code must be packaged so that I can delete it from a wordpress table. The entries are respectively in the posts table and in the ...
Data123456's user avatar
0 votes
1 answer
68 views

How to UNPIVOT an aliased query result using PHP and MySql

I would be grateful for your assistance in helping me get solution for my project weather query problem. I have arrived at the query below and is working: "); $first_row = true; while ($row = ...
BenGik's user avatar
  • 13
1 vote
2 answers
347 views

Table Aliases: MySQL says table R1 does not exist when Joining the same table 3 times

I have a table R with the following fields stated below: weatherID, dateRecorded, Days, locationID, timeRecorded, rainAmount, rainNumberHours, temperature, windSpeed, windDirection NB: The ...
BenGik's user avatar
  • 13
0 votes
1 answer
38 views

How to get mysqli to read a mysql cnf file

From the command line, one can get mysql and mysqldump to read a config file using --defaults-extra-file. This can contain username and password for connection. Is there a way to get mysqli from php ...
Rohit Gupta's user avatar
  • 1,422
0 votes
0 answers
268 views

Unknown column od.id_warehouse in where clause

SELECT LEFT(invoice_date, 10) as fix_date, COUNT(*) as countOrders, SUM((SELECT SUM(od.product_quantity) FROM ps_order_detail od WHERE o.id_order = od.id_order)) as countProducts, ...
Ahmed Ibrahim's user avatar
0 votes
2 answers
1k views

Mysql UUID function, does it prevent duplicates?

lets say i use INSERT INTO database(column1) VALUES (uuid()); if i do the same again INSERT INTO database(column1) VALUES (uuid()); (lets assume the UUIDs are both the same, somehow) will mysql ...
user655355's user avatar
0 votes
0 answers
116 views

Behavior Transactions PDO::beginTransaction() and "BEGIN"

I have a strange behavior in a php script (PHP 8.1) using MariaDB 10.7.5 database. This one with native SQL works: $pdo->query("BEGIN"); [ ... some database stuff ... ] $pdo->query(&...
Marco's user avatar
  • 97
-4 votes
2 answers
47 views

How do I write the query to get the exact result

I am confused about writing query in PHP, I want to: 1. SELECT RollNumber FROM student WHERE ProgramID= ? 2. SELECT DSID FROM datesheet WHERE CourseCode = ? 3. INSERT INTO result (DSID, RollNumber) ...
Ahmed Raza's user avatar
2 votes
1 answer
377 views

Optimize a query multiple tables & Multiple conditions

I need to optimize the query which has multiple joins. And also with multiple OR AND conditions which varies depending upon the user input. The query which gets generated is: SELECT emp.name as ...
Parikshit Bharadwaj's user avatar
0 votes
1 answer
120 views

Understanding slow queries from mysqldumpslow

I'm maintaining a system which sporadically (no exact time) but only at night causes the entire server to crash for a few seconds and the users seeing "Error Connection Refused" until the ...
Marcus Christiansen's user avatar
0 votes
2 answers
736 views

is it possible to list each category as a heading and its own products in a single sql query

i have a DB schema as shown in the picture bellow : i want to view each category and subcategory as a heading and list the products under it note: the products must be of the same supplier like this:...
rh2o's user avatar
  • 1
0 votes
1 answer
534 views

Best approach for basic PHP DB session data storage

I've decided to switch from PHP's native session management based on $_SESSION to use my own, due to many different issues I've had so far with PHP's possibilities, and also because I'm building an ...
DevelJoe's user avatar
  • 163
3 votes
1 answer
728 views

Converting large database with many tables from latin1 to utf8mb4

So this is not a question about "how do I convert a table from latin1 to utf8?" I totally know that and get it. The question I'm trying to ask is, "How can I make this conversion have ...
n0nag0n's user avatar
  • 133
0 votes
2 answers
2k views

How to limit the number of rows in a mysql table

How can I set a limit of rows to a mysql table? (I am using php) POSSIBLE METHOD-1: When the user tries to SIGN-UP I can select everything from the TABLE and get the number of ROWS in the TABLE and ...
user avatar
1 vote
1 answer
271 views

How to deal with invoices that reference products that don't exist any more?

I am developing an ERP using PHP and MYSQL. I have a product page and an invoice page. I am facing an issue, if I delete a product from products page, and I already created an invoice with this ...
Black P's user avatar
  • 11
0 votes
0 answers
49 views

Use of comments to define index relationship to another table

I am building a CRUD system using PHP and MySQL for custom applications I am working on. The question I have relates to the use of comments to define indexes from one table and return the required ...
Majickal's user avatar
0 votes
1 answer
60 views

php mysql aggregating/ combining queries to reduce db connections

I have a use case where a large number of clients are reporting their operational states every minute using an HTTP connection to a php script. For each client, I have a row in a mysql table with ...
aVC's user avatar
  • 101
0 votes
0 answers
199 views

How do I connect to mysql database with password

Using PHP 7.4.27 (now using 7.4.29) with MariaDB in xampp I can access everything using phpmyadmin. I am using the following on my localhost $con = new mysqli($host, $user, $pwd, $db); I can connect ...
Rohit Gupta's user avatar
  • 1,422
3 votes
1 answer
17k views

SQLSTATE[08006] [7] FATAL: the database system is in recovery mode

I have some problem with PostgreSQL and PostGIS. I received an error after running the below query with some coordinates on special raster file. It worked fine until last week. The query is: select (...
mohammad karimi's user avatar
1 vote
0 answers
258 views

Can two simultaneous DB transactions interfere with each other? ACID vs SELECT ... FOR UPDATE?

This question may be considered as a follow-up question to this one. Imagine: a platform that provides a service X to book a service X, customer Y has to pay in advance every payment is authorized ...
DevelJoe's user avatar
  • 163
-1 votes
1 answer
281 views

Mysql takes longer when using php or python compared to worbench queries

Versions: MySQL Community Server: 8.0.16 in Windows server (Configuration file: unknow) Workbench: 8.0 Problem: When I make a query through workbench, it takes 1 second but when I make a query through ...
Ignakal's user avatar
1 vote
2 answers
722 views

Performance of the same MySQL database is different on different servers

I have two servers: Server A: AMD Epyc 7371 - 16c / 32t - 3.1 GHz / 3.8 GHz 256 GB ECC 2400 MHz 2 × 960 GB NVMe SSD MySql 8.0.26 Server B: Dual Intel Xeon Gold 6242R - 20c / 40t - 3.1 GHz / 4.1 GHz ...
Antonio Sordellini's user avatar
2 votes
2 answers
223 views

Does this kind of data/field in this table needs normalization in MYSQL?

I have this uom table in MYSQL: id uom 1 piece 2 dozen 3 set and this products table in MYSQL: id itemNo title uom 1 19421 test1 1:1:10.00,3:1:56.17 2 7878 test2 1:1:24.33 3 123456 test3 2:12:...
Algo's user avatar
  • 31
1 vote
1 answer
1k views

GROUP_CONCAT Extremely slow

I'm trying to use group_concat and join tables using this query. However, it is extremely slow, to the extend which is not possible to apply to production. SELECT a.id, a.`name`, ...
Henry A's user avatar
  • 11
1 vote
0 answers
92 views

Storing Image Filenames As An Array So I Can Add New Values Without Having To Re-Write The Entire Array - MySQL

I have an image library where I would like to create the functionality where users can create boards of selected images. The boards will essentially be collections of images on the site along a ...
pjk_ok's user avatar
  • 111
0 votes
0 answers
75 views

Is there a purpose for UPDATE ... WHERE but with same values?

I am translating some code from PHP to Python, and I came upon this interesting snippet: $sql11 = "UPDATE tbl_pas SET api_id_pas='" . $api['kd_pas'] . "' WHERE api_id_pas='&...
pepoluan's user avatar
  • 187
-2 votes
2 answers
54 views

1 table or multiple tables?

I am building a web application (php/mysql). There will potentially be many users (managers). There is a table (let's call it "gurus") into which a manager/user will enter lists of gurus. ...
Bee Tee's user avatar
0 votes
1 answer
280 views

Secure MySQL database by encryption?

I have cloud webserver running ubuntu where a MySQL database is installed. The database has a table with sensitive data. To protect the data I would like to encrypt the database (or database content). ...
user avatar
-1 votes
1 answer
452 views

How to improve performance of a stored procedure called from a web page?

This is my first SQL stored procedure $sql = ("CALL Login_Details($ID);"); $result = mysqli_query($conn, $sql); $row = mysqli_fetch_array($result); mysqli_next_result($conn); When I run ...
user17456435's user avatar
0 votes
1 answer
374 views

Database schema for marketplace[posts_attributes]

Okay so I am making a marketplace type of website like olx etc.. users can post different types of posts meaning the fields change so I made an extra table called posts_attributes which those changing ...
DB_cont's user avatar
8 votes
1 answer
1k views

What does it mean that PostgreSQL "offers" PHP?

On https://www.enterprisedb.com/downloads/postgres-postgresql-downloads : PostgreSQL runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, macOS, Solaris), and Windows. It ...
user17005195's user avatar
0 votes
1 answer
335 views

Column collision in Left join with many columns vs PHPMyAdmin resultset

I have 4 tables (75 columns each table approx) but they share columns with the same name: Table Master_Producto Master_Product.PD_Prof_21 Table Product_Structure Product_Structure.PD_Prof_21 I am ...
user avatar
1 vote
3 answers
4k views

MySQL: Why not create an index on every column? What is the cost of indexing a column?

I know I shouldn't have an index on every column, but I don't know WHY. What is the cost? I have a system with about 400 tables, many of which have datetimes or foreign keys (which might not ACTUALLY ...
Bing's user avatar
  • 143

1
2 3 4 5
14