0

我正在尝试使用以下代码更新表格行

t.executeSql('UPDATE flatcomments SET BuildingCode = ?, FlatNo = ?, Comment = ?, Closed = ?, New = ?)', 
[buildingcode, flatdescription, flatcomment.toUpperCase(), 1, 1]);

没有成功。我哪里错了

4

1 回答 1

0

这是一个不错的 PHP 教程。所有 SQLite 命令都适用于您。

<?php

# CREATING A TABLE
$dbname = 'base';
$mytable ="tablename";

$base= new SQLiteDatabase($dbname, 0666, $err);
if ($err)  exit($err);

$query = "CREATE TABLE $mytable(
            ID bigint(20) NOT NULL PRIMARY KEY,
            post_author bigint(20) NOT NULL,            
            post_date datetime,
            post_content longtext,
            post_title text,
            guid VARCHAR(255)            
            )";

$results = $base->queryexec($query);
# The SQL command CREATE TABLE defines the columns. It is sent to the SQLite manager by the PHP method queryExec() which returns true or false, depending on whether the operation is successful or not.

# See the code of the script sqlite-create-table.php.



# ADDING POSTS

# The table of posts that we just created will be filled, like in Wordpress, with the posts we write, each post corresponding to a row of the table.
# The SQL command: INSERT INTO allows to store the data.
$number = 1;
$title="My first post";
$content="The content of my post...";
$date = strftime( "%b %d %Y %H:%M", time());
$author=1;
$url = "http://www.lantian.eu";

$query = "INSERT INTO $mytable(ID, post_title, post_content, post_author, post_date, guid) 
                VALUES ('$number', '$title', '$content', '$author', '$date', '$url')";
$results = $base->queryexec($query);
# For the purposes of the tutorial, we place the contents of the post directly into variables. In practice these variables will be assigned from an t online or local ext editor, as shown in the CMS tutorial.
# The author is represented by the number 1 because Wordpress does not put the names in the posts table but in a separate table instead.
# The guid column contains the URL of the post that also serves as an ID unique.
# The INSERT command jas for first parameter the table name and in parentheses the list of columns to fill, then the parameter VALUE provides a list of values corresponding to the columns in the same order.
# Thus, post_title, which contains the titles, will has for value $title, the variable that was assigned the title of the post.
# The same queryExec method is used to send the request.

# Source code of the script sqlite-write.php.



# READING A POST
# You can access the contents of the database with the SELECT command.
$query = "SELECT post_title, post_content, post_author, post_date, guid FROM $mytable";
$results = $base->arrayQuery($query, SQLITE_ASSOC);
$arr = $results[0];

if($results)
{
   $title = $arr['post_title'];
   $content = $arr['post_content']; 
   $user = $arr['post_author'];
   $date = $arr['post_date'];
   $url = $arr['guid'];
}     
# To the SELECT command is given the list of columns that you want get the content and lines will be assigned to $results array. Indeed, the arrayQuery PHP method returns an array of arrays, each representing a line of the table.
# In practice we will use instead other commands that we will see later to limit the resources usage.
# Data are retrieved in the associative array $arr, where the column names are keys and their content the values.

# Source code of the script sqlite-read.php.


# DELETING A TABLE
# The deletion of a table is made by the DROP TABLE command of SQL.
$query = "DROP TABLE $mytable";
$results = $base->queryexec($query);

# See the code sqlite-delete-table.php.

?>
于 2012-10-07T11:47:05.110 回答