in the .env file set clean seed to true:
IS_CLEAN_SEED=true
then migrate with seed:
php artisan migrate:refresh --seed
The clean seeds are defined in the DatabaseSeeder class. The MVC repo has examples.
in the .env file set clean seed to true:
IS_CLEAN_SEED=true
then migrate with seed:
php artisan migrate:refresh --seed
The clean seeds are defined in the DatabaseSeeder class. The MVC repo has examples.
select *
from orders
order by id
limit 100;
select *
from order_items
order by id
limit 100;
select a table in the db and show info from this table:
SELECT * FROM celebs;
create DB table:
CREATE TABLE celebs (id INTEGER, name TEXT, age INTEGER);
insert info into DB:
INSERT INTO celebs (id, name, age) VALUES (1, 'Justin Bieber', 21);
INSERT INTO celebs (id, name, age) VALUES (2, 'Beyonce Knowles', 33);
INSERT INTO celebs (id, name, age) VALUES (3, 'Jeremy Lin', 26);
INSERT INTO celebs (id, name, age) VALUES (4, 'Taylor Swift', 26);
update a row in the DB
UPDATE celebs
SET age = 22
WHERE id = 1;
SELECT * FROM celebs;
Add a new column to the table
ALTER TABLE celebs ADD COLUMN twitter_handle TEXT;
SELECT * FROM celebs;
add information to this new column
UPDATE celebs
SET twitter_handle = '@taylorswift13'
WHERE id = 4;
SELECT * FROM celebs;
delete rows that have a NULL value
UPDATE celebs
SET twitter_handle = '@taylorswift13'
WHERE id = 4;
DELETE FROM celebs WHERE twitter_handle IS NULL;
SELECT * FROM celebs;
1.) Functions refresher
print the number of characters in your name:
$length = strlen("Samuel");
echo $length;
2.) Functions Syntax
typical structure of a function:
function name(parameters) {
statement;
}
function helloWorld() {
echo "Hello world!";
}
3.) First Function
function displayName() {
echo "Samuel";
}
displayName();
5.) Returning Values
Instead of printing something to the screen, what if you want to make it the value that the function outputs so it can be used elsewhere in your program? In PHP, the return keyword does just that. It returns to us a value that we can work with. The difference between this and echo or print is that it doesn’t actually display the value.
function returnName() {
return "samuel";
}
6.) Parameters and Arguments
Functions wouldn’t be nearly as useful if they weren’t able to take in some input. This is where parameters or arguments come in. These are the variables or inputs that a function uses to perform calculations.
$name = "Samuel";
function greetings($name) {
echo "Greetings," .$name. "!";
}
greetings($name);
7.) Practice Defining multiple parameters
$name = "Samuel";
$age = "28";
function aboutMe($name, $age){
echo "Hello! My name is " .$name. " and I am " .$age. " years old";
}
aboutMe($name, $age);
This is just useful notes for my own later use. Spoiler alert if you don’t want the answers to these lessons than don’t read on any farther.
Lesson 7:
1.) Introducing Functions
strlen()
string function. You pass this a string or a varialbe containing a string and it will return the number of characters in the string. Example:
$length = strlen("Samuel");
print $length;
2.) String Functions
substr()
You pass this function the string you want to get a subsctring of, the character in your string to start at, and how many characters you want after your starting point. For example:
print the first 3 letters of my name:
$myname = "Samuel Bell";
$partial = substr($myname,0,3);
print $partial;
print my name in uppercase:
$uppercase = strtoupper($myname);
print $uppercase;
print my name in lowercase:
$lowercase = strtolower($uppercase);
print $lowercase;
I went walking late a few nights ago, totally on a whim. Just randomly decided to go out and stroll. It was relatively late, probably around 11:00 p.m. For some reason I just started thinking about you and got very emotional. And then here I was walking through the streets for a couple of hours just wandering and thinking, growing more emotional as I went. It was very odd timing wise. There was nothing specific that happened in my day or came up to remind me of you. I suppose it was slightly close to the 1 year anniversary of your passing (which you so cleverly planned to be the exact date of your wedding anniversary, such a planner).
Anyway I just wanted to write about that night so I could remember it in my mind. Try to keep the memory vivid. It felt great to walk and just think about you, try to ask you questions (I even asked them out load most of the time, if anyone saw me walking teary eyed talking to myself I was probably quite a funny site).
The bigger question is why did that walk happen when it did, what is the reason behind the timing. I’ve obviously still come no where near close to processing that your gone. I still find myself if not on a daily basis then for sure on a weekly basis thinking about something I was to talk to you about or ask you… and then I actually remember that I can’t. I still find it very troubling.