本文整理汇总了PHP中Query函数的典型用法代码示例。如果您正苦于以下问题:PHP Query函数的具体用法?PHP Query怎么用?PHP Query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DemLuotTruyCap
public static function DemLuotTruyCap()
{
$query = "SELECT count(1) FROM online";
$r = Query($query);
$row = mysql_fetch_array($r);
return $row[0];
}
示例2: update
function update($sem)
{
foreach (glob("./{$sem}/*.csv") as $filename) {
$dept = substr($filename, 0, -4);
if ($sem == "fall") {
$dept = substr($dept, 7);
} else {
if ($sem == "winter") {
$dept = substr($dept, 9);
}
}
echo $dept . "\n";
if (($handle = fopen($filename, "r")) !== FALSE) {
Query("DROP TABLE IF EXISTS {$dept}");
Query("CREATE TABLE IF NOT EXISTS {$dept} (NAME text, SECTION text, \n\t\t\t\tDAY text, START time, FINISH time, LOCATION text)");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$q = "INSERT INTO {$dept} VALUES (";
foreach ($data as $key => $value) {
$q .= "'{$value}',";
}
$q = substr($q, 0, -1);
$q .= ")";
Query($q);
}
fclose($handle);
}
}
}
示例3: getWikiPage
function getWikiPage($id, $rev = 0)
{
global $canedit, $canmod;
$ptitle = $id;
if (!$ptitle) {
$ptitle = 'Main_page';
} else {
$ptitle = title2url($ptitle);
}
// so that we don't have for example 'Main page' and 'Main_page' being considered different pages
if ($rev < 0) {
$rev = 0;
}
$page = Query("SELECT p.*, pt.date, pt.user, pt.text FROM {wiki_pages} p LEFT JOIN {wiki_pages_text} pt ON pt.id=p.id AND pt.revision=" . ($rev > 0 ? 'LEAST(p.revision,{1})' : 'p.revision') . " WHERE p.id={0}", $ptitle, $rev);
if (!NumRows($page)) {
$page = array('id' => $ptitle, 'revision' => 0, 'flags' => 0, 'text' => '', 'new' => 1);
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Fount');
} else {
$page = Fetch($page);
}
$page['istalk'] = strtolower(substr($ptitle, 0, 5)) == 'talk:';
$page['ismain'] = strtolower($ptitle) == 'main_page';
$page['canedit'] = $canedit && (!($page['flags'] & WIKI_PFLAG_SPECIAL) || HasPermission('wiki.makepagesspecial'));
return $page;
}
示例4: printResult
function printResult()
{
$results = Query();
foreach ($results as $row) {
printMonster($row);
}
}
示例5: updatePerson
function updatePerson($personid, $name)
{
if ($personid) {
return Query("UPDATE `persons` SET `name`= '" . $name . "' WHERE (`personid`= " . $personid . ")", debug_backtrace());
} else {
return NULL;
}
}
示例6: insert_relationtype
function insert_relationtype($reltype)
{
$reltypeid = 0;
if (NULL == ($reltypeid = exists_relationtype($reltype))) {
$reltypeid = Query("INSERT INTO `reltypes` (`reltype`) VALUES ('" . $reltype . "')", debug_backtrace());
}
return $reltypeid;
}
示例7: get_relationtypes
function get_relationtypes($userid = 0)
{
if ($userid) {
return Query("SELECT DISTINCT reltypes.reltype\n\t\tFROM relations AS UsersToPersons,persons,relations AS PersonsToPersons,relations_reltype,reltypes\n\t\tWHERE\n\t\tUsersToPersons.table1 = 'users'\n\t\tAND UsersToPersons.table2 = 'persons'\n\t\tAND UsersToPersons.id1 = " . $userid . "\n\t\tAND UsersToPersons.id2 = persons.personid\n\t\tAND PersonsToPersons.table1 = 'persons'\n\t\tAND PersonsToPersons.table2 = 'persons'\n\t\tAND PersonsToPersons.id1 = persons.personid\n\t\tAND relations_reltype.relationid = PersonsToPersons.relationid\n\t\tAND reltypes.reltypeid = relations_reltype.reltypeid", debug_backtrace());
} else {
return 0;
}
}
示例8: FetchResult
function FetchResult($query, $row = 0, $field = 0)
{
$res = Query($query);
if (mysql_numrows($res) == 0) {
return -1;
}
return mysql_result($res, $row, $field);
}
示例9: get_phonetypes
function get_phonetypes($userid = 0)
{
if ($userid) {
return Query("SELECT DISTINCT phones.phonetype\n\t\tFROM relations AS RELUSERS,phones,relations AS RELPHONES\n\t\tWHERE RELUSERS.id1 = " . $userid . " AND\n\t\t(RELUSERS.table1 LIKE '%users%' AND\n\t\tRELUSERS.table2 LIKE '%persons%' OR\n\t\tRELUSERS.table1 LIKE '%users%' AND\n\t\tRELUSERS.table2 LIKE '%companies%' OR\n\t\tRELUSERS.table1 LIKE '%users%' AND\n\t\tRELUSERS.table2 LIKE '%schools%') AND\n\t\tRELPHONES.table2 = 'phones' AND\n\t\tphones.phoneid = RELPHONES.id2 AND\n\t\tRELPHONES.table1 = RELUSERS.table2 AND\n\t\tRELPHONES.id1 = RELUSERS.id2\n\t\tORDER BY phones.phoneid DESC", debug_backtrace());
} else {
return 0;
}
}
示例10: member
function member($id)
{
if ($id > 0) {
$sql = "select * from ly_users where id='{$id}'";
$query = Query($sql);
$row = GetRow($query);
return $row;
}
}
示例11: insert_log
function insert_log($userid = 0, $REMOTE_ADDR, $REMOTE_PORT, $HTTP_USER_AGENT, $REQUEST_URI)
{
if ($userid) {
Query("INSERT INTO logs(userid,REMOTE_ADDR,REMOTE_PORT,HTTP_USER_AGENT,REQUEST_URI) VALUES(" . $userid . ",'" . $REMOTE_ADDR . "','" . $REMOTE_PORT . "','" . $HTTP_USER_AGENT . "','" . $REQUEST_URI . "')", debug_backtrace());
return 1;
} else {
return NULL;
}
}
示例12: get_person_count
function get_person_count($userid = 0)
{
if ($userid) {
$Result = Query("SELECT COUNT(*) AS count\n\t\tFROM persons\n\t\tWHERE userid = " . $userid . "", debug_backtrace());
return (int) $Result[0]['count'];
} else {
return NULL;
}
}
示例13: insert_alias
function insert_alias($alias)
{
$alias = $alias;
$aliasid = 0;
if (NULL == ($aliasid = exists_alias($alias))) {
$aliasid = Query("INSERT INTO `aliases` (`alias`) VALUES ( '" . $alias . "' )", debug_backtrace());
}
return $aliasid;
}
示例14: __construct
public function __construct($page = 1, $limit = 10)
{
$this->db = Query(array('type' => 'sqlite', 'host' => '', 'user' => '', 'pass' => '', 'port' => '', 'database' => '', 'file' => 'db/sample.db', 'prefix' => '', 'alias' => 'default'));
$this->ret = array('status' => 'success', 'msg' => '', 'data' => '');
$this->tbl = 'sales';
$this->data = false;
$this->setData = array();
return $this;
}
示例15: loadSmiliesOrdered
function loadSmiliesOrdered()
{
global $smiliesOrdered;
$rSmilies = Query("select * from {smilies}");
$smilies = array();
while ($smiley = Fetch($rSmilies)) {
$smiliesOrdered[] = $smiley;
}
}