当前位置: 首页>>代码示例>>PHP>>正文


PHP sql_execute函数代码示例

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


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

示例1: sql_clean

 /**
  * 针对指定配置执行sql
  * @param unknown_type $module
  * @param unknown_type $sql
  */
 protected function sql_clean($module, $sql)
 {
     $conf = get_conf($module);
     $ipaddr = $conf["mysql"]["ipaddr"];
     $db = $conf["mysql"]["db"];
     $user = $conf["mysql"]["user"];
     $pwd = $conf["mysql"]["pwd"];
     sql_execute($ipaddr, $db, $user, $pwd, $sql);
 }
开发者ID:sdgdsffdsfff,项目名称:stplatform,代码行数:14,代码来源:basetest.php

示例2: get_user_options

 public function get_user_options($user_id)
 {
     if (!$user_id) {
         throw new UnexpectedValueException();
     }
     $out = array();
     $res = sql_query("SELECT option_id id, option_value value FROM user_options_values WHERE user_id={$user_id}");
     while ($r = sql_fetch_array($res)) {
         $out[$r['id']] = $r['value'];
     }
     //autovivify absent options
     sql_begin();
     $ins = sql_prepare("INSERT INTO user_options_values VALUES(?, ?, ?)");
     foreach ($this->options as $opt) {
         if (!in_array($opt->id, array_keys($out))) {
             $out[$opt->id] = $opt->default_value;
             sql_execute($ins, array($user_id, $opt->id, $opt->default_value));
         }
     }
     sql_commit();
     return $out;
 }
开发者ID:ayunah,项目名称:opencorpora,代码行数:22,代码来源:lib_options.php

示例3: merge_sentences

function merge_sentences($id1, $id2)
{
    check_permission(PERM_ADDER);
    if ($id1 < 1 || $id2 < 1) {
        throw new UnexpectedValueException();
    }
    // check same paragraph and adjacency
    $res = sql_pe("SELECT pos, par_id FROM sentences WHERE sent_id IN (?, ?) ORDER BY pos LIMIT 2", array($id1, $id2));
    $r1 = $res[0];
    $r2 = $res[1];
    $res = sql_query("SELECT pos FROM sentences WHERE par_id = " . $r1['par_id'] . " AND pos > " . $r1['pos'] . " AND pos < " . $r2['pos'] . " LIMIT 1");
    if ($r1['par_id'] != $r2['par_id'] || sql_num_rows($res) > 0) {
        throw new Exception();
    }
    //moving tokens
    sql_begin();
    $res = sql_pe("SELECT MAX(pos) AS maxpos FROM tokens WHERE sent_id=?", array($id1));
    sql_pe("UPDATE tokens SET sent_id=?, pos=pos+? WHERE sent_id=?", array($id1, $res[0]['maxpos'], $id2));
    //merging source text
    $res_src = sql_prepare("SELECT `source` FROM sentences WHERE sent_id=? LIMIT 1");
    sql_execute($res_src, array($id1));
    $r1 = sql_fetchall($res_src);
    sql_execute($res_src, array($id2));
    $r2 = sql_fetchall($res_src);
    sql_pe("UPDATE sentences SET source=? WHERE sent_id=? LIMIT 1", array($r1[0]['source'] . ' ' . $r2[0]['source'], $id1));
    //dropping status, moving comments
    sql_pe("UPDATE sentences SET check_status=0 WHERE sent_id=? LIMIT 1", array($id1));
    sql_pe("UPDATE sentence_comments SET sent_id=? WHERE sent_id=?", array($id1, $id2));
    sql_pe("DELETE FROM sentence_check WHERE sent_id=? OR sent_id=?", array($id1, $id2));
    // change syntax markup accordingly
    sql_pe("UPDATE syntax_parses SET sent_id = ? WHERE sent_id = ?", array($id1, $id2));
    //deleting sentence
    sql_pe("DELETE FROM sentence_authors WHERE sent_id=? LIMIT 1", array($id2));
    sql_pe("DELETE FROM sentences WHERE sent_id=? LIMIT 1", array($id2));
    sql_commit();
}
开发者ID:gisly,项目名称:opencorpora,代码行数:36,代码来源:lib_books.php

