Questions tagged [mysql]
MySQL is an open-source, relational database management system. If your PHP code uses MySQLi, use the MySQLi tag instead.
1,091 questions
0
votes
0
answers
16
views
My first attempt to insert and retrieve data from a MySQL database using the boost::mysql library
About the Project
This was a go/no go prototype for a project that would store the data a combined personal planner software with project planning software in a relational database. It was also a ...
1
vote
0
answers
22
views
Inserting and retrieving data MySql Database access in C++ using Boost::ASIO and Boost::MySQL
About the Project
This is a unit test and a prototype for the database portion of a project that would store the data a combined personal planner software with project planning software in a ...
2
votes
1
answer
47
views
Cmake build system for prototype planner software using boost and other previously written code
I'm prototyping/debugging some C++ code that I may turn into a longtime project. The build system is ready for review, the prototype is not.
The GitHub repository for the code listed below.
Like all ...
6
votes
2
answers
695
views
Weather Observation Station 8 query
Here's my (correct) solution to a HackerRank question:
Weather Observation Station 8
Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last ...
3
votes
1
answer
74
views
A function that returns correct number of inserted, updated and skipped rows for INSERT or UPDATE query
When MySQL executes a Data Modification Query, it provides some additional info on the outcome, which is usually displayed in the console. This info is also being exposed through MySQL C API and this ...
5
votes
3
answers
1k
views
Slow SQL query with nested subquery
I have written the below query in order to identify how many events (occur over a week) in each hour.
...
4
votes
2
answers
481
views
Improving upon the Security of my Export Remote Database to Local PHP API
I am working on an in-house application, and I am working on how our application communicates with our remote server.
I have a PHP script that acts as an API to call to our MySQL DB and dump its ...
7
votes
4
answers
2k
views
Program for an employee database using python
In this program I'm defining functions to perform different tasks on a data record book for employees.
Here is a summary of the code:
Intro() to make the presentation of the home page.
create_record()...
0
votes
0
answers
68
views
Connection pool design for Boost MySQL
I had to design a connection pool that handles Boost MySQL connection to use the asynchronous functions.
Here is the code:
...
3
votes
1
answer
137
views
Faster Query to Track State changes in a Large Table
I have a table that tracks state changes of an entity with timestamps. The schema of the table is as follows:
entityid
userid
originalvalue
newvalue
changetime
255
101
Draft
Submitted
2023-11-28 12:10:...
4
votes
1
answer
135
views
Evaluating Extended Operating Hours Past Midnight Across Timezones in PHP
I am working on a project that involves tracking the operating hours of businesses across different timezones. Some of these businesses operate past midnight, and to accommodate this, operating hours ...
2
votes
1
answer
258
views
MySQL interval search query suggestions
My database structure is:
...
8
votes
3
answers
1k
views
A simple PHP login form with PDO
I wrote a simple PHP login form for a website. It has an initialization script, as well as a form to allow a user to login, plus a link to log the user out after logging in.
...
3
votes
1
answer
126
views
Consuming sharded database using node.js
I think the only big improvement that can be made is to check which shard to query based on the userIds of the followed users. One easy way is to check the last ...
3
votes
1
answer
104
views
SQL query creating tables needed by a simple PHP CMS
I have written recently the SQL query to MariaDB that I want to move into PHP code. Below is my test.sql file. What do you think about my SQL code?
...
2
votes
1
answer
96
views
delete rows based on references to other tables in a mysql database?
I have a database with the following hierarchy.
A dataset can have multiple scans (foreign key scan.id_dataset -> dataset.id)
A scan can have multiple labels (<...>
1
vote
1
answer
123
views
mySQL adjacency list model : Always retrieve parent and children/siblings
Iâm using mySQL to create and adjacency list model type of table. I have only one level, that is a parent with children, like this:
...
0
votes
1
answer
87
views
PHP login codes suggestions
Now i have a fully functional PHP codes for login and registeration i was wondering if anyone could offer improvements to the code
The code:
Config.php:
...
0
votes
1
answer
162
views
Follow up to Validation Script in PHP
So I've implemented the suggestions in Original question
And now my code looks like this:
...
2
votes
1
answer
148
views
PHP Validation script
The code below is modified slightly from the code in this previous post.
I believe the code below could be improved and more secured but i don't know how so someone please show me how an improved ...
0
votes
1
answer
263
views
SQL & PHP login method
My code is working however it seems to be using old outdated php version so less secure and I'm still new to programming so I'd be more than thankful if someone shows me how an improved updated and ...
3
votes
1
answer
425
views
blog RESTFUL api with posts and comments
I built RESTFUL api for a blog using java and spring boot(without a frontend).
What it does
the code manages all the http methods on a post inside the blog and comments on that post.
the post consists ...
-1
votes
1
answer
280
views
is my code protected against SQL injections?
im using spring boot and CrudRepository for my queries, the project is about posting content on a blog, so I have a post record with id, creator name, post name, the content itself likes and dislikes:
...
5
votes
3
answers
2k
views
Count unique visitor using IP address and make sure that 24 hours has passed before incrementing the counter
I've created a unique page counter using a PHP script. Pages could be videos, images, publications, etc.
Every time a new user views a page, I record the entry and increment the view counter.
I cannot ...
1
vote
2
answers
86
views
backend Database authorization app using MySQL [V2]
here is my first virsion question: Is it good practice to have all my back end in one single file with all functions being static?
...
1
vote
4
answers
188
views
3
votes
1
answer
252
views
PHP MySQLi Wrapper Class For API
I've never had my code reviewed before, so I am taking this opportunity to see what can be improved with my coding style. I am still somewhat "new" to PHP, in the sense that I'm an old dog ...
3
votes
0
answers
94
views
Create table of yearly monthly temperatures from monthly data
I've got a series of tables with monthly data on USA regions over about 130 years, divided by either climate divisions (clim_div) or other federal standards (ncdc_fips). They all follow the same ...
-3
votes
1
answer
108
views
Preventing PHP SQL injection on login [closed]
I had a login code like this:
...
1
vote
1
answer
418
views
Three way Eloquent relationship definition and saving in Laravel
I'm building a Laravel app (with Vue3 and InertiaJS), and I'm attempting to create relationships between three models:
User
Area
WorkHours
where WorkHours is the ...
1
vote
1
answer
65
views
Find offers that can be matched with bids
I am working on a sql query for the following scenario:
Get all available offers for registered demand (offers from profiles
should not be from profile which had registered demand). After that
get ...
3
votes
1
answer
113
views
Company management app: Extracting data with JDBC and java.sql
I'm currently working on a company management system as a university project, and I have to get my hands in java.sql.
I have come to struggle with extracting a ...
4
votes
3
answers
415
views
Queries to get products selected in multiple stores
Project description
I'm making a website listing products. The listing goes as following (See here):
Product name
Shop name
Price in that shop
If the product appears multiple times in the table for ...
9
votes
5
answers
2k
views
Weekly MySQL database backup
I haven't used Unix, etc. for 40 years, so I am a bit rusty. I need to back up the databases on my website(s) once a week and then retrieve them automatically from my development machine. So this is ...
4
votes
4
answers
534
views
Functions in PHP to run basic MySQL crud
I wrote a list of functions in PHP that I want to use in my pet project as an autoloaded file for all parts of the app. The purpose of these function is to shorten the code you write for MySQL queries ...
0
votes
2
answers
136
views
Search between dates in a WP Query
In the posts I have a date field and a start and end date range. I need to query if it matches date or if it matches between the dates in the range. This Query works, but how can I optimize?
...
0
votes
2
answers
197
views
Version 2: Display visitor's number on your web page (changed code after getting answer for first version)
Version 2: Display visitor's number on your web page (changed code after getting answer for first version).
The first version is here: Display visitor's number on your web page
The "visitors&...
0
votes
1
answer
292
views
Display visitor's number on your web page
Display visitor's number on your web page.
The "visitors" table has only one column (visitor_count) and only one row. The column's initial value is 0.
I know goto should not be used but then ...
3
votes
1
answer
250
views
Proper PDO connection function
I am reviewing the database class for a live website. I am not sure if the current connect function is the best way to create a pdo object as it appears to create a new connection every time it is ...
5
votes
1
answer
107
views
A procedure that receives a letter and a number that shows for example : (A,3) A AA AAA
Make a procedure called paintletter, it receives two parameters,
a letter and a number. it will have to paint on the screen lines with the specified letters starting with a letter and ending with as ...
3
votes
1
answer
55
views
MySQL procedure to extract a letter from a phrase
Create a function called GETLYRICS, which will receive as parameters a word of at most 15 letters and a number. It must return the letter of the position indicated in the number.
My exercise is fine ...
2
votes
1
answer
700
views
SQL query to find expenditures of employees who have exceeded their limit
I've 2 tables emp and expenditure.
Emp:
ID, NAME
Expenditure:
ID, EMP_ID, AMOUNT
Each emp has a limit of 100 that he/she can ...
2
votes
1
answer
272
views
Optimization of laravel pivot table relationship
I have a pivot table called invite_riskarea which is designed as follows:
This table stores the permissions that have a specific user (through an invite id) to ...
-3
votes
1
answer
60
views
2
votes
1
answer
40
views
Shell script to backup db from mysql whether the mysql server is running in docker
I have written this shell script to backup MySQL database to disk. It works fine but I am not well proficient in shell scripting. So what do you think can it be improved?
...
1
vote
2
answers
116
views
Having trouble deleting multiple queries (PHP, MYSQL)
I'm having trouble making WHERE IN query work, I was only able to make it work as a foreach loop.
My payload looks like this:
sku[]: BOOK0002
sku[]: BOOK0003
My ...
1
vote
1
answer
182
views
Is this session manager secure?
I'm looking for best practices for writing secure session managers.
I'm making a table for the authorization token (UUID OR GUIDv4) with autoincrement, user_id, token, status (enum) then update status ...
1
vote
1
answer
153
views
Validate avatar image
I want to know if that code is correct and readable.
In class avatar the method getAvatar() validates the data. It checks if the field is not empty and if the photo extension is correct. If not, an ...
2
votes
1
answer
77
views
Calculate time interval excluding breaks
I have a solution for a question I asked on SO:
I am trying to create a database where I also need to find the time
difference inside a record. However, timediff() ...
0
votes
4
answers
631
views
table name column name from GET parameter
This is a function that reads a setting data from DB.
...