I have Product and Booking entity and I’m trying to select products that aren’t already booked in a given period. In other words, to select available products during a given period. To make myself understandable, see the schema below. I only want to select product that have a booking like #1 or #5 since it is available. If a product
Tag: php
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
How to convert SQL query in laravel query?
I know this question is not asked in a well manner way,so I am sorry,I have SQL query this one I want to convert it in PHP laravel query form so tried this query but I don’t know SQL and even I am not understanding how I convert it, can someone help just convert SQL query to laravel query? here
WooCommerce sql query to find products with a specific meta key and meta value
I am trying to get products with a custom field with value condition from DB. Custom field is named: “_filtered_product”. I want to get products only with value = 1 This is SQL query I have written. Answer Not sure why you want to write your own sql query for this simple task, while you could use wp_query! That being
Php – cannot create new database record because primary key is null (autoincrement)
There are two tables: address and person. person_id (primary key, autoincrement) is a foreign key to address. I am trying to add an address record and person record from the same form but am getting this error. Uncaught Error: Attempt to assign property “person_id” on null in C:xampphtdocsappcontrollersMain.php:22 Stack trace: #0 [internal function]: appcontrollersMain->insert() #1 C:xampphtdocsappcoreApp.php(52): call_user_func_array(Array, Array) #2 C:xampphtdocsindex.php(4):
MySQL PHP insert new row where rowNum column values always remain chronological by date and time
I am trying to create a SQL query (or multiple queries and logic in PHP) to insert new rows into MySQL db table (say table name is student) where the rowNum column values always remain chronological dependent on a separate date/time column. This means that if the row I’m inserting has the greatest/max/latest date/time it should be inserted normally and
Laravel – Get sum of a column without querying to database more than once
My table structure is like this: but now I want to move the gift to another table since the gift can be given to the users more than once in different dates. I have used $user->gift in many places in my project and I don’t want to change the code. So I want to create a method in User model
I wanna create a new table from the data of two tables
I have a A table to store the product name, the quantity and input day of goods in stock. In adverse conditions, invoices for the above products will be sent later. I will put the product name and invoice quantity in B table. The problem here is that I want to check the quantity of goods with invoice and without
How to improve a mysql COUNT query for speed?
How can I improve this query for speed? at the moment it’s taking a couple of seconds only to load the php file where the query is without even querying anything. I’ve an index on skillsTrends, jobtitle and industry. Collation: utf8mb4_unicode_ci Number of records < 1,000,000. Answer Try this covering index. It should help the performance of your query. And,
Insert price to the pivot table
I am trying to insert data to a pivot table order_serrvice using arrays I follow this code: https://blog.quickadminpanel.com/master-detail-form-in-laravel-jquery-create-order-with-products/ the column qty and service was inserted properly but the price does not, I dont know why? order_service table: OrderController: with dd($request): dd($price[$service]) Data base outbut Can any one help? Answer In your controller, you are misusing the attach() method: The attach()