示例4: get_context_for_word

function get_context_for_word($tf_id, $delta, $dir = 0, $include_self = 1)
{
    // dir stands for direction (-1 => left, 1 => right, 0 => both)
    // delta <= 0 stands for infinity
    $t = array();
    $tw = 0;
    $left_c = -1;
    //if there is left context to be added
    $right_c = 0;
    //same for right context
    $mw_pos = 0;
    static $query1 = NULL;
    // prepare the 1st query
    if ($query1 == NULL) {
        $query1 = sql_prepare("\n            SELECT MAX(tokens.pos) AS maxpos, MIN(tokens.pos) AS minpos, sent_id, source, book_id\n            FROM tokens\n                JOIN sentences USING (sent_id)\n                JOIN paragraphs USING (par_id)\n            WHERE sent_id = (\n                SELECT sent_id\n                FROM tokens\n                WHERE tf_id=? LIMIT 1\n            )\n        ");
    }
    sql_execute($query1, array($tf_id));
    $res = sql_fetchall($query1);
    $r = $res[0];
    $sent_id = $r['sent_id'];
    $sentence_text = $r['source'];
    $book_id = $r['book_id'];
    $maxpos = $r['maxpos'];
    $minpos = $r['minpos'];
    // prepare the 2nd query
    // this is really bad unreadable code, sorry
    static $query2 = NULL;
    if ($query2 == NULL) {
        $q = "SELECT tf_id, tf_text, pos FROM tokens WHERE sent_id = ?";
        if ($dir != 0 || $delta > 0) {
            $q_left = $dir <= 0 ? $delta > 0 ? "(SELECT IF(pos > {$delta}, pos - {$delta}, 0) FROM tokens WHERE tf_id=? LIMIT 1)" : "0" : "(SELECT pos FROM tokens WHERE tf_id=? LIMIT 1)";
            $q_right = $dir >= 0 ? $delta > 0 ? "(SELECT pos+{$delta} FROM tokens WHERE tf_id=? LIMIT 1)" : "1000" : "(SELECT pos FROM tokens WHERE tf_id=? LIMIT 1)";
            $q .= " AND pos BETWEEN {$q_left} AND {$q_right}";
        }
        $q .= " ORDER BY pos";
        $query2 = sql_prepare($q);
    }
    // how many values should we provide?
    $bound = array($tf_id, $tf_id);
    if ($delta <= 0) {
        if ($dir == 0) {
            $bound = array();
        } else {
            $bound = array($tf_id);
        }
    }
    sql_execute($query2, array_merge(array($sent_id), $bound));
    foreach (sql_fetchall($query2) as $r) {
        if ($delta > 0) {
            if ($left_c == -1) {
                $left_c = $r['pos'] == $minpos ? 0 : $r['tf_id'];
            }
            if ($mw_pos) {
                if ($r['pos'] > $mw_pos) {
                    $right_c = $r['tf_id'];
                }
                if ($right_c && $r['pos'] == $maxpos) {
                    $right_c = 0;
                }
            }
        }
        if ($include_self || $r['tf_id'] != $tf_id) {
            $t[$r['tf_id']] = $r['tf_text'];
        }
        if ($include_self && $r['tf_id'] == $tf_id) {
            $mw_pos = $r['pos'];
        }
    }
    return array('context' => $t, 'mainword' => $tf_id, 'has_left_context' => $left_c, 'has_right_context' => $right_c, 'sentence_id' => $sent_id, 'sentence_text' => $sentence_text, 'book_id' => $book_id);
}
开发者ID:gisly,项目名称:opencorpora,代码行数:70,代码来源:lib_annot.php

