コード例 #1
0
ファイル: cache.database.php プロジェクト: valery/symphony-2
 /**
  * Given the hash of a some data, check to see whether it exists in
  * `tbl_cache`. If no cached object is found, this function will return
  * false, otherwise the cached object will be returned as an array.
  *
  * @param string $hash
  *  The hash of the Cached object, as defined by the user
  * @return array|boolean
  *  An associative array of the cached object including the creation time,
  *  expiry time, the hash and the data. If the object is not found, false will
  *  be returned.
  */
 public function read($hash)
 {
     if ($c = $this->Database->fetchRow(0, "SELECT SQL_NO_CACHE * FROM `tbl_cache` WHERE `hash` = '{$hash}' AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`) LIMIT 1")) {
         if (!($c['data'] = Cacheable::decompressData($c['data']))) {
             $this->delete($hash);
             return false;
         }
         return $c;
     }
     $this->delete();
     return false;
 }
コード例 #2
0
 /**
  * Given the hash of a some data, check to see whether it exists in
  * `tbl_cache`. If no cached object is found, this function will return
  * false, otherwise the cached object will be returned as an array.
  *
  * @param string $hash
  *  The hash of the Cached object, as defined by the user
  * @param string $namespace
  *  The namespace allows a group of data to be retrieved at once
  * @return array|boolean
  *  An associative array of the cached object including the creation time,
  *  expiry time, the hash and the data. If the object is not found, false will
  *  be returned.
  */
 public function read($hash, $namespace = null)
 {
     $data = false;
     // Check namespace first
     if (!is_null($namespace)) {
         $data = $this->Database->fetch("\n                SELECT SQL_NO_CACHE *\n                FROM `tbl_cache`\n                WHERE `namespace` = '{$namepspace}'\n                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)\n            ");
     }
     // Then check hash
     if (!is_null($hash)) {
         $data = $this->Database->fetchRow(0, "\n                SELECT SQL_NO_CACHE *\n                FROM `tbl_cache`\n                WHERE `hash` = '{$hash}'\n                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)\n                LIMIT 1\n            ");
     }
     // If the data exists, see if it's still valid
     if ($data) {
         if (!($data['data'] = Cacheable::decompressData($data['data']))) {
             $this->delete($hash, $namespace);
             return false;
         }
         return $data;
     }
     $this->delete(null, $namespace);
     return false;
 }
コード例 #3
0
 /**
  * Given the `$page_id` and a `$column`
  *
  * @param mixed $page_id
  * The ID of the Page that currently being viewed, or the handle of the
  * current Page
  * @return array
  * An array of the current Page, containing the `$column`
  * requested. The current page will be the last item the array, as all
  * parent pages are prepended to the start of the array
  */
 public function resolvePage($page_id, $column)
 {
     $path = array();
     $page = self::$Database->fetchRow(0, "\n\t\t\t\tSELECT\n\t\t\t\t\tp.{$column},\n\t\t\t\t\tp.parent\n\t\t\t\tFROM\n\t\t\t\t\t`tbl_pages` AS p\n\t\t\t\tWHERE\n\t\t\t\t\tp.id = '{$page_id}'\n\t\t\t\t\tOR p.handle = '{$page_id}'\n\t\t\t\tLIMIT 1\n\t\t\t");
     $path = array($page[$column]);
     if (!is_null($page['parent'])) {
         $next_parent = $page['parent'];
         while ($parent = self::$Database->fetchRow(0, "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tp.{$column},\n\t\t\t\t\t\t\tp.parent\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_pages` AS p\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tp.id = '{$next_parent}'\n\t\t\t\t\t")) {
             array_unshift($path, $parent[$column]);
             $next_parent = $parent['parent'];
         }
     }
     return $path;
 }
コード例 #4
0
ファイル: matrixread.php プロジェクト: onyxnz/quartzpos
    if (!$newresults) {
        die('Error building database!' . $sql);
    }
}
//get supplier from categories
// print"<br>";
for ($i = 1; $i < $num_rec; $i++) {
    $sql = "SELECT supplier FROM hkmatrix WHERE uid = " . $i;
    $results = $db->QuerySingleRowArray($sql);
    $suppcode = $results[0];
    if ($suppcode) {
        $sql2 = "SELECT hksupplier, wwwsupplier FROM categories WHERE code = '" . $suppcode . "'";
        //print $sql2."<br>";
        $subresults = $db->Query($sql2);
        if (!empty($subresults)) {
            $ns = $db->fetchRow($subresults);
            //print_r($ns);
            if ($ns[1]) {
                $newsupp = $db->clean($ns[1]);
            } else {
                $newsupp = $db->clean($ns[0]);
            }
            $sql3 = "UPDATE hkmatrix SET supplier ='" . $newsupp . "' WHERE uid = " . $i;
            //print "<br> $sql3";
            $results = $db->Query($sql3);
        }
    }
    //finish suppcode check
    $sql = "SELECT prodgroup FROM hkmatrix WHERE uid = " . $i;
    $results = $db->QuerySingleRowArray($sql);
    $pgcode = $results[0];
コード例 #5
0
ファイル: ajax.php プロジェクト: Gerst20051/Social-HnS
             $db_insertid = $db->insertID();
             $urlex = '/\\b(([^:\\/?#]+):)(\\/\\/([^\\/?#]*))([^?#]*)(\\?([^#]*))?(#(.*))?/i';
             $contentArray = explode(" ", $status);
             $linkArray = array();
             foreach ($contentArray as $content) {
                 if (preg_match($urlex, $content, $matches)) {
                     array_push($linkArray, $matches);
                 }
             }
             foreach ($linkArray as $link) {
                 if ($link[4] != "" && strlen($link[4]) > 3) {
                     $db->query('SELECT * FROM stream WHERE type = 4 AND data = "' . mysql_real_escape_string($link[0]) . '"');
                     if ($db->numRows() == 0) {
                         $db->insert('stream', array('timestamp' => time(), 'type' => 4, 'data' => $link[0], 'likes' => 1));
                     } else {
                         $oid = $db->fetchRow();
                         $db->query('UPDATE stream SET likes = likes+1 WHERE sid = ' . $oid);
                     }
                 }
             }
             $final = array("data" => array("insertid" => $db_insertid, "status" => addslashes($status)), "error" => false);
             print_r(json_encode($final));
         } else {
             die('0');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
 } elseif ($_POST['p'] == 'updatestatus') {
     try {
コード例 #6
0
<?php /* Logged In Get Request */
if (isset($_GET['p'])) {

if ($_GET['p'] == 'userdata') {
try {
	$db = new MySQL();
	if (!isset($_GET['uid'])) $uid = $_SESSION['user_id'];
	else $uid = $_GET['uid'];
	$db->query();
	if ($db->numRows() == 1) {
		header('Content-Type: text/javascript; charset=utf8');
		print_r(json_encode($db->fetchRow()));
	} else die('0');
} catch(Exception $e) {
	echo $e->getMessage();
	exit();
}
}

}
?>