• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP qa_db_argument_to_mysql函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中qa_db_argument_to_mysql函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_argument_to_mysql函数的具体用法?PHP qa_db_argument_to_mysql怎么用?PHP qa_db_argument_to_mysql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了qa_db_argument_to_mysql函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: qa_db_event_create_not_entity

function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null)
{
    require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
    $updatedsql = isset($timestamp) ? 'FROM_UNIXTIME(' . qa_db_argument_to_mysql($timestamp, false) . ')' : 'NOW()';
    qa_db_query_sub("INSERT INTO ^userevents (userid, entitytype, entityid, questionid, lastpostid, updatetype, lastuserid, updated) " . "VALUES (\$, \$, 0, #, #, \$, \$, " . $updatedsql . ")", $userid, QA_ENTITY_NONE, $questionid, $lastpostid, $updatetype, $lastuserid);
    qa_db_user_events_truncate($userid, $questionid);
}
开发者ID:netham91,项目名称:question2answer,代码行数:7,代码来源:qa-db-events.php


示例2: qa_db_count_posts

function qa_db_count_posts($type = null, $fromuser = null)
{
    $wheresql = '';
    if (isset($type)) {
        $wheresql .= ' WHERE type=' . qa_db_argument_to_mysql($type, true);
    }
    if (isset($fromuser)) {
        $wheresql .= (strlen($wheresql) ? ' AND' : ' WHERE') . ' userid ' . ($fromuser ? 'IS NOT' : 'IS') . ' NULL';
    }
    return qa_db_read_one_value(qa_db_query_sub('SELECT COUNT(*) FROM ^posts' . $wheresql));
}
开发者ID:swuit,项目名称:swuit-q2a,代码行数:11,代码来源:admin.php


示例3: qa_db_apply_sub

/**
 * Substitute ^, $ and # symbols in $query. ^ symbols are replaced with the table prefix set in qa-config.php.
 * $ and # symbols are replaced in order by the corresponding element in $arguments (if the element is an array,
 * it is converted recursively into comma-separated list). Each element in $arguments is escaped.
 * $ is replaced by the argument in quotes (even if it's a number), # only adds quotes if the argument is non-numeric.
 * It's important to use $ when matching a textual column since MySQL won't use indexes to compare text against numbers.
 */
function qa_db_apply_sub($query, $arguments)
{
    $query = preg_replace_callback('/\\^([A-Za-z_0-9]+)/', 'qa_db_prefix_callback', $query);
    if (!is_array($arguments)) {
        return $query;
    }
    $countargs = count($arguments);
    $offset = 0;
    for ($argument = 0; $argument < $countargs; $argument++) {
        $stringpos = strpos($query, '$', $offset);
        $numberpos = strpos($query, '#', $offset);
        if ($stringpos === false || $numberpos !== false && $numberpos < $stringpos) {
            $alwaysquote = false;
            $position = $numberpos;
        } else {
            $alwaysquote = true;
            $position = $stringpos;
        }
        if (!is_numeric($position)) {
            qa_fatal_error('Insufficient parameters in query: ' . $query);
        }
        $value = qa_db_argument_to_mysql($arguments[$argument], $alwaysquote);
        $query = substr_replace($query, $value, $position, 1);
        $offset = $position + strlen($value);
        // allows inserting strings which contain #/$ character
    }
    return $query;
}
开发者ID:ronkeizer,项目名称:question2answer,代码行数:35,代码来源:qa-db.php


示例4: qa_db_user_updates_selectspec

