Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-26 Thread pisey phon
Thanks you .



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Problem-with-method-numRows-in-Sqlite3-tp71420p71495.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


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-24 Thread Simon Slavin

On 24 Sep 2013, at 9:50am, pisey phon  wrote:

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

Insert a debugging line into your program so that having make up the full 
INSERT command it shows it on the display or put it in a log file before trying 
to ->exec it.  There's probably a syntax error in the command.

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


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-24 Thread pisey phon
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:

open($db_file);
}
public function connecting($db){
if(!$db){
echo $db->lastErrorMsg();
}else{
echo "Opened database successfully";
}
}
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!==""&_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


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-24 Thread pisey phon
thanks you so much for replying it really help me



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Problem-with-method-numRows-in-Sqlite3-tp71420p71439.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


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-23 Thread Tim Streater
On 23 Sep 2013 at 04:50, pisey phon  wrote: 

> I got an error "Call to undefined method SQLite3Result::numRows()". and here
> is my code:
> $db = new Sqlite3("sample.db");
> $result = $db->query("select * from table");
> $rows = $result->numRows();

Sorry, ignore my last mail. DO this:

$resl = $db->query ("select * from table");
$regl = $resl->fetchAll (PDO::FETCH_ASSOC);
$numl = count ($regl);  // $numl has number of rows


--
Cheers  --  Tim
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-23 Thread Tim Streater
On 23 Sep 2013 at 04:50, pisey phon  wrote: 

> I got an error "Call to undefined method SQLite3Result::numRows()". and here
> is my code:
> $db = new Sqlite3("sample.db");
> $result = $db->query("select * from table");
> $rows = $result->numRows();

Don't do that. Do:

$rows = count ($result);

--
Cheers  --  Tim
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-23 Thread Paolo Bolzoni
As far as I know the only way to know the number of returned
rows is scanning all the query result. Isn't it?

On Mon, Sep 23, 2013 at 5:48 PM, John McKown
 wrote:
> Basically, this is telling you that there is no such function as
> "Sqlite3::numRows". I did a fast scan of the sqlite3 documentation, and
> there does not appear to be a sqlite3 function which returns this type of
> information. The PHP interface appears to just be a wrapper for PHP around
> existing sqlite3 calls, and since sqlite3 does not implement this function,
> neither does the PHP interface.
>
> From my looking, such as it was, I would say that you need to either do a
> $result->fetcharray(), then see how big that array is. Or, if you don't
> really want the data, do a
> $result=$db->query("select count(*) as numRows from table");
>
> if you just want a count. Lastly, if you need to check the number of rows
> without fetching them, then you'll need to run both queries.
>
> Again, the above is "as best as I can tell". I am not a PHP expert.
>
>
> On Sun, Sep 22, 2013 at 10:50 PM, pisey phon  wrote:
>
>> Dear Sqlite Team
>>
>>
>> I have some problem with Sqlite3.
>>
>>
>> Would you mind if I want to ask you a question?
>>
>>
>> I got an error "Call to undefined method SQLite3Result::numRows()". and
>> here
>> is my code:
>> $db = new Sqlite3("sample.db");
>> $result = $db->query("select * from table");
>> $rows = $result->numRows();
>>
>>
>> Please help me. Thanks in advance.
>>
>>
>> Pisey Phon
>> Junior Web Developer.
>>
>>
>>
>> --
>> View this message in context:
>> http://sqlite.1065341.n5.nabble.com/Problem-with-method-numRows-in-Sqlite3-tp71420.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
>>
>
>
>
> --
> As of next week, passwords will be entered in Morse code.
>
> Maranatha! <><
> John McKown
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-23 Thread Paolo Bolzoni
You are using a binding, right?
Please, can you show the problem with the plain C interface?

On Mon, Sep 23, 2013 at 5:50 AM, pisey phon  wrote:
> Dear Sqlite Team
>
>
> I have some problem with Sqlite3.
>
>
> Would you mind if I want to ask you a question?
>
>
> I got an error "Call to undefined method SQLite3Result::numRows()". and here
> is my code:
> $db = new Sqlite3("sample.db");
> $result = $db->query("select * from table");
> $rows = $result->numRows();
>
>
> Please help me. Thanks in advance.
>
>
> Pisey Phon
> Junior Web Developer.
>
>
>
> --
> View this message in context: 
> http://sqlite.1065341.n5.nabble.com/Problem-with-method-numRows-in-Sqlite3-tp71420.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
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problem with method numRows() in Sqlite3

2013-09-23 Thread John McKown
Basically, this is telling you that there is no such function as
"Sqlite3::numRows". I did a fast scan of the sqlite3 documentation, and
there does not appear to be a sqlite3 function which returns this type of
information. The PHP interface appears to just be a wrapper for PHP around
existing sqlite3 calls, and since sqlite3 does not implement this function,
neither does the PHP interface.

>From my looking, such as it was, I would say that you need to either do a
$result->fetcharray(), then see how big that array is. Or, if you don't
really want the data, do a
$result=$db->query("select count(*) as numRows from table");

if you just want a count. Lastly, if you need to check the number of rows
without fetching them, then you'll need to run both queries.

Again, the above is "as best as I can tell". I am not a PHP expert.


On Sun, Sep 22, 2013 at 10:50 PM, pisey phon  wrote:

> Dear Sqlite Team
>
>
> I have some problem with Sqlite3.
>
>
> Would you mind if I want to ask you a question?
>
>
> I got an error "Call to undefined method SQLite3Result::numRows()". and
> here
> is my code:
> $db = new Sqlite3("sample.db");
> $result = $db->query("select * from table");
> $rows = $result->numRows();
>
>
> Please help me. Thanks in advance.
>
>
> Pisey Phon
> Junior Web Developer.
>
>
>
> --
> View this message in context:
> http://sqlite.1065341.n5.nabble.com/Problem-with-method-numRows-in-Sqlite3-tp71420.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
>



-- 
As of next week, passwords will be entered in Morse code.

Maranatha! <><
John McKown
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users