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


PHP SQLite3::lastInsertRowId方法代码示例

本文整理汇总了PHP中SQLite3::lastInsertRowId方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::lastInsertRowId方法的具体用法?PHP SQLite3::lastInsertRowId怎么用?PHP SQLite3::lastInsertRowId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLite3的用法示例。


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

示例1: end

             $s_name = $line;
             if ($level <= $c_level) {
                 end($sections);
                 for ($i = $level; $i <= key($sections); $i++) {
                     unset($sections[$i]);
                 }
                 end($counters);
                 for ($i = $level; $i <= key($counters); $i++) {
                     unset($counters[$i]);
                 }
             }
             $section = end($sections);
             $counter = end($counters) + 1;
             if ($s_query->execute() !== false) {
                 $counters[key($counters)]++;
                 $sections[$level] = $sqlite->querySingle("select s_id from sections where rowid=" . $sqlite->lastInsertRowId(), false);
                 $counters[$level] = 0;
                 $section = $sections[$level];
                 $c_level = $level;
             }
         } else {
             $params = preg_split("/\\s+/", trim($line), 2);
             $l_url = $params[0];
             $l_comment = isset($params[1]) ? $params[1] : "";
             $l_query->execute();
         }
     }
 }
 fclose($defaults);
 $s_query->close();
 $l_query->close();
开发者ID:jatolmed,项目名称:links,代码行数:31,代码来源:include.php

示例2: json_encode

<?php

require "../includes/include.php";
if (!empty($_POST["url"]) && is_numeric($_POST["section"]) && intval($_POST["section"]) > 0) {
    $sqlite = new SQLite3($db_str, SQLITE3_OPEN_READWRITE);
    $url = $_POST["url"];
    $comment = $_POST["comment"];
    $section = is_numeric($_POST["section"]) && intval($_POST["section"]) > 0 ? intval($_POST["section"]) : null;
    if (sectionExists($section)) {
        $insert = $sqlite->prepare("insert into links (l_url,l_comment,l_section) values (:url,:comment,:section)");
        $insert->bindValue("url", $url, SQLITE3_TEXT);
        $insert->bindValue("comment", $comment, SQLITE3_TEXT);
        $insert->bindValue("section", $section, SQLITE3_INTEGER);
        if ($insert->execute() !== false) {
            $id = $sqlite->querySingle("select l_id from links where rowid=" . $sqlite->lastInsertRowId());
            $result = ["insert" => findLinkById($id), "success" => true, "message" => date("Y-m-d H:i:s"), "anchor" => "s{$section}"];
        } else {
            $result = ["insert" => ["url" => $url, "comment" => $comment, "section" => $section], "success" => false, "message" => "Unable to execute query", "anchor" => "s{$section}"];
        }
        $insert->close();
    } else {
        $result = ["insert" => ["url" => $url, "comment" => $comment, "section" => $section], "success" => false, "message" => "Section {$section} not found"];
    }
    $sqlite->close();
} else {
    $result = ["insert" => $_POST, "success" => false, "message" => "Bad request"];
}
print json_encode($result);
开发者ID:jatolmed,项目名称:links,代码行数:28,代码来源:create_link.php

示例3: json_encode

<?php

require "../includes/include.php";
if (!empty($_POST["name"])) {
    $sqlite = new SQLite3($db_str, SQLITE3_OPEN_READWRITE);
    $name = $_POST["name"];
    $container = is_numeric($_POST["container"]) && intval($_POST["container"]) > 0 ? intval($_POST["container"]) : null;
    $position = is_numeric($_POST["position"]) && intval($_POST["position"]) > 0 ? intval($_POST["position"]) : 1;
    if (sectionExists($container) && hack($container, $position)) {
        $insert = $sqlite->prepare("insert into sections(s_name,s_container,s_position) values(:name,:container,:position)");
        $insert->bindValue("name", $name, SQLITE3_TEXT);
        $insert->bindValue("container", $container, SQLITE3_INTEGER);
        $insert->bindValue("position", $position, SQLITE3_INTEGER);
        if ($insert->execute() !== false) {
            $id = $sqlite->querySingle("select s_id from sections where rowid=" . $sqlite->lastInsertRowId());
            $result = ["insert" => findSectionById($id), "success" => true, "message" => date("Y-m-d H:i:s"), "anchor" => "s{$id}"];
        } else {
            $result = ["insert" => ["name" => $name, "container" => $container, "position" => $position], "success" => false, "message" => "Unable to execute query", "anchor" => "s" . ($container != null ? $container : "null")];
        }
        $insert->close();
    } else {
        $result = ["insert" => ["name" => $name, "container" => $container, "position" => $position], "success" => false, "message" => "Container {$container} not found or not accesible"];
    }
    $sqlite->close();
} else {
    $result = ["insert" => $_POST, "success" => false, "message" => "Bad request"];
}
print json_encode($result);
开发者ID:jatolmed,项目名称:links,代码行数:28,代码来源:create_section.php


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