Skip to content

Laravel: getting a single value from a MySQL query

I’m trying get a single value from MySQL database using laravel but the problem I’m getting an array . this is my query result in MySQL command line: my laravel function: expected $data value is a string with value= Admin but what i get is : [{“groupName”:”Admin”}] Answer E…

Laravel – seeding large SQL file

A memory exhaustion happens when I run my DB seed script in production. Below is my seed script. So what I did was add a no-limit on my seed script. The problem now is that when I run the script it logs the output into the terminal the content of the SQL script (which is very, very big). Is there

Extract Parameters from pdo query

I have this query using pdo: SELECT * FROM users WHERE name LIKE :name AND age > :age1 AND age < :age2 how can I extract the parameters from this query with a regular expression in order to …

Join Two Non Related Tables

I have two tables Like A and B. Each have one column (ID) in ascending order. I want to join tables LIKE C Table. Datas are not statical but in A and B the row counts are always equal. I’ve tried join statements but couldn’t find out. Thanks for your help. Answer If you’re using a database t…

Alter column default value

I know you can change the default value of an existing column like this: But according to this my query supposed to work: So here I’m trying to make my column Not Null and also set the Default value. But getting Incoorect Syntax Error near CONSTRAINT. Am I missing sth? Answer I think issue here is with …