示例5: foreach

        foreach ($changes as $source => $dest) {
            // Voir si la colonne contient la chaine recherch�e
            if (sql_first("SELECT * FROM `" . $table . "` WHERE `" . $column . "` LIKE '%" . $source . "%'")) {
                // Faire la modification complexe pour les lignes JSON
                $json = sql_all("SELECT * FROM `" . $table . "` WHERE `" . $column . "` LIKE 'a:%'");
                foreach ($json as $line) {
                    $source_j = $line->{$column};
                    $j = unserialize($line->{$column});
                    if ($j) {
                        $j = recursive_array_replace($source, $dest, $j);
                        $j = serialize($j);
                        sql_pexecute("UPDATE `" . $table . "` SET `" . $column . "`=? WHERE `" . $column . "`=?", array($j, $source_j));
                    }
                }
                // Faire ensuite la modification pour les autres lignes.
                sql_execute("UPDATE `" . $table . "` SET `" . $column . "` = replace(`" . $column . "`, '" . $source . "', '" . $dest . "') WHERE `" . $column . "` NOT LIKE 'a:%' AND `" . $column . "` LIKE '%" . $source . "%'");
            }
        }
    }
}
function recursive_array_replace($find, $replace, $data)
{
    if (is_array($data)) {
        foreach ($data as $key => $value) {
            if (is_array($value) || is_object($value)) {
                $data[$key] = recursive_array_replace($find, $replace, $value);
            } else {
                $data[$key] = str_replace($find, $replace, $value);
            }
        }
    } else {
开发者ID:nosval,项目名称:WPBlank,代码行数:31,代码来源:dbreplace.php

示例6: dmsg

                 }
                 $area['areaname'] = $areaname;
                 $do->add($area);
             }
         }
         $do->repair();
         dmsg('添加成功', $this_forward);
     } else {
         include tpl('area_add');
     }
     break;
 case 'import':
     $file = DT_ROOT . '/file/setting/area.sql';
     is_file($file) or msg('数据文件不存在,请上传程序包内 file/setting/area.sql 文件至 file/setting 目录');
     require DT_ROOT . '/include/sql.func.php';
     sql_execute(file_get($file));
     cache_area();
     dmsg('导入成功', $this_forward);
     break;
 case 'cache':
     $do->repair();
     dmsg('更新成功', $this_forward);
     break;
 case 'delete':
     if ($areaid) {
         $areaids = $areaid;
     }
     $areaids or msg();
     $do->delete($areaids);
     dmsg('删除成功', $this_forward);
     break;
开发者ID:hcd2008,项目名称:destoon,代码行数:31,代码来源:area.inc.php

示例7: save_user_options

function save_user_options($post)
{
    if (!isset($post['options'])) {
        throw new UnexpectedValueException();
    }
    check_logged();
    sql_begin();
    $upd = sql_prepare("UPDATE user_options_values SET option_value=? WHERE option_id=? AND user_id=? LIMIT 1");
    foreach ($post['options'] as $id => $value) {
        if ($_SESSION['options'][$id]['value'] != $value) {
            sql_execute($upd, array($value, $id, $_SESSION['user_id']));
            $_SESSION['options'][$id] = $value;
        }
    }
    sql_commit();
}
开发者ID:OpenCorporaUnit,项目名称:opencorpora,代码行数:16,代码来源:lib_users.php

