MySQL is an open-source, relational database management system. If your PHP code uses MySQLi, use the MySQLi tag instead.

learn more… | top users | synonyms

0
votes
1answer
34 views

Get all recipes from database with the cheapest ingredients

I have the following query which tries to get all the chepeast products linked to my recipies and it takes 10 seconds to return from the database: ...
3
votes
1answer
33 views

Backup MySQL database for Django projects

I have a usual Django application with a single MySQL database. The purpose of this shell script is to backup a MySQL database every midnight by crontab and check that everything goes right. The ...
3
votes
1answer
33 views

List users, ordered by accuracy of soccer match predictions

I have a solution to make a ranked list of users that are predicting soccer scores. I have 3 tables: matches contains soccer matches information. ...
3
votes
3answers
438 views

PHP-MySQL sign-in and sign-up project

I have done my first PHP-MySQL project with MySQLi connection. Please review this and inform me about security and performance issues. dbconnect.php ...
1
vote
1answer
60 views

Upload bot, using MySQL excessively

I have a PHP bot running on a shared host. My account often get suspended. When I asked to web hosting service, they said that my account suspended because of excessive MySQL usage. There is an ...
-1
votes
1answer
41 views

Convert all dates in an array to date format

I'm returning an array containing dates (and other things) from an API, then looping through the array on the front end to convert them into dates The backend uses Node.Js and queries a mySql ...
1
vote
1answer
40 views

Java MySQL handler for a Minecraft mod

I am studying computer science and recently I developed an application in Java (it is a minecraft mod) that connects a MySQL database and queries to fetch, update or insert data. My DatabaseHandler ...
2
votes
2answers
56 views

SQL Query to display minimum prices per country

I have developed a Tender management System sort of code for one of my client. This is the piece of code : ...
1
vote
2answers
54 views

Iterating over a range of dates in a shell script

I have been working on a script that can be used to automatically pull the batch ids that were processed 4 days ago and which need to be processed tomorrow on the server. The batch IDs from 3 days ago ...
0
votes
0answers
74 views

Retrieving and sending encrypted data from/to database

In my Server class, I have a few methods that handle different queries to be sent to the database. Everything works fine, but I really want to DRY up this class, ...
2
votes
1answer
51 views

Python + MySQL Login system using Twilio API

This is one of my first python projects. I decided to make a semi-complex login system in Python, using MySQL and the Twilio API. The current features are: Multi-account support Two-Factor ...
3
votes
4answers
169 views

User registration and authentication in PHP and PDO

Please criticize as thoroughly as possible, even the smallest thing will be very useful for me. I'm trying to create a safe and easy system to change for future projects. I am aware that it should ...
0
votes
1answer
83 views

Display data from two MySQL database tables

This is my first attempt at PHP PDO. I needed to get data from two tables in my MySQL database. I'm pleased to say the code works, and I was just wondering if what I've done is correct. ...
5
votes
2answers
108 views

Generate SQL query by loop

I need to perform SQL query which will get products from database based on few dimensions which I will pass in URL. ...
0
votes
1answer
92 views

Checking if records exists in a table from a 1-billion row table

I have a data scraping script that runs and scrapes records, saves into the following table: For the records already existing in DB, I need to update the old records if it is not updated for the ...
3
votes
1answer
30 views

Moving WordPress database and files to new host

I've written a script in an attempt to try to automate moving hosts from old hosts to our new docker containers. All feedback and input appreciated! ...
0
votes
1answer
87 views

Connecting to a database and running CRUD operations

I have a database class that connects to a database and runs CRUD operations. I need a critique of how well this class adheres to SOLID principles. A class to run all database operations seems like '...
0
votes
0answers
40 views

MySQL query with multiple union and group by

My database schema is something like this: desc SUB: ...
1
vote
2answers
57 views

Fetching items from database with “Outstanding” status

I am fetching around more than 300000 items through a query: ...
1
vote
1answer
74 views

Laravel generate category list from product results

I have product results with some filter, and the one is category. I'll get the category list from product results. the model category and products is one to many relationship. This is the search ...
7
votes
2answers
85 views

Multiple SELECT with LEFT JOIN to order results

I have two tables, looking like this: Table 1 ...
1
vote
1answer
31 views

Extracting site visit information from a REST API call, including addresses from a MySQL database

I'm building a web app that pulls data from a ticketing system via REST API. I'm currently able to pull all of the data I need just fine but the loading process is really slow. I'd love any feedback ...
1
vote
1answer
31 views

Getting the last post of all threads

My MySQL query is loading very slowly (over 30 secs) and I was wandering what tweaks I can make to optimize it. The query should return the last post with the string "?" of all threads. ...
-1
votes
1answer
31 views

Is the format of this PDO mysql statement correct

I have been writing simple php programs, trying to adhere to the PSR standards, for writing code. However they do not seem to have any standards for writing mysql PDO statements in. For example I ...
2
votes
1answer
36 views

Eliminate redundancy from session authentication

