sqlite & sqlite 3

Talk about working with different database types

Moderator: alexandrleonenko

natalop
Newbie
Newbie
Posts: 4
Joined: Aug 10th, '16, 17:55

Re: sqlite & sqlite 3

Postby natalop » Aug 11th, '16, 13:49

Thanks for the reply.
I looked at the link and I followed the suggestions:
below is my code.

rete_sqlite_cfg.php

Code: Select all

<?php
   
    $DB_HOST = 'localhost';
    $DB_NAME = 'test.db';
    $TABLE_NAME = 'monument';
    $DB_USER = '';
    $DB_PASS = '';
   
?>


rete_sqlite.php

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>PHP DataGrid :: Sample #1-1 (code)</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name='keywords' content='php grid, php datagrid, php data grid, datagrid sample, datagrid php, datagrid, grid php, datagrid in php, data grid in php, free php grid, free php datagrid, pear datagrid, datagrid paging' />
    <meta name='description' content='Advanced Power of PHP - using PHP DataGrid Pro for displaying some statistical data' />
    <meta content='Advanced Power of PHP' name='author'></meta>
  </head>
<body style="padding:10px">
<?php

  ################################################################################   
  ## +---------------------------------------------------------------------------+
  ## | 1. Creating & Calling:                                                    |
  ## +---------------------------------------------------------------------------+
  ##  *** define a relative (virtual) path to datagrid.class.php file
  ##  *** (relatively to the current file)
  ##  *** RELATIVE PATH ONLY ***     
    define("DATAGRID_DIR", '../datagrid/');                     /* Ex.: "datagrid/" */
    require_once(DATAGRID_DIR.'datagrid.class.php');

    // includes database connection parameters
    include_once('rete_sqlite_cfg.php');
   
    ob_start();     
  ##  *** set needed options
    $debug_mode = true;
    $messaging = true;
    //$unique_prefix = "f_"; 
    $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix);

  ##  *** set data source with needed options
  ##  *** put a primary key on the first place
    $sql=" SELECT " 
    ." monument.id, "
    ." monument.nome, "
    ." monument.Given, "
    ." monument.Surname "
   
    ."FROM monument ";     
    $default_order = array("id"=>"ASC");
   
  /*
    $pdo = new PDO(
    'sqlite::memory:',
    null,
    null,
    array(PDO::ATTR_PERSISTENT => true)
  */ 
   
    $dgrid->DataSource("PDO", "sqlite", $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $sql, $default_order);             

    $dg_caption = '<b>Semplice esempio da Rete con sqlite3 con PHP DataGrid</b> - <a href=rete_sqlite.php>Back to Index</a>';
    $dgrid->SetCaption($dg_caption);
   
  ## +---------------------------------------------------------------------------+
  ## | 6. View Mode Settings:                                                    |
  ## +---------------------------------------------------------------------------+
  ##  *** set columns in view mode
    $dgrid->SetAutoColumnsInViewMode(true); 
   
  ## +---------------------------------------------------------------------------+
  ## | 7. Add/Edit/Details Mode settings:                                        |
  ## +---------------------------------------------------------------------------+
  ##  ***  set settings for edit/details mode
    $table_name = "monument";
    $primary_key = "id";
    $condition = "";
    $dgrid->SetTableEdit($table_name, $primary_key, $condition);
    $dgrid->SetAutoColumnsInEditMode(true);
     
  ## +---------------------------------------------------------------------------+
  ## | 8. Bind the DataGrid:                                                     |
  ## +---------------------------------------------------------------------------+
  ##  *** set debug mode & messaging options
    $dgrid->Bind();       
    ob_end_flush();
   
?>
</body>
</html>


but in the browser displays a blank page.

If you can have a complete example, maybe I could figure out where I'm wrong.

Thanks again

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: sqlite & sqlite 3

Postby ne_moj » Aug 12th, '16, 08:54

Hello

Go to the install/database.class.php file and correct the line 170
$this->dbh = new PDO("sqlite:my/database/path/database.db");
my/database/path/database.db on your database

Regards Sergey

natalop
Newbie
Newbie
Posts: 4
Joined: Aug 10th, '16, 17:55

Re: sqlite & sqlite 3

Postby natalop » Aug 13th, '16, 15:45

Thanks for the reply.

I corrected the line of the file 'install / database.class.php writing the correct path of the database.

Unfortunately the problem is not solved.

A message appears:

1) Line: 864 SQLSTATE
[HY000] [14] unable to open database files

I begin to think that this 'DataGrid script v8.1.8' has something wrong.

Possible that is not available a working example code for the sqlite connection.

I'm discouraging. :oops:

Thanks anyway

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: sqlite & sqlite 3

Postby ne_moj » Aug 16th, '16, 09:35

Hello

Please contact support to resolve this issue (http://www.apphp.com/support)

You can write a new ticket here - http://www.apphp.com/support/open.php

natalop
Newbie
Newbie
Posts: 4
Joined: Aug 10th, '16, 17:55

Re: sqlite & sqlite 3

Postby natalop » Aug 16th, '16, 12:21

Hello,

I contacted the support, I'll tell you the result

Thank you


Return to “Databases: different types implementation”