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

-1
votes
0answers
8 views

Correct form of passing $variable to mysql [on hold]

I am wondering which of the following two examples is the correct or safe form of passing a variable to database: Example one with dots and double quotes ...
1
vote
1answer
34 views

Hibernate insert with foreign key

Ι have the following database: ...
0
votes
0answers
18 views

Converting static SQL query to dynamic [migrated]

I've created my first dynamic, OO, SQL query in Drupal 7 and I'd like feedback. I have a static query (below) that works. I'm trying to create a dynamic query so I can use the 'pager' extension. This ...
0
votes
1answer
38 views

Solved the problem. Might some cleanup and/or advise

I wanted to display 1 outcome of 1 single custom field or attribute in the category overview, using a third party customfield extension in my J! and VM website. I got it working using the code below. ...
3
votes
1answer
33 views

MySQL class that handles sanitization

I've written a MySQL class that handles sanitization of different data types. The reason I used this (and not prepared statements) is because this can be more dynamic. Prepared statmenets only ...
0
votes
0answers
2 views

Database : what design to point on two possibilities? [migrated]

I am designing a datamodel for a new project. One of the requirements specifies that some objects can point either a person or a company. What is the smartest way to achieve that? I have thought ...
3
votes
1answer
48 views

Python CSV command line tool to import CSV into MySQL

I've written my first Python program longer than 15 rows and, of course, it looks terrible. I'd be very glad to receive comments and suggestion about how to implement a similar tool correctly. ...
1
vote
1answer
20 views

Shoping cart code using a loop to print multiple times [closed]

This code belongs to a shopping cart which I want to print multiple times with the help of a loop. There are 9 SQL queries and I want all these queries to run at a time with the below table every ...
4
votes
2answers
270 views

Efficient use of MySQL Connections with Java

Background: I'm building a dynamic in-house on-call roster that will be displayed on a web page. The end user will be displayed a list of people who are currently (at the time of the database call) ...
3
votes
1answer
54 views

Checking referential integrity of a database schema

I am using PHP PDOs to parse the results I am receiving from MySQL queries against a database. I am now running into an issue with running out of allocated memory. Are there any suggestions on ...
1
vote
2answers
106 views

Am I correctly implementing PHP/PDO and the MVC/DAO pattern?

Context: I am working on the login module of a PHP web-application and I am trying to implement this using PHP/PDO and the DAO pattern. I would like someone to review the code below and let me know ...
2
votes
0answers
36 views

Fetching player data

I would like to select some information I have stored in my MySQL DB. I have 2 tables gameTable and playerTable. Now I want to get the gameTable and get the names and levels of these players. How do ...
2
votes
1answer
84 views

Class method to insert a record into MySQL

I'm just starting out using OOP; classes and methods etc. I've been looking around for some PDO classes/wrappers out there, but there's not much to choose from. So I've tried to make my own. Started ...
6
votes
1answer
43 views

Is there a better way to split out join'd table data?

Consider the following segment of code: ...
3
votes
2answers
339 views

Importing MySQL Database to a .txt File

We just finished working on a Database project in Java Netbeans. We added the feature Import which will import the database record of one user to a text file. ...
3
votes
1answer
63 views

Matchmaking system - sorting musicians by skills, genres, and location

I'm making a matchmaking system using PHP and MySQL which allows users to search through a list of musicians so that they can find people with the right skills and interests who are near them. It ...
1
vote
1answer
62 views

PHP PDO / MySQL helper/wrapper functions

Further to my previous post for a user login script I've been learning PDO in order to migrate from mysql_* functions. As before with mysql_*, I wanted to wrap the PDO code into wrapper functions, so ...
-1
votes
2answers
38 views

MySQL query in nested loop to get scores and averages for students

I am trying to get the scores and average for all assignments for records in a MYSQL database. The code below works but seems to take quite a bit of time to run because of the nested while loop. Any ...
0
votes
1answer
76 views

Combine Mysql limit query

Is it possible to combine these queries into one query? I am trying to see and average all scores but also count and average just the last three based on the same grouping. This is the main query: ...
3
votes
1answer
20 views

Virtual Airline Dispatch Generator

This Code is old and I am trying to figure out how to improve it. I am considering running the distance function in MySQL, but it is a ***** to figure out for me due to my experience with arithmetic ...
6
votes
5answers
366 views

Database abstraction in Java

I am working on a project in Java which includes a lot of database related tasks. For instance, I would have to insert, update, retrieve data so many times within the application. To use code ...
6
votes
2answers
77 views

Database access concept

I've got a small tomcat web application that's used to receive customer data from an iPad app. After receiving those information they will be saved on a local MySQL database and then sent to an SAP ...
1
vote
1answer
128 views

Two tables for storing comments

I have two tables for storing comments comments ...
4
votes
2answers
448 views

Voting system for a website

I am currently adding a voting system to my website. Below is my voting class. I feel that it could be simplified and that there is repeated code regarding the functions, although to the best of my ...
1
vote
2answers
60 views

SQL Data Fetcher for CMS

