And now I have an error with insert data into database with Sqlite3.
Errro: "SQLite3::exec() [sqlite3.exec]: near "SET": syntax error".
I a a new with Sqlite3

here is my code:

<?php
        class Sqlite extends SQLite3 {
                private $db="";
                public function __construct($db_file) {
                        $this->open($db_file);
                }
                public function connecting($db){
                        if(!$db){
                                echo $db->lastErrorMsg();
                        }else{
                                echo "Opened database successfully<br/>";
                                }
                }
                public function queryData($db,$table){
                        $this->connecting($db);
                        $result = $db->query("select * from $table");
                        return $result;
                }
                
                public function stringEscape($string){
                        return SQLite3::escapeString($string);
                }
                
                public function save($db,$table,$fields=array()){
                        
if(isset($table)&&$table!==""&&is_array($fields)&&!empty($fields)){
                                $query = $db->exec("INSERT INTO $table SET ");
                                $temp = array();
                                foreach($fields as $fieldName => $fieldValue ){
                                        $temp[] = $fieldName . " = '" . 
$this->stringEscape($fieldValue) ."' ";
                                }
                                $query .= implode( " , " , $temp ) . " ; " ;
                                //$db = $db->queryExec($query);
                                return $this->queryData($db,$query);
                        } 
                        return false;
                }
                
        }       
        $db = new SQLite('test.at');
        echo "
Insert Data into Database
";
        $result = $db->save($db,"people",array("ID"=>NULL, "Name"=>"SeySey",
"Sex"=>"F"));
        $result->execute();
        //print_r($result);
?>



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Problem-with-method-numRows-in-Sqlite3-tp71420p71440.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to