function qa_db_user_updates_selectspec($userid, $forfavorites = true, $forcontent = true)
{
    require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
    $selectspec = qa_db_posts_basic_selectspec($userid);
    $nonesql = qa_db_argument_to_mysql(QA_ENTITY_NONE, true);
    $selectspec['columns']['obasetype'] = 'LEFT(updateposts.type, 1)';
    $selectspec['columns']['oupdatetype'] = 'fullevents.updatetype';
    $selectspec['columns']['ohidden'] = "INSTR(updateposts.type, '_HIDDEN')>0";
    $selectspec['columns']['opostid'] = 'fullevents.lastpostid';
    $selectspec['columns']['ouserid'] = 'fullevents.lastuserid';
    $selectspec['columns']['otime'] = 'UNIX_TIMESTAMP(fullevents.updated)';
    $selectspec['columns']['opersonal'] = 'fullevents.entitytype=' . $nonesql;
    $selectspec['columns']['oparentid'] = 'updateposts.parentid';
    qa_db_add_selectspec_ousers($selectspec, 'eventusers', 'eventuserpoints');
    if ($forfavorites) {
        // life is hard
        $selectspec['source'] .= ' JOIN ' . "(SELECT entitytype, questionid, lastpostid, updatetype, lastuserid, updated FROM ^userevents WHERE userid=\$" . ($forcontent ? '' : " AND entitytype!=" . $nonesql) . " UNION SELECT ^sharedevents.entitytype, questionid, lastpostid, updatetype, lastuserid, updated FROM ^sharedevents JOIN ^userfavorites ON ^sharedevents.entitytype=^userfavorites.entitytype AND ^sharedevents.entityid=^userfavorites.entityid AND ^userfavorites.nouserevents=1 WHERE userid=\$) fullevents ON ^posts.postid=fullevents.questionid";
        array_push($selectspec['arguments'], $userid, $userid);
    } else {
        // life is easy
        $selectspec['source'] .= " JOIN ^userevents AS fullevents ON ^posts.postid=fullevents.questionid AND fullevents.userid=\$ AND fullevents.entitytype=" . $nonesql;
        $selectspec['arguments'][] = $userid;
    }
    $selectspec['source'] .= " JOIN ^posts AS updateposts ON updateposts.postid=fullevents.lastpostid" . " AND (updateposts.type IN ('Q', 'A', 'C') OR fullevents.entitytype=" . $nonesql . ")" . " AND (^posts.selchildid=fullevents.lastpostid OR NOT fullevents.updatetype<=>\$) AND ^posts.type IN ('Q', 'Q_HIDDEN')" . (QA_FINAL_EXTERNAL_USERS ? '' : ' LEFT JOIN ^users AS eventusers ON fullevents.lastuserid=eventusers.userid') . ' LEFT JOIN ^userpoints AS eventuserpoints ON fullevents.lastuserid=eventuserpoints.userid';
    $selectspec['arguments'][] = QA_UPDATE_SELECTED;
    unset($selectspec['arraykey']);
    // allow same question to be retrieved multiple times
    $selectspec['sortdesc'] = 'otime';
    return $selectspec;
}
开发者ID:netham91,项目名称:question2answer,代码行数:30,代码来源:qa-db-selects.php


示例5: qa_db_categoryslugs_sql

function qa_db_categoryslugs_sql($categoryslugs)
{
    if (!is_array($categoryslugs)) {
        // accept old-style string arguments for one category deep
        $categoryslugs = strlen($categoryslugs) ? array($categoryslugs) : array();
    }
    $levels = count($categoryslugs);
    if ($levels > 0 && $levels <= QA_CATEGORY_DEPTH) {
        return ($levels == QA_CATEGORY_DEPTH ? 'categoryid' : 'catidpath' . $levels) . '=(SELECT categoryid FROM ^categories WHERE backpath=' . qa_db_argument_to_mysql(qa_db_slugs_to_backpath($categoryslugs), true) . ' LIMIT 1) AND ';
    } else {
        return '';
    }
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:13,代码来源:qa-db-selects.php



注:本文中的qa_db_argument_to_mysql函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP qa_db_category_nav_selectspec函数代码示例发布时间:2022-05-15
下一篇:
PHP qa_db_apply_sub函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap