I need to access a table by referencing another table ID and by doing so I created first a foreach loop to retrieve the first table data then give its ID reference to the second table. I have done it in my other function but I don’t know in this function prompts me that it’s undefined index. Here is my
Tag: mysql
how to optimize this sql insertion php code?
I have mysql database and I want to insert about 40’000 rows into it from PHP code , but my code takes more than 15 minutes to insert the rows, is there any chances to optimize it? where is my problem(PHP code / database design) ? here are the details: – the row data are stored in a utf-8 txt
Replace column values in result set using a lookup/dictionary array
You can find the entire code below. I have 2 arrays. The first array looks like this: The second array is this: (from a mysqli result set) I want to replace the logMessage values in the second array with the corresponding $replacements value. How it should look: Must be Current code: Answer Maybe something like the following. Grabs the key
Show checkbox values from database in PHP
In Database I have a column ‘language’ which have values English, Arabic, Urdu respectively. Now, I am getting these values and show these values in checkboxes for update purposes. I have to check the checkbox if it matches the value with database value and then make it checked otherwise unchecked. But I am getting the wrong results.. Below code is
PHP MySql delete query
I have a delete script on my dashboard that WAS working before moving domains. ( not sure if that is relevant ) The code for my ‘deletejob.php’ is below. <?php error_reporting(0); $host = '…
Retrieve associated model from different database using cakephp 3
I’m developping an application that will use two databases: A main database to store the app’s data and a second one where I’ll check usernames and other read-only stuff. So I set up two different connections in my app.php: After that I put a method in my Model/Table/UsersTable.php so cake will know that this table uses a different database: I’m
Loop two arrays and access one-at-a-time from first array and three-at-a-time from the second array
I have two sets of data which are in two different arrays and I need to combine them in groups then insert the results into my database. In above I have two set of data.$arr contains the name and $code contains a numeric code. Here I need to insert the code per name into the table as per the user
SQL Argument data type int is invalid for argument 1 of charindex function
I’m trying to convert MySQL query to MsSql query but I’m having trouble. Here is my query: MySQL SELECT *, (SELECT count(books.id) FROM books WHERE books.status = 1 AND FIND_IN_SET(…
How to use SQL prepared statement in php pdo
I create prepared statement for sql that give me the right result in mysqlWorkbench, but when I tried to use the same query with php pdo, it returns me an empty Array. So how to use my prepared statement with php pdo ? This is my code: Answer I found a solution that give me the right result. I create
Laravel: SQLSTATE HY000 2002 No connection could be made because the target machine actively refused it
I am trying to migrate migrations to MySQL database using php artisan migrate in Laravel 5.2’s Homestead on my local machine. I keep getting this error: I can connect to the database just fine using MySQL workbench, but I want to use laravel’s migration feature. My database.php looks like this: Has anyone had this problem before? Answer Use these default