function getDB_id($rideID) { $rideID = (int) $rideID; //security $result = singleQuery($this->conn, $this->_selectPart() . $this->_fromJoinPart() . " where rideID={$rideID}"); if (!$result) { return "No ride number {$rideID} found."; } return $this->parseRow($result); }
<?php include_once '../src/errors.php'; include_once '../src/database.php'; $sql = 'SELECT testEntry, additional FROM TestTable WHERE testEntry != :value1'; $values = array(':value1' => 'n'); $result = singleQuery($sql, $values, array('testEntry', 'additional')); foreach ($result as $r) { foreach ($r as $rv) { echo $rv; } } $select_columns = array('testEntry', 'additional'); $from_sql = 'TestTable'; $where_sql = 'testEntry != :value1'; $condition_values = array(':value1' => 'n'); $result = SFWQuery($select_columns, $from_sql, $where_sql, $condition_values); foreach ($result as $r) { foreach ($r as $rv) { echo $rv; } } echo "<p>done</p>";
function SFWQuery($select_columns, $from_sql, $where_sql = '', $condition_values = array(), $tail_sql = '') { $select_sql = 'SELECT ' . join(', ', $select_columns); $sql = "" . join(" ", array($select_sql, "FROM", $from_sql, 'WHERE', $where_sql, $tail_sql)); return singleQuery($sql, $condition_values, $select_columns); }