/** * Execute a insert sql statement. Is also capable of doing UPDATE and DELETE statements. * I think it needs a better name... * * @param string $sql the sql to execute * @param string $paramtype the parameter types * @param array $params the params in an array * @return boolean Is the sql succesfully executed? */ function insert_sql($sql, $paramtype, array $params) { $mysqli = startConnection(); $stmt = $mysqli->prepare($sql); array_unshift($params, $paramtype); $refs = array(); foreach ($params as $key => $value) { $refs[$key] =& $params[$key]; } call_user_func_array(array($stmt, 'bind_param'), $refs); if (!$stmt->execute()) { closeConnection($mysqli, $stmt); return false; } else { closeConnection($mysqli, $stmt); return true; } }
function getEmployeeCompensationSorted() { $provider = startConnection(); $response = $provider->getDummyPayroll(); $employeeCompensation = $response[0]->{'employee_compensations'}; $allEmployees = array(); for ($i = 0; $i < count($employeeCompensation); $i++) { $thisEmployee = $employeeCompensation[$i]; $fixedCompensation = $thisEmployee->{'hourly_compensations'}; $totalHoursForThisEmployee = 0; for ($j = 0; $j < count($fixedCompensation); $j++) { $totalHoursForThisEmployee += $fixedCompensation[$j]->{'hours'}; } $allEmployees[$thisEmployee->{'employee_id'}] = $totalHoursForThisEmployee; } //TODO get the names based on id and then sort it and return it. //TODO make a call to /api/v1/employees/:employee_id to get the name based on the ID return $allEmployees; }
<?php putenv('phpunit=1'); define('PROJECT_ROOT', realpath(dirname(__FILE__)) . '/../'); define('TEST_DIR', realpath(dirname(__FILE__))); set_include_path(get_include_path() . PATH_SEPARATOR . TEST_DIR); require 'lib/IntegrationTest.php'; require 'functions.php'; require 'SchemaCopy.php'; require 'SeedLoader.php'; prepareTestDatabase(); require PROJECT_ROOT . 'inc/Bootstrap.php'; register_shutdown_function(function () { echo "** Resetting environment to development\n\n"; }); Bootstrap::start(); function startConnection() { $conn = Database::obtain(INIT::$DB_SERVER, INIT::$DB_USER, INIT::$DB_PASS, INIT::$DB_DATABASE); $conn->getConnection(); } startConnection();
} function getVariablesUpdate($sVar) { $sVar->action = $_POST['myAction']; return $sVar; } function checkVariables() { if (strlen($_POST['myName']) < 6 && strlen($_POST['myRepeat']) < 6 && (strlen($_POST['startDate']) == 10 || strlen($_POST['startDate']) == 0) && (strlen($_POST['startTime']) == 5 || strlen($_POST['startTime']) == 0) && strlen($_POST['Duration']) < 4 && strlen($_POST['myAction']) < 30 && strlen($_POST['Command']) < 7 && strlen($_POST['id']) < 6) { return 34566543; } return 1; } $sVar = array('Command' => NULL, 'id' => NULL, 'name' => NULL, 'toRepeat' => NULL, 'startTime' => NULL, 'endTime' => NULL, 'action' => NULL); addHeader(); $conn = startConnection(); if (checkVariables() != 34566543) { die('Variables Problem'); } $sVar = new StdClass(); $sVar->Command = $_POST['Command']; if ($sVar->Command != NULL) { if (sha1($_POST['psswd']) == PWD_SHA) { if ($sVar->Command == 'Add') { $sVar = getVariablesAdd($sVar); if (!addQuerySelect($conn, $sVar)) { die("add Problem"); } } elseif ($sVar->Command == 'Erase') { $sVar = getVariablesErase($sVar); if (!EraseQuery($conn, $sVar->id)) {
echo "<script src='Javascript/products.js'></script>"; } else { if ($Page == "Account") { echo "<script src='Javascript/userAccount.js'></script>"; } } ?> <script src="Javascript/masterPage.js"></script> </head> <body> <div id="top"> </div> <div> <?php startConnection($link); //Starts the connection with the database. Location: databaseConnect.php include 'accountDialogs.php'; //Adds all of the HTML for the dialog boxes. ?> </div> <div class="mainNav"> <div class="navImage"> <a href="index.php"><img id="logo" class="headerImage" src="Images/LogoBlack5.png"/></a> </div> <div class="navLinks"> <?php //Sets the links for all of the nav bar. Accounts is not included because accounts is added later. $PageListName = array("HOME", "PRODUCTS", "TUTORIALS", "ABOUT US"); $PageURL = array("index.php", "products.php?filter=none", "tutorial.php", "aboutUs.php"); //Displays all of the links in the Nav bar except the account and shopping cart.