[CS-XMLDatastore-commits] SF.net SVN: cs-xmldatastore:[6] trunk/0.1
Status: Alpha
Brought to you by:
crazedsanity
|
From: <cs-...@li...> - 2009-09-09 20:47:16
|
Revision: 6
http://cs-xmldatastore.svn.sourceforge.net/cs-xmldatastore/?rev=6&view=rev
Author: crazedsanity
Date: 2009-09-09 20:47:04 +0000 (Wed, 09 Sep 2009)
Log Message:
-----------
Fixed error in schema, main class creates db handle & can load schema, + tests.
Modified Paths:
--------------
trunk/0.1/cs_xmlDataStore.class.php
trunk/0.1/setup/schema.pgsql.sql
Added Paths:
-----------
trunk/0.1/tests/
trunk/0.1/tests/testOfXMLDataStore.php
Modified: trunk/0.1/cs_xmlDataStore.class.php
===================================================================
--- trunk/0.1/cs_xmlDataStore.class.php 2009-09-09 19:47:22 UTC (rev 5)
+++ trunk/0.1/cs_xmlDataStore.class.php 2009-09-09 20:47:04 UTC (rev 6)
@@ -13,16 +13,48 @@
class cs_xmlDataStore {
- protected $db;
+ public $db;
protected $reader;
protected $writer;
//-------------------------------------------------------------------------
public function __construct() {
+ if(defined(__CLASS__ .'-DBTYPE')) {
+ //create database handle.
+ $params = array(
+ 'host' => constant(__CLASS__ .'-HOST'),
+ 'dbname' => constant(__CLASS__ .'-DBNAME'),
+ 'user' => constant(__CLASS__ .'-USER'),
+ 'password' => constant(__CLASS__ .'-PASSWORD'),
+ 'port' => constant(__CLASS__ .'-PORT')
+ );
+
+ $this->db = new cs_phpDB(constant(__CLASS__ .'-DBTYPE'));
+ $this->db->connect($params);
+ }
+ else {
+ throw new exception(__METHOD__ .": missing DBTYPE constant (". __CLASS__ .'_DBTYPE' .")");
+ }
}//end __construct()
//-------------------------------------------------------------------------
+
+
+ //-------------------------------------------------------------------------
+ public function load_schema() {
+ $schemaFile = dirname(__FILE__) .'/setup/schema.'. $this->db->get_dbtype() .'.sql';
+
+ if(file_exists($schemaFile)) {
+ $this->db->run_update(file_get_contents($schemaFile), true);
+ }
+ else {
+ throw new exception(__METHOD__ .": db type (". $this->db->get_dbtype() .") not supported " .
+ "or missing schema file(". $schemaFile .")");
+ }
+ }//end load_schema()
+ //-------------------------------------------------------------------------
+
}
?>
Modified: trunk/0.1/setup/schema.pgsql.sql
===================================================================
--- trunk/0.1/setup/schema.pgsql.sql 2009-09-09 19:47:22 UTC (rev 5)
+++ trunk/0.1/setup/schema.pgsql.sql 2009-09-09 20:47:04 UTC (rev 6)
@@ -54,7 +54,7 @@
CREATE TABLE csxd_store_item_table (
store_item_id serial NOT NULL PRIMARY KEY,
store_id int NOT NULL REFERENCES csxd_store_table(store_id),
- auth_data_hash text varchar(40),
+ auth_data_hash text DEFAULT NULL,
creation timestamp NOT NULL DEFAULT NOW(),
last_update timestamp,
store_data text
Added: trunk/0.1/tests/testOfXMLDataStore.php
===================================================================
--- trunk/0.1/tests/testOfXMLDataStore.php (rev 0)
+++ trunk/0.1/tests/testOfXMLDataStore.php 2009-09-09 20:47:04 UTC (rev 6)
@@ -0,0 +1,50 @@
+<?php
+/*
+ * Created on Sep 9, 2009
+ *
+ * SVN INFORMATION:::
+ * -------------------
+ * Last Author::::::::: $Author$
+ * Current Revision:::: $Revision$
+ * Repository Location: $HeadURL$
+ * Last Updated:::::::: $Date$
+ */
+
+
+//=============================================================================
+class testOfCSXMLDataStore extends UnitTestCase {
+
+ //-------------------------------------------------------------------------
+ function setUp() {
+
+ $this->gfObj = new cs_globalFunctions;
+ $this->gfObj->debugPrintOpt=1;
+
+ //create the object.
+ $this->store = new cs_xmlDataStore();
+
+ //load schema.
+ $this->store->db->beginTrans();
+ $this->store->load_schema();
+ }//end setUp()
+ //-------------------------------------------------------------------------
+
+
+
+ //-------------------------------------------------------------------------
+ function tearDown() {
+ $this->store->db->rollbackTrans();
+ }//end tearDown()
+ //-------------------------------------------------------------------------
+
+
+
+ //-------------------------------------------------------------------------
+ function test_basics() {
+
+ }//end test_basics()
+ //-------------------------------------------------------------------------
+
+}//end testOfCSXMLDataStore{}
+//=============================================================================
+?>
Property changes on: trunk/0.1/tests/testOfXMLDataStore.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|