示例8: json_encode

         echo json_encode($arr);
         exit;
     }
 }
 if ($i == 999999) {
     exit;
 }
 $sqldata = file_get_contents(SITEDIR . 'Install/yourphp_data.sql');
 sql_execute($sqldata, $dbPrefix);
 $sqldata = file_get_contents(SITEDIR . 'Install/yourphp_area.sql');
 sql_execute($sqldata, $dbPrefix);
 $indexcode = file_get_contents(SITEDIR . 'index.php');
 $indexcode = str_replace('if(!is_file(\'./config.php\'))header("location: ./Install");', '', $indexcode);
 if ($_POST['lang']) {
     $langsql = file_get_contents(SITEDIR . 'Install/yourphp_lang.sql');
     sql_execute($langsql, $dbPrefix);
     $indexcode = str_replace('define(\'APP_LANG\',false);', 'define(\'APP_LANG\',true);', $indexcode);
     $indexcode = @file_put_contents(SITEDIR . 'index.php', $indexcode);
 } else {
     $indexcode = str_replace('define(\'APP_LANG\',true);', 'define(\'APP_LANG\',false);', $indexcode);
     $indexcode = @file_put_contents(SITEDIR . 'index.php', $indexcode);
     mysql_query("UPDATE `{$dbPrefix}menu` SET  `status` ='0'   WHERE model='Lang' ");
 }
 mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$site_name}' WHERE varname='site_name' and lang=1");
 mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$site_url}' WHERE varname='site_url' ");
 mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$site_email}' WHERE varname='site_email'");
 mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$seo_description}' WHERE varname='seo_description'  and lang=1");
 mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$seo_keywords}' WHERE varname='seo_keywords'  and lang=1");
 //读取配置文件,并替换真实配置数据
 $strConfig = file_get_contents(SITEDIR . 'Install/' . $configFile);
 $strConfig = str_replace('#DB_HOST#', $dbHost, $strConfig);
开发者ID:yunsite,项目名称:yourphpcms,代码行数:31,代码来源:index.php

