<?php include "../../include.php"; error_reporting(E_ALL); if ($_POST) { db_switch("trackit"); //establish vars //die($_POST["start"]); $projects = array(); list($startMonth, $startYear) = explode("/", $_POST["start"]); list($endMonth, $endYear) = explode("/", $_POST["end"]); $startdate = $startMonth . "/1/" . $startYear; $enddate = $endMonth . "/28/" . $endYear; $timeframe = "h.midDate > '" . $startdate . "' AND h.midDate < '" . $enddate . "'"; $reportname = "Percentages " . $_POST["start"]; if ($_POST["start"] != $_POST["end"]) { $reportname .= " to " . $_POST["end"]; } //start output file $file = '<table border="1" style="font-family:verdana; font-size:10px;"> <tr bgcolor="#dddddd"> <td width="140" align="center" rowspan="2"><b>' . $reportname . '</b></td>'; //load projects into array & finish first row $result = db_query("SELECT\n\t\t\tp.id,\n\t\t\tp.projectName,\n\t\t\tp.projectID,\n\t\t\tp.taskName, \n\t\t\tp.taskID\n\t\tFROM _josh_projects p\n\t\tWHERE \n\t\t\tp.isVacation = 0 AND\n\t\t\t(SELECT SUM(h.hrs) FROM _josh_hours h WHERE h.projectID = p.id AND {$timeframe}) IS NOT NULL\n\t\tORDER BY projectName, taskName"); while ($r = db_fetch($result)) { $projects[] = $r["id"]; $tasks[] = $r["taskName"]; $file .= '<td width="90" align="center" valign="bottom">' . $r["projectName"] . '</td>'; } $file .= '<td width="60" align="right" rowspan="2"><b>Total</b></td></tr>'; //second row: tasks
function db_open() { global $_josh; //skip if already connected if (isset($_josh["db"]["pointer"])) { return; } error_debug("<b>db_open</b> running"); //todo: be able to specify new variables. it should close the open connection and connect to the new thing. //connect to db if (!isset($_josh["db"]["language"]) || !isset($_josh["db"]["database"]) || !isset($_josh["db"]["username"]) || !isset($_josh["db"]["password"]) || !isset($_josh["db"]["location"])) { configure(); //error_handle("database variables error", "joshserver could not find the right database connection variables. please fix this before proceeding."); } elseif ($_josh["db"]["language"] == "mysql") { error_debug("<b>db_open</b> trying to connect mysql on " . $_josh["db"]["location"]); if ($_josh["db"]["pointer"] = @mysql_connect($_josh["db"]["location"], $_josh["db"]["username"], $_josh["db"]["password"])) { } else { error_handle("database connection error", "this application is not able to connect its database. we're sorry for the inconvenience, the administrator is attempting to fix the issue."); } } elseif ($_josh["db"]["language"] == "mssql") { error_debug("<b>db_open</b> trying to connect mssql on " . $_josh["db"]["location"] . " with username " . $_josh["db"]["username"]); if ($_josh["db"]["pointer"] = @mssql_connect($_josh["db"]["location"], $_josh["db"]["username"], $_josh["db"]["password"])) { } else { error_handle("database connection error", "this application is not able to connect its database. we're sorry for the inconvenience, the administrator is attempting to fix the issue."); } } //select db db_switch(); }
<?php include "../../include.php"; echo drawTop(); if ($_josh["db"]["language"] == "mssql") { db_switch("trackit"); $l = db_grab("SELECT MAX(loadDate) loadDate FROM _josh_loads"); echo drawMessage("These database indexes were loaded: " . format_date($l["loadDate"], true, " at ")); db_switch($_josh["db"]["database"]); } ?> <table class="left" cellspacing="1"> <?php echo drawHeaderRow("Reports", 1); ?> <tr><td><a href="totals.php">Totals</a></td></tr> <tr><td><a href="percentages.php">Percentages (without Vacation)</a></td></tr> </table> <?php echo drawBottom();
FROM wp_posts p WHERE post_type = "careers" AND (post_status = "publish" or post_status = "draft") ORDER BY 6'); $lastLocation = ""; while ($r = db_fetch($result)) { if ($r['location'] != $lastLocation) { $lastLocation = $r['location']; echo '<tr class="group"><td colspan="2">' . $lastLocation . '</td></tr>'; } ?> <tr> <td><a href="./?id=<?php echo $r['id']; ?> "><?php echo $r['title']; ?> </a></td> <td class="r"><?php echo format_date($r['updated_date']); ?> </td> </tr> <?php } ?> </table> <?php } db_switch(); echo drawBottom();
/** * Import schema to the database * @param string $dbNamespace The namespace for the database * @return boolean TRUE for success; FALSE for failure */ public function import($dbNamespace = null) { if ($dbNamespace === null) { $dbNamespace = $this->dbNamespace; } $this->build($dbNamespace); if (!count($this->sqlStatements)) { return false; } if ($this->dbNamespace !== $dbNamespace) { db_switch($dbNamespace); } $error = false; foreach ($this->sqlStatements as $sql) { if (!db_query($sql)) { $error = true; break; } } if ($this->dbNamespace !== $dbNamespace) { // back to default db db_switch($this->dbNamespace); } $this->build($dbNamespace); return !$error; }