On 13 Dec 2009, at 5:27am, FrankLane wrote:

>  $data3 = preg_split('/\t/',$data2[$i]);  // tab delimited record data into
> array
> 
>  $sqlcmd = 'INSERT INTO tab (i0) VALUES ('.$data3[0].')';

Good so far.  Now you should know that a normal SQL command to insert a record 
would look something like this:

INSERT INTO tab(i0,i1,i2,i3,i4) VALUES (1,2,3,4,5)

where the five values listed go into the five variables listed.  So you need to 
turn the array currently in $data3 into a list of variables.  One way to do it 
is this:

$valuesSeparatedByCommas = preg_replace('/\t/', ',', $data2[$i]);
$sqlcmd = 'INSERT INTO tab(i0,i1,i2,i3,i4) VALUES 
('.$valuesSeparatedByComma.')';

another way to do it is this:

$arrayOfValues = explode('/\t/',$data2[$i]);  // tab delimited record data into 
array
$valuesSeparatedByCommas = join(',', $arrayOfValues);
$sqlcmd = 'INSERT INTO tab(i0,i1,i2,i3,i4) VALUES 
('.$valuesSeparatedByComma.')';



> Looking in the php manual, there is no "query" function, but a lot of other
> xxx_query functions. Is this a simple problem"


I think you are best off using ->fetchAll for now.  See

http://php.net/manual/en/pdostatement.fetchall.php

and scroll down to see some examples.  This should allow you to prove that the 
database system is working and give you confidence to try some of the other 
functions.  You will probably end up using either ->fetch() or ->fetchObject().

(Warning: I haven't actually tried any of the above code.)

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to