I am creating a CMS for a website, so I've added most of the functions that will fetch data from the database to a separate class. The code doesn't seem to have any bugs(Since I've tested it) but I ...
5
votes
1answer
176 views

Efficient Pandas to MySQL “UPDATE… WHERE”

I have a pandas DataFrame and a (MySQL) database with the same columns. The database is not managed by me. I want to update the values in the database in an "UPDATE... WHERE" style, updating only ...
3
votes
0answers
65 views

Custom session handler

I'm new to PDO and haven't been coding in a while. Is the following custom session handler industry-acceptable? ...
3
votes
1answer
43 views

Join - order by vote-sum and check if user has voted

I have a vote and a comment table. Now I want to display all comments and order them by votes-sum. Sum because some votes can have a higher value than others. Therefore I want to display if the user ...
3
votes
3answers
262 views

Cron PHP script to pull newly added clients from remote db, add their information to local db

I wrote a PHP script and was wondering if it was well written or if it could be improved upon to read or run more efficiently, any help or critique would be greatly appreciated. The file will be ...
3
votes
2answers
57 views

Small library for logging to MySQL

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. This library is going to be used from all of my other programs ...
6
votes
1answer
37 views

Implementing EXCEPT functionality for social networking exercise

I am taking Stanford's Introduction to Databases Self-Paced online course. I have gone through the videos in the SQL mini-course, and I am having trouble completing the exercises. The following is ...
2
votes
1answer
43 views

Simplify SQL query that utilizes GROUP BY and HAVING BY and uses aggregation

I am taking Stanford's Introduction to Databases Self-Paced online course. I have gone through the videos in the SQL mini-course, and I am having trouble completing the exercises. The following is ...
3
votes
2answers
111 views

Is my login system secure?

I am recently making a CMS and I need a secure login system, so this is my code. How is it? First: the HTMLcode for signup and login: ...
3
votes
1answer
40 views

Query about advertiser calls times out

I'm a bit of a rookie MySQL coder and I've been tasked with building a query that will join and filter several very large tables (one with ~210 million rows, one with 10 million, one with 2.5 million, ...
5
votes
3answers
62 views

Performing database interactions

I wrote this CRUD class in PHP that has methods to do database interactions, but I want to know if it is good/secure/elegant? It works fine and all and it hasn't ever given me any troubles, but I'm ...
3
votes
2answers
123 views

Finding max rating for a movie

I am taking Stanford's Introduction to Databases Self-Paced online course. I have gone through the videos in the SQL mini-course, and I am having trouble completing the exercises. The following is ...
3
votes
2answers
92 views

Displaying a random poem from a database

I'm new to web development, and I'm constantly torn between good code and bad code. I was wondering if you could help me improve my following code and see if I'm doing it right in terms of how I use ...
2
votes
1answer
48 views

SMS relay --> MySQL database

The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps: ...
2
votes
1answer
83 views

Open source Pastebin tool made in JSP and servlet

I'm a student and still studying. I just made my own Pastebin tool to generate source code. I've also contributed this project as an open source. You could see this project from here. If you wish to ...
5
votes
2answers
74 views

Optimise web panel users statistics query

Details Can anyone instruct me on a more optimised way of querying this statistics of registered users? I currently lack the knowledge to create a better query. Right now it works fine, but I want ...
1
vote
1answer
74 views

Magento MySQL search based on phone number

I'm building a search for Magento. Magento API doesn't provide an easy way to look up a customer using a phone number so I created a custom solution. My MySQL/PHP OOP skills are limited. Did I miss ...
2
votes
1answer
39 views

SQL query to order by the difference between FIRST and BEST scores

Can anyone help me optimise this query? I have the following table: ...
2
votes
1answer
141 views

Uploading images via MySQL in Blob

Is it safe to upload images via MySQL in Blob? I've constructed my code like the following: ...
1
vote
0answers
34 views

Selecting all posts with a certain tag

The task is to select all posts tagged with a certain tag, along with other tags the post may have, given as text rather than ID. Table posts ...
1
vote
1answer
60 views

Handling errors when using PDO to connect to a database instead of MySQLi

What would be the preferred method for handling errors when using the PDO to connect to a MySQL database? I was using mysqli_error($this->pdo), but I heard this ...
2
votes
4answers
67 views

Selecting three stylesheets in a specific order

I'm somewhat new to SQL (only had to use it in Database classes). I have a simple table of stylesheets, from which I want to select specific ones in a specific order (e.g. reset, then layout, then ...
3
votes
0answers
76 views

Instagram-like news feed display

I am writing an application that shows a news feed, much like Instagram. For this, I have a function in the model to select the feeds as shown in the code. For some reason, this runs quite slow and I ...
2
votes
0answers
73 views

Programming with PHP & jQuery

I'm programming a system and I want to know if this is the correct way or if there are a better way to do it. Container: I have more fields but I only added one to show you the container. ...
1
vote
2answers
89 views

Class for multithreaded insert into database

Here I have class that supposed to take dictionaries of product objects and their articles (kind of unique identifier) from queue and insert or update them in database table. Received dictionary ...