public function updateUserFbId($token, $uid) { $user = array("fb_uid" => $uid); $sql = SqlUtils::update(self::TABLE_USERS, $user, "token = '{$token}'"); $this->handle->exec($sql); return $token; }
public static function getInsertFieldsValues($keyAndValues) { return implode(",", SqlUtils::getParameters($keyAndValues)); }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); include 'get.php'; $result = array(); $query = str_replace("\"", " ", getParam('query')); $query = str_replace("'", " ", $query); $query = strtolower(standardlizeString($query)); if (strlen($query) > 0) { $sqlUtil = new SqlUtils(); $sqlStr = "SELECT Name,Town,State,State_Abbrev,Zip,Code,Icon,URL FROM Data WHERE"; $queryData = explode(' ', $query); if (count($queryData) > 0) { // CHECK Name $sqlStr .= "("; for ($i = 0; $i < count($queryData); $i++) { $sqlStr .= "LOWER(Name) LIKE '%" . $queryData[$i] . "%'"; if ($i < count($queryData) - 1) { $sqlStr .= " OR "; } } $sqlStr .= ") OR "; // CHECK Town $sqlStr .= "("; for ($i = 0; $i < count($queryData); $i++) { $sqlStr .= "LOWER(Town) LIKE '%" . $queryData[$i] . "%'"; if ($i < count($queryData) - 1) { $sqlStr .= " OR "; } }
function addItem($id, $item) { if ($this->db == null) { return new PEAR_Error("DB Connect error."); } $logger =& Log::singleton("null", "results.log", "addItem"); $logger->log($id . ": " . print_r($item, true)); $sqlCheck = "SELECT * FROM items WHERE name = ? AND address = ?"; $itemId =& $this->db->getOne($sqlCheck, array($item["name"], $item["address"])); if (isset($itemId) && !PEAR::isError($itemId)) { $logger->log("Update: {$itemId}"); $sql = SqlUtils::getUpdateSQL("items", $item, "id = {$itemId}", array("lastdate" => "NOW()")); $res =& $this->db->query($sql, array_values($item)); $sql = "\n\t\t\t\tINSERT INTO items_links (item_id, rubric_id) \n\t\t\t\t\tVALUES (?, ?)\n\t\t\t"; $res =& $this->db->query($sql, array($itemId, $id)); return $itemId; } else { $logger->log("Insert new"); $sql = SqlUtils::getInsertSQL("items", $item, array("lastdate" => "NOW()")); $res =& $this->db->query($sql, array_values($item)); $itemId =& $this->db->getOne($sqlCheck, array($item["name"], $item["address"])); if (isset($itemId)) { $logger->log("Id: " . $itemId); $sql = "\n\t\t\t\t\tINSERT INTO items_links (item_id, rubric_id) \n\t\t\t\t\t\tVALUES (?, ?)\n\t\t\t\t"; $res =& $this->db->query($sql, array($itemId, $id)); return $itemId; } return new PEAR_Error("Item ID is null"); } }
public function deleteBook($bookId) { $sql = SqlUtils::delete(self::TABLE_BOOKS, "id = '{$bookId}'"); $this->handle->exec($sql); return $bookId; }