Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated db.php for console

  • Loading branch information...
commit 3f03b53142deed15315d0eb5a1cf5fc512d99449 1 parent bb988d4
Jeff Reifman authored
View
3  docs/sample_initialized.sql
@@ -1,3 +1,6 @@
+/* NOT RECOMMENDED FOR UPLOAD */
+/* YOU WILL HAVE BETTER RESULTS IF YOU USE OUR CONFIGURATION MENU TO INSTALL THE DATABASE */
+
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
View
3  docs/sample_populated.sql
@@ -1,3 +1,6 @@
+/* NOT RECOMMENDED FOR UPLOAD */
+/* YOU WILL HAVE BETTER RESULTS IF YOU USE OUR CONFIGURATION MENU TO INSTALL THE DATABASE */
+
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
View
2  php/console/console.php
@@ -25,7 +25,7 @@
* change this..
*/
//require_once('../db.php');
-require_once('/var/www/grist/db.php');
+require_once(PATH_CONSOLE.'/db.php');
$poddb = new DB();
$controller_name = '';
//$poddb->selectdb('hotdish');
View
61 php/console/db.php
@@ -0,0 +1,61 @@
+<?php
+
+class DB {
+ var $dbh;
+ var $dbname = 'research';
+
+ function __construct($dbname = false) {
+ global $init;
+ if (!$dbname)
+ $dbname = $init['database'];
+ else
+ $this->dbname = $dbname;
+ $this->dbh = mysql_connect($init['hostname'],$init['username'], $init['password']);
+
+ mysql_select_db($this->dbname);
+ }
+
+ function query($sql) {
+ return mysql_query($sql, $this->dbh);
+ }
+
+ function get_pods() {
+ $data = array();
+ $pods = mysql_query("SELECT * FROM Admin_DataStore WHERE type =
+'pod'", $this->dbh);
+ while (($pod = mysql_fetch_assoc($pods)) !== false) {
+ $data[$pod['name']] = array(
+ 'id' => $pod['id'],
+ 'data' => json_decode($pod['data'], true)
+ );
+ }
+
+ return $data;
+ }
+
+ function get_pod($podid = 0) {
+ if ($podid == 0) {
+ return false;
+ } else {
+ $result = mysql_query("SELECT * FROM Admin_DataStore WHE
+RE type = 'pod' AND id = $podid", $this->dbh);
+ $arr = mysql_fetch_assoc($result);
+ if (isset($arr['id']) && is_numeric($arr['id'])) {
+ $data = array(
+ 'id' => $arr['id'],
+ 'data' => json_decode($arr['data'], true
+)
+ );
+ return $data;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ function selectdb($dbname) {
+ mysql_select_db($dbname, $this->dbh);
+ }
+}
+
+?>
View
2  php/console/models/BaseModel.php
@@ -1,7 +1,7 @@
<?php
/* ::TODO:: CHANGE THIS */
//require_once('../db.php');
-require_once('/var/www/grist/db.php');
+require_once(PATH_CONSOLE.'/db.php');
class BaseModel {
Please sign in to comment.
Something went wrong with that request. Please try again.