[icinga-checkins] icinga.org: icinga-web/jmosshammer/default2: * Added base64 encoding to BLOB fields (PostgreSQL workaround)

git at icinga.org git at icinga.org
Fri May 21 10:46:56 CEST 2010


Module: icinga-web
Branch: jmosshammer/default2
Commit: d30b99d75be4cd7589d6e928ceb9b7a740ace2ca
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=d30b99d75be4cd7589d6e928ceb9b7a740ace2ca

Author: jmosshammer <jannis.mosshammer at netways.de>
Date:   Fri May 21 10:46:22 2010 +0200

* Added base64 encoding to BLOB fields (PostgreSQL workaround)

---

 .../database/models/generated/BaseNsmTarget.php    |   14 +++++++++--
 .../database/models/generated/BaseNsmUser.php      |    4 +-
 .../models/generated/BaseNsmUserPreference.php     |   24 ++++++++++++++++---
 3 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/lib/appkit/database/models/generated/BaseNsmTarget.php b/lib/appkit/database/models/generated/BaseNsmTarget.php
index a91dec8..95fff60 100644
--- a/lib/appkit/database/models/generated/BaseNsmTarget.php
+++ b/lib/appkit/database/models/generated/BaseNsmTarget.php
@@ -9,12 +9,14 @@
  * @property string $target_name
  * @property string $target_description
  * @property string $target_class
+ * @property string $target_type
+ * @property integer $newColumn
  * @property Doctrine_Collection $NsmPrincipalTarget
  * 
  * @package    ##PACKAGE##
  * @subpackage ##SUBPACKAGE##
  * @author     ##NAME## <##EMAIL##>
- * @version    SVN: $Id: Builder.php 6401 2009-09-24 16:12:04Z guilhermeblanco $
+ * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
  */
 abstract class BaseNsmTarget extends Doctrine_Record
 {
@@ -24,7 +26,8 @@ abstract class BaseNsmTarget extends Doctrine_Record
         $this->hasColumn('target_id', 'integer', 4, array(
              'type' => 'integer',
              'length' => 4,
-             'unsigned' => 0,
+             'fixed' => false,
+             'unsigned' => false,
              'primary' => true,
              'autoincrement' => true,
              ));
@@ -32,6 +35,7 @@ abstract class BaseNsmTarget extends Doctrine_Record
              'type' => 'string',
              'length' => 45,
              'fixed' => false,
+             'unsigned' => false,
              'primary' => false,
              'notnull' => true,
              'autoincrement' => false,
@@ -40,6 +44,7 @@ abstract class BaseNsmTarget extends Doctrine_Record
              'type' => 'string',
              'length' => 100,
              'fixed' => false,
+             'unsigned' => false,
              'primary' => false,
              'notnull' => false,
              'autoincrement' => false,
@@ -48,6 +53,7 @@ abstract class BaseNsmTarget extends Doctrine_Record
              'type' => 'string',
              'length' => 80,
              'fixed' => false,
+             'unsigned' => false,
              'primary' => false,
              'notnull' => true,
              'autoincrement' => false,
@@ -56,16 +62,18 @@ abstract class BaseNsmTarget extends Doctrine_Record
              'type' => 'string',
              'length' => 45,
              'fixed' => false,
+             'unsigned' => false,
              'primary' => false,
              'notnull' => true,
              'autoincrement' => false,
              ));
+
     }
 
     public function setUp()
     {
         parent::setUp();
-    $this->hasMany('NsmPrincipalTarget', array(
+        $this->hasMany('NsmPrincipalTarget', array(
              'local' => 'target_id',
              'foreign' => 'pt_target_id'));
     }
diff --git a/lib/appkit/database/models/generated/BaseNsmUser.php b/lib/appkit/database/models/generated/BaseNsmUser.php
index 8ebb257..fb922d5 100755
--- a/lib/appkit/database/models/generated/BaseNsmUser.php
+++ b/lib/appkit/database/models/generated/BaseNsmUser.php
@@ -119,11 +119,11 @@ abstract class BaseNsmUser extends Doctrine_Record
              'autoincrement' => false,
              ));
     }
-
+    
     public function setUp()
     {
         parent::setUp();
-    $this->hasOne('NsmPrincipal', array(
+   		$this->hasOne('NsmPrincipal', array(
              'local' => 'user_id',
              'foreign' => 'principal_user_id'));
 
diff --git a/lib/appkit/database/models/generated/BaseNsmUserPreference.php b/lib/appkit/database/models/generated/BaseNsmUserPreference.php
index ba401ad..d8bc286 100755
--- a/lib/appkit/database/models/generated/BaseNsmUserPreference.php
+++ b/lib/appkit/database/models/generated/BaseNsmUserPreference.php
@@ -82,11 +82,27 @@ abstract class BaseNsmUserPreference extends Doctrine_Record
              'local' => 'upref_user_id',
              'foreign' => 'user_id'));
     }
-    
-	public function get($val) {
-		$val = parent::get($val);
+
+   public function set($name,$value,$load = true) {
+   		if($col = $this->getTable()->getColumnDefinition($name)) {
+			if($col["type"] == 'blob')
+				$value = base64_encode($value);
+    	}
+	
+		parent::set($name,$value,$load);
+    }
+ 
+	public function get($column) {
+		$val = parent::get($column);
+		
 		if(is_resource($val))
-			return stream_get_contents($val);
+			$val = stream_get_contents($val);
+
+		if($col = $this->getTable()->getColumnDefinition($column)) {
+			if($col["type"] == 'blob')
+				$val = base64_decode($val);
+    	}
+
 		return $val;
 	}
 }
\ No newline at end of file





More information about the icinga-checkins mailing list