Skip to content

Instantly share code, notes, and snippets.

@bbatsche
bbatsche / multi.php
Created May 16, 2014 14:06
Multimeter Lottery
<?php
$students = array(
'Andrew',
'Caitlin',
'Josue',
'Genaro',
'Amanda',
'Ashley F',
'Michael',
@bbatsche
bbatsche / Vagrantfile
Created May 6, 2014 20:49
Badlands Config Suppliment
# -*- mode: ruby -*-
# vi: set ft=ruby :
#############################
# Codeup Server Setup
#############################
box = 'chef/ubuntu-14.04'
hostname = 'codeup-trusty'
domain = 'codeup.dev'
@bbatsche
bbatsche / User Role Example.sql
Created March 18, 2014 22:58
An example of how to create a table relating a user table and a role table and an example of how to join across the two.
CREATE TABLE user_role (
user_id INT(10) UNSIGNED NOT NULL,
role_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (user_id, role_id),
CONSTRAINT user_role_role_fk FOREIGN KEY (role_id) REFERENCES role (id)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT user_role_user_fk FOREIGN KEY (user_id) REFERENCES `user` (id)
ON DELETE CASCADE ON UPDATE CASCADE
);
@bbatsche
bbatsche / pdo-example.php
Last active August 29, 2015 13:57
Examples of PDO Calls
<?php
/*******************************
* Setup Connection
*******************************/
$dbc = new PDO('mysql:host=127.0.0.1;dbname=codeup_demo_db', 'username', 'password');
// Tell PDO to throw exceptions on error
$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@bbatsche
bbatsche / snippet.php
Last active August 29, 2015 13:56
Snippet on how to reset the array keys
<?php
// ...
} elseif ($input == 'R') {
// Remove which item?
echo 'Enter item number to remove: ';
// Get array key
$key = trim(fgets(STDIN));
while ($key < count($items)) {
$items[$key - 1] = $items[$key];
<?php
class DoMath {
public $var;
public static $boo;
public function addToVar($value) {
// $this->var += $value;
}