public static function fromKey($pk) { return Account::first(sprintf("accountId='%s'", safeSQL($pk))); }
} function get_lang($lang_id_t) { global $db; $query = 'SELECT lang FROM lang_tb WHERE lang_id = ' . $lang_id_t; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); extract($row); return $lang; } $id = safeSQL($_GET['id']); echo "ID:" . $id . "<br>"; $query = 'SELECT title,intro,year,type_id,lang_id FROM video_tb WHERE id="' . $id . '"'; $result = mysql_query($query, $db) or die(mysql_error($db)); while ($row = mysql_fetch_assoc($result)) { extract($row); $type = get_type($type_id); $lang = get_lang($lang_id); echo '<tr>'; echo "<th>Title:</th>"; echo '<td>' . $title . '</td>'; echo '</tr>'; echo '<tr>'; echo '<th valign="top">Introduction:</th>'; echo '<td>' . $intro . '</td>'; echo '</tr>';
function processStep2() { $this->xlsx = new SimpleXLSX($this->import->url); $rows = $this->xlsx->rows($this->import->worksheet); $columns = $rows[0]; $item_rows = $this->db->getArray("SELECT id FROM " . safeSQL($this->import->collection) . "_items"); $items = array(); foreach ($item_rows as $item_row) { $items[] = $item_row->id; } foreach ($columns as $num => $header) { if ($_REQUEST["measure" . $num]) { //TODO: Add Measure $this->db->doInsert(safeSQL($this->import->collection) . "_measures", array("id" => $_REQUEST["id" . $num], "title" => $_REQUEST["name" . $num], "source" => $_REQUEST["source" . $num], "type" => "value")); print "Added Measure: " . $_REQUEST["id" . $num] . "</BR>"; } } $values_table = safeSQL($this->import->collection) . "_values"; foreach ($rows as $count => $row) { if ($count == 0) { continue; } //Skip header row //Check if item exists $id = $row[$_REQUEST["column_id"]]; if (in_array($id, $items)) { $new_item = false; } else { $new_item = true; } foreach ($row as $num => $cell) { if ($new_item) { if ($_REQUEST["new" . $num] == "ignore") { continue; } else { //TODO: Add item print "Add item: " . $id . "</BR>"; $new_item = false; } } if ($_REQUEST["column" . $num]) { $value = str_replace(",", ".", $cell); if (is_numeric($value)) { $float = floatval($value); $array = array("measure" => $_REQUEST["id" . $num], "id" => $id, "year" => $_REQUEST["year" . $num], "quarter" => $_REQUEST["quarter" . $num], "date" => $_REQUEST["date" . $num], "year" => $_REQUEST["year" . $num], "value" => $float); //print_r($array); $this->db->doUpsert($values_table, $array); //print("<BR>"); } } } print "Completed row " . $count . " (id = " . $id . ")<BR>"; } $this->db->doUpdate("imports", array("step" => 2), array("id" => $this->import->id)); $this->import = $this->db->returnFirst("SELECT * FROM imports WHERE id = " . $_REQUEST["id"]); }
$query = 'SELECT lang FROM lang_tb WHERE lang_id = ' . $lang_id_t; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); extract($row); return $lang; } //**************SEARCH**************// if ($_POST['search-submit'] == "Submit") { $type_id_t = safeSQL($_POST['type_id']); $lang_id_t = safeSQL($_POST['lang_id']); $genre_id_t = safeSQL($_POST['genre_id']); if ($type_id_t == '0') { $type_id_t = '%'; } else { echo 'type:' . get_type($type_id_t); echo '<br>'; } if ($lang_id_t == '0') { $lang_id_t = '%'; } else { echo 'lang:' . get_lang($lang_id_t); echo '<br>'; } if ($genre_id_t == '0') { $genre_id_t = '%'; } else {