samedi 6 juin 2015

PHP read the table data from SQLite3 DB and display it as tab separated values

Please help me run the code for sqlite3 the below code is for mysql.

<?php
$con = mysql_connect("localhost","user","");

if (!$con) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db("highcharts", $con);

$result = mysql_query("SELECT * FROM highcharts_php");

while($row = mysql_fetch_array($result)) {
echo $row['timespan'] . "\t" . $row['visits']. "\n";
}

mysql_close($con);
?>

i try below code pls suggest edit, pls help i have working knowledge of php and sql.

<?php

class MyDB extends SQLite3
{
function __construct()
{
    $this->open('mysqlitedb.db');
}
}

$db = new MyDB();


$result = $db->query('SELECT bar FROM foo');
var_dump($result->fetchArray());
?>

Aucun commentaire:

Enregistrer un commentaire