I have a session authentication script and it works, but I can't find a way to eliminate the redundancy where the two database queries are. One checks if the cookie has a corresponding entry, and the ...
2
votes
1answer
53 views

Get all company branches using stored procedure

Am creating an application for a transportation company that will store information about their drivers, the cars they drive and to what branches and districts they belong to. I have a branch table ...
1
vote
3answers
64 views

Three PHP database queries to manage accounts

I have a database connection PHP file which has a lot of queries to the database. Here are 3 of the functions that I am using: ...
1
vote
0answers
35 views

API with security through a private and public key

I want to make users login into an app. The code on my server serves a "token". This is based on a salt that is saved for each user, the login date, expDate and the ...
2
votes
0answers
71 views

Query for searching for the best transportation

I made a website where is possible to search for the best transportation from a place to another. For instance, if I need to go from Berlin to Bremen, the website will search in its internal database ...
4
votes
6answers
69 views

Insert values into two different but similar tables

I have a combobox with two items. And if one is selected I want to write data to "salary" table and if selected another, to "other" table. The difference between two code blocks is only one word. I ...
1
vote
0answers
19 views

auto_increment composite primary key with MySQL InnoDB

The intent is to have an auto_increment composite primary key on a InnoDB table which mimics the behavior as on a MyISAM table. The following assumes (3) InnoDB tables all with an auto_increment ...
3
votes
2answers
97 views

Checking a user's emails using an ID

I'm trying to do this: Getting user's ID based on his email name. Using that user_id to check all his emails that have been sent for him so far. ...
2
votes
1answer
81 views

MySQL statements to update overlapping database entries and insert new data into various tables

As I've mentioned in previous questions, I am writing MySQL statements to update overlapping database entries and insert new data into various tables. My database design looks something like this, ...
1
vote
0answers
27 views

Export database values as csv with a helper class

Should I be using getter and setter functions in my class nodeStruct? I am currently using them where there is need to manipulate the input value (e.g for ...
1
vote
0answers
51 views

Printing many-to-many relationships in an HTML/bootstrap table

I need to print the many-to-many relation ship in my tablet. However, I don't know what to do for my case: I tried tons of ideas, however, I may have done something wrong because nothing worked. Here ...
1
vote
1answer
47 views

Database connection in MVC model

I followed the tutorial Build a PHP MVC Application and have implemented a database connection. I made a seperate database connection class and I call it in the controller. It works, but now I have ...
2
votes
1answer
47 views

Get all members from each group

I have a table of groups, and a table of members. Each member belongs to one group. This is how it looks (more groups then 2 are possible): Groups ...
4
votes
1answer
66 views

Python program that takes input and runs queries on a mySQL database on it

I've been slowly learning Python so I want to know what the most Python-esque way of doing things are. The scenario is that I'm connected to a database with a Customer and a SalesRep table in a ...
1
vote
3answers
97 views

Selecting a table with multiple ID on MySQL using PHP PDO

I have made a MySQL script to query a table with a set of id using an IN clause and after some reading I found out that there are security issues with it like prone ...
6
votes
3answers
71 views

Running a MySQL query with an admin class

This is my admin class, DB class and how I use OOP. I am looking for ways to improve my code to make better use of OOP. Please help me if you think I can improve my code in some way. db.class.php <...
1
vote
2answers
56 views

Method to get user information (OOP / MVC approach)

I coded a small user script with PHP. I'm improving the script, learning from my mistakes. I recently learned about object oriented programming and wrote 2 big god classes (user class and message ...
2
votes
2answers
104 views

PHP MySQL connection class

I'm trying to build a class that connects to the database. It does the job but it is not very elegant. I also have no understanding of singleton class or dependency injection. Is this safe? Can you ...
3
votes
1answer
90 views

More efficient method to check for duplicate database entries?

I am saving company information in a database, and if repeat information is found, I want to update the overlapping rows. Some of the supported fields are emails, phone numbers, organization names, ...
2
votes
2answers
88 views

Level system in a gamification platform

Currently, I'm working on gamification platform and I have the following rules for achieving a new level: Level 0: When user registers Level 1: When user confirms account Level 2: When user ...
2
votes
0answers
23 views

Search Indexer Transaction Safety

I am writing a search indexer for a site I built. It counts the number of times a word is used in a given story allowing one use of the word per chapter. I have also attempt to weight words in the ...
4
votes
2answers
106 views

Social network queries for profiles, posts, and followers

The code below is for a social networking system. The problem is that when there are many posts and many followers, the performance is slow. Is something wrong with the queries and the script below? ...
1
vote
0answers
27 views

Returning direct status changes of user statuses

I have a query which returns direct status changes (no intermediary changes) of user statuses: ...
1
vote
0answers
27 views

Database table for WordPress plugin

Is there a better solution to create a database table for a WordPress Plugin? How can I simplify this query? What code improvements could be made in this code? Any ideas would be great. ...
4
votes
1answer
94 views

Migrate files from MySQL BLOBs to PostgreSQL largeobjects

As title says, this piece of code migrates files (binary and metadata) from a database to another one with different structure. Currently my problem is that when I have to deal with a big database (...