I am having an issue inserting a record into the database. I am a beginner with the Yii framework, so I may have made some stupid mistakes. This is from the SiteController public function …
Tag: database
Relational Databases: Is it fine to have a foreign key referencing an Associative table?
Lets say we have Passengers, where Passengers can attend many Flights, and one Flight may have many Passengers. In each Flight, each Passenger has a unique selection of Movies he/she can watch. For Passengers, Flights, and the association between them, we have three tables: For Movies, it must specify for which Passenger and for which Flight will it be available
Are changes made to DB only through transactions?
I am not able to get a clear complete understanding regarding the role of transactions in databases. I know operations clubbed in a transactions will be executed together and then either committed or …
Calculate read pages through select query in reading progress table
I have a small program that I use to track my progress in reading books and stuff like goodreads to know how much I read per day. I created two tables for that, tbl_materials(material_id int, name …
How chceck is id is used in other column in same table
I’m using MariaDB 10.3 and I have table like: post_id post_content post_user_id post_shared 1 Test1 1 0 2 Test2 2 0 3 Test2 1 …
How can this be witten in Laravel Eloquent term?
I am converting a piece of database SQL query to Laravel Eloquent query but it doesn’t work. My code snippet looks like this: Can someone explain why? Answer So assuming you have a Post model, you can try something like this:
Generate unique Identifier for table
I’m trying to create a table in SQL Server. I want to generate a unique identifier 32 bit and be the primary key. I define it as primary key and set the type – how I can turn on the generation? How I …
Replace Database field based on 2 different Table Conditions
I need to update the table based on email matching condition and need to know SQL query that can solve this problem. I have 2 tables “old_data” and “new_data” Old_data contains around 60,000 records …
Get today and yesterday data from mysql
SELECT * FROM att_record2 WHERE DATE(row_datentime)=DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND out_datentime=”0000-00-00 00:00:00″ AND in_datentime!=”0000-00-00 00:00:00″ I want to get data from …
MySQL output gives values from different rows
I am working on sql and there are 4 different columns which are pname, Fname,Flastname and amount. It gives the correct outputs for pname and amount but fname and flastname are from different rows …