public function getUserDetails() { $db = new Database(); $session = new Session(); $id = $session->get_session('userid'); $query = "SELECT * FROM userdetail WHERE UserID='{$id}'"; $result = $db->runQuery($query); $row = $db->fetchArray($result); return $row; }
$data = array(); $page = $db->escapeString($requestData->page); $innerPage = $db->escapeString($requestData->innerPage); if ($page == "dashboard") { $query = $db->query("SELECT * FROM tbl_hashtag"); /*Overview Page*/ if ($innerPage == "overview") { /*Check whether it contains tha hashtag data or not*/ if ($db->hasRows($query)) { $data['hashtagArray'] = array(); $i = 0; while ($row = $db->fetchAssoc($query)) { $hashtagName = $row['hashtagName']; /*Total Tweet Count*/ $totTweetsQuery = $db->query("SELECT COUNT(DISTINCT tweet_id) FROM tweet_tags WHERE tag = '{$hashtagName}'"); $totalTweets = $db->fetchArray($totTweetsQuery); $data['hashtagArray'][$i]['hashtagName'] = $hashtagName; $data['hashtagArray'][$i]['tweets'] = array(); //$tweetQuery = "SELECT * FROM tweet_tags LEFT JOIN" $data['hashtagArray'][$i]['totalTweets'] = $totalTweets[0]; $data['hashtagArray'][$i]['totalImpressions'] = $i + 2000; $data['hashtagArray'][$i]['profileVisits'] = 3000; $data['hashtagArray'][$i]['totalMentions'] = 2000 - $i; $data['hashtagArray'][$i]['totalFollowers'] = 123121; $i++; } $data['destinationPage'] = "overview"; $data['message'] = "The hashtag is present"; echo $jsonHandle->encode($data); } else { $data['destinationPage'] = "add";
/** * Gets fields with specified key type. */ public static function getFields($tables, $key = null, $nameOnly = true) { $tables = Utility::wrapAssoc($tables); $cache =& self::$schemaCache; // Clear the cache on expire if (@$cache['timestamp'] < strtotime('-30min')) { unset($cache['collections']); $cache['timestamp'] = microtime(1); } array_walk($tables, function ($tableName) use(&$cache) { if (!Database::hasTable($tableName)) { throw new \PDOException("Table {$tableName} doesn't exists!"); } if (@$cache['collections'][$tableName]) { return; } $res = Database::fetchArray('SHOW COLUMNS FROM ' . static::escapeField($tableName)); $res = array_combine(array_map(prop('Field'), $res), array_map(removes('Field'), $res)); $res = array_map(function ($info) { $info['Key'] = preg_split('/\\s*,\\s*/', $info['Key']); foreach ($info as &$value) { switch ($value) { case 'YES': $value = true; break; case 'NO': $value = false; break; } } return $info; }, $res); $cache['collections'][$tableName] = $res; }); $tables = array_map(function ($tableName) use($cache, $key, $nameOnly) { $cache = $cache['collections'][$tableName]; if ($key !== null) { $key = Utility::wrapAssoc($key); $cache = array_filter($cache, propHas('Key', $key)); } return $cache; }, $tables); $tables = array_reduce($tables, function ($result, $fields) { return array_merge($result, (array) $fields); }, array()); if ($nameOnly) { $tables = array_unique(array_keys($tables)); } return $tables; }