Terrance / IITCTeamKeys

Collaborate with team members on Ingress by sharing knowledge of keys in your inventory.
6 stars 7 forks source link

db.php & teamkeys.db #4

Closed aerosox closed 8 years ago

aerosox commented 8 years ago

where can i get this 2 file?

Terrance commented 8 years ago

db.php is just a helper that returns a Medoo instance. A new database can be created using the SQL in the readme.

aerosox commented 8 years ago

i follow the guides but im still getting "Failed to fetch a list of teams. Retrying in 3 seconds..." in IITC

db.php

<? // Or if you just download the medoo.php into directory, require it with the correct path. require 'medoo.php';

$database = new medoo([ 'database_type' => 'sqlite', 'database_file' => 'teamkeys.db' ]);

$database->insert("account", [ "user_name" => "foo", "email" => "foo@bar.com" ]); ?>

Terrance commented 8 years ago

db.php needs to return $database, and also probably shouldn't be trying to insert things...

aerosox commented 8 years ago

return $database as in query?

Terrance commented 8 years ago

Not sure what you mean by query. The entire contents of my db.php looks like this:

<?
require_once getenv("PHPLIB") . "medoo.min.php";
return new medoo([
    "database_type" => "sqlite",
    "database_file" => getenv("DATA") . $dbFile
]);

Here, $dbFile is defined by the script that imports db.php. You probably don't want the getenv() calls as part of your require paths (though PHP may default that to empty for you).

The alternative is not to have a db.php at all (I only use this as I have many projects using SQLite DBs in a standard place) -- just replace lines 3 and 4 in teamkeys.php with:

require_once "medoo.php";
$db = new medoo(["database_type" => "sqlite", "database_file" => "teamkeys.db"]);