Skip to content

Tag: mysql

Call to undefined method but it is defined and it works in index.php?

I have a small php project with OOP. I have 3 Klasse that represent the Objects User.php Transaction.php and BankAccount.php. They work fine if I’m in the index.php but as soon i go to an other site it states: The project structure is like this app/public models Database.php User.php Transaction.php Ban…

Updating multiple tables in SQL using an Array

Currently I had a table called crm_leads for my Leads page where I already have many records. Now for the same page I have created few new fields which is now going to be stored in another table called crm_leads_details. Now I’m storing all my POST values in an array format like so: Now in my model I&#8…

Refactor database schema on migration

This is my initial migration Now, the easy time ended and now I have to move name and phone to customer table. This is my create customer migration. I don’t know where to do this operation so I just throw all in the migration. And alter order migration Now I’m stuck with empty customer_id. I have …

MySQL split table amounts based on another table information

I need to split amounts in a table (transactions) accord to another related table information (bill_details). Base table (transactions): ID amount document_id 1 100.00 11 2 80.00 12 3 120.00 13 Another table (bill_details): ID amount document_id description 1 20.00 11 A 2 60.00 11 B 3 20.00 11 C 4 80.00 12 D …

Alphabetic ordering for names

I have been struggling with this for almost 2 days now and i just can not get it to work myself. Basically my goal is to make a list from A to Z, with values from a database. Example: Now my php code looks like this: Now, it does work when i put strings inside the array and remove the

PHP MySQL GET RESULT from INSERT INTO IF NOT EXIST

I know how to do INSERT INTO if the record doesn’t exist. But if it does exist, mysql doesn’t treat it as an error. It just treats it as 0 rows inserted. I want to know if that was the case and return that message to the user that the data they submitted already exists. I know I can do