In MySQL, I have INSERT … SELECT ON DUPLICATE KEY UPDATE query as below: UPDATE: This is the result from above query. Now I want to create an array of the user_id of either the insert or the update the records. So, my expecting array should be I tried it something like this, but it doesn’t work for me. That
Tag: pdo
How can I print the connected database information (such as db name) in PHP?
I am trying to execute an SQL query in PHP but even though the DB has been connected it returns 0 rows, but when I try to execute the same query in MSSQL it returns a row. I have tried the one below but it returns just Boolean false: Here is how I execute my query: I just want to
PHP MySQL loop through the rows and print date when the date changes
My messages table is like this: This is my query used for fetching messages: I want to use created_at timestamp field to group messages in such a way so that I can display date when the message transactions took place. For example: I therefore want to print a new header containing date each time the date changes. My current PHP
shopping cart with PHP and connected to the MySQL
Good evening, I am currently working on the implementation of a shopping cart through PHP and MySQL, I am getting the following error at line 172 onwards, I have been looking at the quotes but I cannot find the problem, what could be the solution to this? I have been changing this cart from a mysqli version of it into
How to group by two columns in mysql
I am building a chat website, I have a table that contains the following columns, from_id, to_id, messages. The from_id is the id of the user that the chat is from and the to_id is the id of the user the chat is sent to. Now I want to get all the chats but I also want to group it
sort details order by user id from another mysql table by activity less than 3600
I wish to fetch all users from “members” table but also check if the member_id from members table and user_id exist in”login” table and then see if column “activity” (current_timestamp) is less than 3600 seconds in login table than order those users on top rest users if don’t exist in login table shows those users in bottom? how cani query
Connecting to multiple MySQL database in single php app [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I’m trying to connect multiple mysql databases to a single php web app. I’d like each user to be able
How to get all items that are tagged Tag1 AND Tag2 AND … for a 3-table tag solution
So I implemented a 3 table tag solution, als indicated in this classic post (so-called “Toxi” solution). Everthing works splendid, the only thing I struggle with is to get all items that are …
How to set pdo timezone at connection
I have this code where I connect to database and the code is working properly. However the now() function of MySQL is out of sync with PHP set default time zone function. I am comparing the PHP date with MySQL now. Therefore, I wanted to set the database time zone as well. I wanted to set the database time upon
How to update rows with new values for groups found and make this as fast as posible?
I have a table which have these fields: id, client_id, visit_id, number_of_visit. This table can have from 30k to 100+k rows of data. The primary key is client_id and visit_id. (I cannot have a row with these two values being the same, but meanwhile client_id can appear more than 1 time having different visit_ids and so on). The thing I