示例9: header

             } else {
                 header("location:./recovery.php?anyid={$anyid}&pre={$pre}&dosubmit=1&lang={$lang}");
             }
         }
     }
 } else {
     if ($dosubmit) {
         $fileid = $fileid ? $fileid : 1;
         $filename = $pre . $fileid . '.sql';
         $filepath = '../../databack/' . $filename;
         if (file_exists($filepath)) {
             $sql = file_get_contents($filepath);
             if (substr($sql, 28, 5) != $metcms_v && substr($sql, 28, 6) != $metcms_v) {
                 metsave($rurls, $lang_dataerr1, $depth);
             }
             sql_execute($sql, 0, $dosubmit1);
             $fileid++;
             save_met_cookie();
             metsave($rurls . "&pre=" . $pre . "&fileid=" . $fileid . "&dosubmit=1&adminmodify=1&database_met=1", "{$lang_setdbDBFile} {$filename} {$lang_setdbImportOK}{$lang_setdbImportcen}", $depth, '', '', 1);
         } else {
             require_once '../../column/global.func.php';
             $query = "select * from {$met_column} where ((module<=5 and module>0) or (module=8)) and (classtype=1 or releclass!=0)";
             $result = $db->get_all($query);
             sitemap_robots();
             $sysflie = array(1 => 'about', 2 => 'news', 3 => 'product', 4 => 'download', 5 => 'img', 6 => 'job', 7 => 'message', 8 => 'feedback');
             foreach ($result as $key => $val) {
                 if (array_search($val[foldername], $sysflie) === false) {
                     if (!file_exists(ROOTPATH . $val['foldername'])) {
                         @mkdir(ROOTPATH . $val['foldername'], 0777);
                     }
                     column_copyconfig($val['foldername'], $val['module'], $val['id']);
开发者ID:Jesuslagliva12,项目名称:OpenAPI,代码行数:31,代码来源:recovery.php

示例10: define

 define('DT_KEY', $CFG['authkey']);
 define('DT_CHARSET', $CFG['charset']);
 define('DT_SKIN', DT_PATH . 'skin/' . $CFG['skin'] . '/');
 define('SKIN_PATH', DT_PATH . 'skin/' . $CFG['skin'] . '/');
 define('VIP', $CFG['com_vip']);
 define('DT_DOMAIN', $CFG['cookie_domain'] ? substr($CFG['cookie_domain'], 1) : '');
 define('errmsg', 'Invalid Request');
 //创建数据
 require DT_ROOT . '/include/db_mysql.class.php';
 require DT_ROOT . '/include/sql.func.php';
 require DT_ROOT . '/admin/global.func.php';
 $db = new db_mysql();
 $db->connect($db_host, $db_user, $db_pass, $db_name, $CFG['db_expires'], $CFG['db_charset'], $CFG['pconnect']);
 $db->pre = $DT_PRE;
 sql_execute(file_get_contents(IN_ROOT . '/table.sql'));
 sql_execute(file_get_contents(IN_ROOT . '/data.sql'));
 //Setting
 $DT = array();
 for ($i = 1; $i <= 22; $i++) {
     $setting = (include DT_ROOT . '/file/setting/module-' . $i . '.php');
     if ($setting) {
         if ($i == 1) {
             $DT = $setting;
         }
         unset($setting['moduleid'], $setting['name'], $setting['moduledir'], $setting['ismenu'], $setting['domain'], $setting['linkurl']);
         if ($i == 3) {
             foreach ($setting as $k => $v) {
                 $setting[$k] = str_replace('http://demo.destoon.com/v' . DT_VERSION . '/', $CFG['url'], $v);
             }
         }
         update_setting($i, $setting);
开发者ID:hcd2008,项目名称:destoon,代码行数:31,代码来源:index.php

示例11: find_ne_entity

function find_ne_entity($annot_id, $e_id, $e_start_token, $e_length)
{
    static $res = NULL;
    if ($res == NULL) {
        $res = sql_prepare("\n            SELECT entity_id\n            FROM ne_entities\n            WHERE annot_id = ?\n            AND start_token = ?\n            AND length = ?\n        ");
    }
    sql_execute($res, array($annot_id, $e_start_token, $e_length));
    $rows = sql_fetchall($res);
    if (sizeof($rows) == 0) {
        return false;
    }
    // check tags
    $found_id = $rows[0]['entity_id'];
    $tags1 = get_ne_entity_tags($e_id, true);
    $tags2 = get_ne_entity_tags($found_id, true);
    if ($tags1 == $tags2) {
        return $found_id;
    }
    return false;
}
开发者ID:gisly,项目名称:opencorpora,代码行数:20,代码来源:lib_ne.php

示例12: enqueue_updated_forms

function enqueue_updated_forms($forms, $revision_id)
{
    $ins = sql_prepare("INSERT INTO `updated_forms` VALUES (?, ?)");
    foreach (array_unique($forms) as $upd_form) {
        sql_execute($ins, array($upd_form, $revision_id));
    }
}
开发者ID:ayunah,项目名称:opencorpora,代码行数:7,代码来源:lib_dict.php

示例13: addtext_add

function addtext_add($text, $sentences, $book_id, $par_num)
{
    check_permission(PERM_ADDER);
    if (!$text || !$book_id || !$par_num) {
        throw new UnexpectedValueException();
    }
    if (sizeof(sql_pe("SELECT book_id FROM books WHERE parent_id=?", array($book_id))) > 0) {
        throw new UnexpectedValueException("Can't add paragraphs to a text having subtexts");
    }
    sql_begin();
    $revset_id = create_revset();
    $sent_count = 0;
    $pars = split2paragraphs($text);
    // move the following paragraphs
    sql_query("UPDATE paragraphs SET pos=pos+" . sizeof($pars) . " WHERE book_id = {$book_id} AND pos >= {$par_num}");
    $par_ins = sql_prepare("INSERT INTO `paragraphs` VALUES(NULL, ?, ?)");
    $sent_ins = sql_prepare("INSERT INTO `sentences` VALUES(NULL, ?, ?, ?, 0)");
    $token_ins = sql_prepare("INSERT INTO `tokens` VALUES(NULL, ?, ?, ?)");
    foreach ($pars as $par) {
        //adding a paragraph
        sql_execute($par_ins, array($book_id, $par_num++));
        $par_id = sql_insert_id();
        $sent_num = 1;
        $sents = split2sentences($par);
        foreach ($sents as $sent) {
            if (!preg_match('/\\S/', $sent)) {
                continue;
            }
            //adding a sentence
            sql_execute($sent_ins, array($par_id, $sent_num++, trim($sent)));
            $sent_id = sql_insert_id();
            sql_query("INSERT INTO sentence_authors VALUES({$sent_id}, " . $_SESSION['user_id'] . ", " . time() . ")");
            $token_num = 1;
            $tokens = explode('^^', $sentences[$sent_count++]);
            foreach ($tokens as $token) {
                if (trim($token) === '') {
                    continue;
                }
                //adding a textform
                sql_execute($token_ins, array($sent_id, $token_num++, trim($token)));
                $tf_id = sql_insert_id();
                //adding a revision
                $parse = new MorphParseSet(false, trim($token));
                create_tf_revision($revset_id, $tf_id, $parse->to_xml());
            }
        }
    }
    sql_commit();
}
开发者ID:ayunah,项目名称:opencorpora,代码行数:49,代码来源:lib_tokenizer.php

示例14: get_ambiguity_stats_for_chart

function get_ambiguity_stats_for_chart()
{
    $chart = array();
    $t = array();
    $tchart = array();
    $time = time();
    $param_set = array(5, 35, 36, 37, 41, 45, 62, 64);
    $res = sql_prepare("SELECT timestamp, param_value FROM stats_values WHERE timestamp > ? AND param_id = ? ORDER BY timestamp");
    foreach ($param_set as $param_id) {
        sql_execute($res, array($time - 90 * SEC_PER_DAY, $param_id));
        while ($r = sql_fetch_array($res)) {
            $day = intval($r['timestamp'] / SEC_PER_DAY);
            $t[$day][$param_id] = $r['param_value'];
        }
    }
    ksort($t);
    foreach ($t as $day => $ar) {
        $tchart['disamb_sentences'][] = '[' . $day * MSEC_PER_DAY . ',' . $ar[41] . ']';
        $tchart['disamb_sentences_strict'][] = '[' . $day * MSEC_PER_DAY . ',' . $ar[62] . ']';
        if ($ar[45]) {
            $tchart['disamb_sent_length'][] = '[' . $day * MSEC_PER_DAY . ',' . sprintf("%.3f", $ar[45] / $ar[41]) . ']';
        }
        if ($ar[64]) {
            $tchart['disamb_sent_strict_length'][] = '[' . $day * MSEC_PER_DAY . ',' . sprintf("%.3f", $ar[64] / $ar[62]) . ']';
        }
        if ($ar[35] == 0) {
            continue;
        }
        $tchart['avg_parses'][] = '[' . $day * MSEC_PER_DAY . ',' . sprintf("%.3f", $ar[35] / $ar[5]) . ']';
        $tchart['non_ambig'][] = '[' . $day * MSEC_PER_DAY . ',' . sprintf("%.3f", $ar[37] / $ar[5] * 100) . ']';
        $tchart['unknown'][] = '[' . $day * MSEC_PER_DAY . ',' . sprintf("%.3f", $ar[36] / $ar[5] * 100) . ']';
        $tchart['total_words'][] = '[' . $day * MSEC_PER_DAY . ',' . $ar[5] . ']';
    }
    foreach ($tchart as $name => $ar) {
        $chart[$name] = join(',', $ar);
    }
    return $chart;
}
开发者ID:ayunah,项目名称:opencorpora,代码行数:38,代码来源:lib_stats.php

示例15: sql_pe

function sql_pe($query, $params)
{
    // prepares and executes query, closes cursor
    // returns all the rows
    $res = sql_prepare($query);
    sql_execute($res, $params);
    try {
        return sql_fetchall($res);
    } catch (PDOException $e) {
        return array();
    }
}
开发者ID:ayunah,项目名称:opencorpora,代码行数:12,代码来源:common.php


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