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.

141 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
1answer
2k views

compare results between two select queries MySQL

I'm making test application where users will input their select queries in input box and the application have to compare them if they are identical with "correct answer" query. "Correct answer" query ...
3
votes
1answer
940 views

PHP MySQLi Lock Tables Query Sometimes Does Not Complete

I am attempting to lock some tables while running some code and unlocking the tables when I am done. Process: Run Lock Tables MySQL Query. Run some PHP Code. Run Unlock Tables MySQL Query. While ...
3
votes
0answers
216 views

Inputting auto-incrementing, grouped, unique hashes?

Alright, here's what I've come up with so far: SET @id=(SELECT IFNULL(MAX(id) + 1, 0) FROM leads); UPDATE leads SET id=@id WHERE id IN ( SELECT id FROM (SELECT * FROM leads) AS something WHERE ...
3
votes
2answers
95 views

Missing DB entries

I have run into a problematic situation. I oversee the administration of 5 php web pages on one server, each having their own database. All pages work like interactive forms drawing and storing data ...
2
votes
0answers
116 views

SQL Server stored procedure not throwing certain kind of error

I noticed an issue in my app recently where an database insert that occurred in a stored procedure was failing, but no exception was getting thrown. The insert failed because a column that doesn't ...
2
votes
1answer
718 views

MySQL Stored Procedure not throwing error if it contains a query that succeeds

I am writing a simple MySQL Stored Procedure, and calling it from PHP using PDO. This is just simple enough to illustrate the problem I'm having. This procedure test_procedure_2, does not throw any ...
2
votes
0answers
63 views

Redesign query/database because of high load

Need help with query or redesigning the db. Please bear with me the query will be changed to pdo ASAP. I'm not a DB admin, nor am I some MySQL wiz. I have the following tables: CREATE TABLE IF NOT ...
2
votes
0answers
33 views

Query to send users message within a crm

I need help understanding the logic of a query I`m trying to write. I want the employees to be able to message other employees. I need the employee to see the list of all employees he can send ...
2
votes
1answer
22 views

need to correct this Query/Loop to find and start “new branch” in the output

given these tables: PERSONS person_id fname lname info 1 LB Johnson "info..." 2 Bobby Baker (null) 3 Malcolm Wallace (null) 4 Billy ...
2
votes
1answer
907 views

MySQL deleting lots of rows by id - where in or loop over each row in transaction

I have a delete query which is potentially going to delete tens of thousands of rows. Currently it's taking quite a long time in the more extreme case (over 100000 rows to delete) using this: ...
2
votes
0answers
100 views

Is this user-storage database system efficient, effective and secure?

I am using: PHP Version 5.2.17-MIT-BACKPORT-GnuTLS SQLite 2.8.17 I have a database called users, which currently has a table called root. There will be others, once I get all the rows for root ...
2
votes
0answers
208 views

MySQL high performance difference between two similar databases

I'm currently upgrading from TecDoc 2015 Quarter 2 database to TecDoc 2015 Quarter 4 database. Q2 Database: 240,838,107 rows InnoDB utf8_general_ci 23.2 GiB Q4 Database: 265,508,380 rows ...
2
votes
0answers
66 views

Caching impression counts to avoid mysql inserts

We currently get a lot of mySQL inserts/updates on duplicate daily (millions) and we're looking at speeding up the application by using some form of counter with memcached and then clearing it on ...
2
votes
0answers
983 views

Sync a local MySQL database and a live server MySQL database

I want to store data in my local MySQL database and after a time interval or when system connected to internet it will update my live MySQL database remotely. Is it possible? I have an inventory ...
2
votes
0answers
380 views

How to send MySQL query results to outfile and standard output at the same time?

I "normally" query MySQL with SELECT col1, col2 FROM tablename LIMIT 10; and sometimes instead send the output to a file with SELECT col1, col2 FROM tablename LIMIT 10 INTO OUTFILE '/path/to/...
2
votes
3answers
1k views

How to select different format of the date in mysql

0 down vote favorite. I have this table and I can't change its format to yyyy-mm-dd because I have so many scripts that are related to this format dd-mm-yyyy. It would be a mess if I change its ...
2
votes
0answers
148 views

mysql vs mongodb cache/load balancing

I have a system where users can 'like' content. There will likely be many hundreds of these likes going on at once. I'd like it to be AJAX driven so you get an immediate response. At the moment I ...
2
votes
0answers
2k views

SQL query optimization in Prestashop e-Commerce solution

I'm working on a layered navigation module within Prestashop e-Commerce solution. I'm trying to optimize a SQL query which creates a temp table during execution. I think this is creating a ...
1
vote
0answers
18 views

How to prevent a record from being affected by the ORDER BY RAND() function?

I am building an online exam site using php and mysql. It's just for MCQ type questions. Here is my database structure: 1) QUESTIONS ( Exam_ID, Questions_ID, Questions_Des) 2) OPTIONS ( Question_ID, ...
1
vote
0answers
40 views

MariaDB DELETE not removing all rows

I'm managing a MariaDB server and I noticed that an application run a DELETE query in a table each time the entity was saved and then it will insert the new rows referenced that entity. Sometimes ...
1
vote
0answers
22 views

MongoDB / PHP - How to change data type for every occurrence of field in a document

I'm trying to learn how to use MongoDB with PHP. I Have built a web application that loads data from database etc. The issue I am having is that when I import my data from a .CSV using MongoDB Compass,...
1
vote
0answers
28 views

Weird MySQL column name issue

After trying to use the Propel PHP ORM on my database, I noticed that there is an issue with foreign keys. This is a table with foreign keys: CREATE TABLE `appusers` ( `AppID` INT(11) NOT NULL, `...
1
vote
0answers
119 views

MySQL count rows of multiple tables for each user

I basically need this with some adjustments, I just can't seem to figure it out how to do it. I need to sum the rows of two tables, for example: SELECT student.StudentID, student.`Name`, COUNT(...
1
vote
0answers
65 views

What is the proper way of designing database with dynamic fields in MySQL + PHP?

I need help on designing a proper structure for a database table with dynamic fields. I am using MySql with PHP and the system I'm currently working on (inventory system) requires a table that accepts ...
1
vote
0answers
52 views

Best practice for large database

I have a mySql database and produce webpages through use of php. I have a database that in simplified form collects data of the form: date|name|score which is unique for date|name. From this ...
1
vote
1answer
17 views

How to determine that the maximum size of the database file is exceeded, and switch the data insertion to the second server?

First I`m sorry for my bad English. My problem is I have one virtual server with PHP backend and one server with one single-table MySQL database. I don't want the file size of the database to exceed ...
1
vote
0answers
371 views

Which method gives better insert performance in mysql db table: CSV import or insert statement

I have combine data from two tables which results in 6727224 rows. I want to insert this data into another mysql db table. Which method should be very fast to insert this number of records. Insert ...
1
vote
0answers
218 views

Can't delete from a table with two conditions using PHP

I am trying to delete a row from a table using two conditions. this is my code : <?php require 'database.php'; $id=0;$od=0; if(!empty($_GET['id_espece'])){ $id=$_REQUEST['id_espece']; }if(!...
1
vote
0answers
1k views

Database design for a multiple choice question website

So I want to design a database schema for MCQ website in which I have several sections ,Lets say 3. and these section will have many sub-sections each. I want to store the questions, choices and ...
1
vote
0answers
1k views

SQL state S1000 in SQLConnect (but not all the time)

I have a CentOS6 webserver and a database server (MS SQL Server 2012). When I use the website everything is going fine except that once an hour or so I get a can't connect error in my php code. I ...
1
vote
0answers
37 views

How to test if the query is taking a longer period of time as our production database is growing?

I would like to have a test (read: whatever can send a mail) in which whenever our query is taking more than 2 seconds to execute, it will send to me an email. If it matters we are using cakePhp with ...
1
vote
0answers
55 views

How can I determine what table a foreign key is used in without a bunch of joins?

I have a few tables as detailed below: Page: page_id (PK), createdDateTime Entry: page_id (FK), entry_id (PK), order, parent, createdDateTime Entry_(type) entry_id (FK, PK), value ((, other columns ...
1
vote
1answer
914 views

MySQL help do I use Where not exist or Join? - Laravel

I have two tables as follows: 1) urls id domain created_at ------------------------------------------------ 1 google.com 2016-11-30 00:00:00 2 test.com ...
1
vote
1answer
494 views

Combine 4 rows based on common ID and Date

I have a query that returns 4 lines per ID. I would like to be able to merge these into one single row in a new table, based on the ID and Date. Can anyone help? I've researched and seem can't find ...
1
vote
1answer
880 views

MySQL/Pivot table for two tables

I was trying to get multiple rows into a single row with dynamic columns created as per the data. I have two tables combined with foreign key. Table 1: | id | name | Invoice value | invoice_date | |-...
1
vote
0answers
746 views

PostgreSQL 9.4 - Allow access from PHP

I would like to configure PostgreSQL 9.4 to allow connections from database users with passwords from PHP on both the command line and through Apache on a CentOS 6.6 box. I installed PostgreSQL with ...
1
vote
0answers
199 views

insertion creates duplicate with same data

I am using MySQL with PHP. I fetch data from a third party using SOAP. I have an issue with duplicate insertion of data. This occurs once or twice a day. Say there are 10 records ready to enter into ...
1
vote
0answers
39 views

Caching impression counts to avoid mysql inserts

We currently get a LOT of mySQL inserts/updates on duplicate daily (millions) and we're looking at speeding up the application by using some form of counter with memcached and then clearing it on ...
1
vote
2answers
3k views

MySQL: SELECT GET_LOCK slow/timeout

I am using "Zebra Session" as a replacement for PHP's built-in session management. Zebra Session stores sessions in a MySQL database, and uses "session locking" in order to ensure that data is ...
1
vote
0answers
646 views

Best way to approach building search functionality using PHP on existing mySQL Database

I am looking for advice on how to approach an upcoming project I am due to undertake. The reason I am asking is that I'm just out of college and the company I work for is currently searching for a new ...
1
vote
0answers
496 views

Question on MySQL insert race condition

I'm using MySQL 5.1, PHP 5.3 and the table is MyISAM. Here's the DTD of this very fake table: CREATE TABLE `temp1` ( `value` varchar(10) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 This ...
1
vote
2answers
74 views

Identifying Unused \ Garbage Objects of a database

How do I find in use db objects from all application pages is there any tool or trick I can use, just like we do search in Visual studio for an object in entire solution
1
vote
0answers
4k views

Occasional disk I/O errors in SQLite

I have a very simple website running PHP and SQLite 3.7.9 (with PDO). After establishing the SQLite connection I immediately execute the following queries: PRAGMA busy_timeout=0; PRAGMA cache_size=...
1
vote
0answers
521 views

What is the best way to manage user access to MySQL via PHP?

I am working on a web application that requires auditing db queries in MySQL. In every application that I have developed or worked on it is standard practice to store the DB credentials in a protected ...
1
vote
0answers
1k views

Need to search users by latitude and longitude

I'm still learning SQL and this is a bit more advanced than my capabilities, so I could use some help. I think I need a sub-query or something. In the database I have a table called user with a ...
1
vote
0answers
547 views

Mysql 5.6 and install php5-mysql , mysql-common

I install Mysql 5.6 with this documentaion(in ubuntu 13.04) , now I need to install php5-mysql and mysql-common packages. can I install them with apt-get? I think they will install mysql5.5 compatible,...
1
vote
0answers
1k views

mysql remote connect

Having troubles with this and I'm not sure why.. I'm trying to access a mysql database from another server. I changed the my.cnf file (uncommented the bind-address to access from all): port=3306 #...
1
vote
0answers
895 views

MySQL Left Join Select all rows

Hi guys I have a query which is pulling data from database : SELECT sandwich_table.id, `sandwich_name`, salad, COUNT(salad), salad_type.type, sandwich_type_table....
1
vote
0answers
408 views

big mysql database optimization

My Joomla mysql database has about 3.4 million rows in content table. It is just static article. Very slow and often use out of resources. To speed up it, I segmented it into 6 sub-tables and added ...
1
vote
0answers
688 views

MySQL GROUP BY and ORDER BY giving inconsistent results

I'm currently working with WordPress, and I've added a new meta value which is a number between 0 and 30. Zero is ignored and up to 30 need to be organised in order and only the latest (based on the ...