eZ components PHP Cross Reference Developer Tools

Source: /PersistentObject/tests/data/persistent_test_object_casesensitive.php - 92 lines - 3506 bytes - Summary - Text - Print

   1  <?php
   2  
   3  class PersistentTestObjectCasesensitive
   4  {
   5      public $id = null;
   6      public $varChar = null;
   7      public $integer = null;
   8      public $DECIMAL = null;
   9      public $text = null;
  10  
  11      /**
  12       * Inserts some data to use for testing.
  13       */
  14      public static function insertCleanData()
  15      {
  16          $db = ezcDbInstance::get();
  17          $db->exec( "insert into " . $db->quoteIdentifier( "PO_test" ) . " (" 
  18              . $db->quoteIdentifier( "Type_VarCHAR" ) . ", " . $db->quoteIdentifier( "tYPe_inTEGer" ) . ", "
  19              . $db->quoteIdentifier( "type_decimal" ) . ", " . $db->quoteIdentifier( "TYPE_TEXT" ) . " )
  20                      VALUES ('Sweden', 9006405, 449.96, 'Sweden has nice girls!' )" );
  21  
  22          $db->exec( "insert into " . $db->quoteIdentifier( "PO_test" ) . " ("
  23              . $db->quoteIdentifier( "Type_VarCHAR" ) . ", " . $db->quoteIdentifier( "tYPe_inTEGer" ) . ", "
  24              . $db->quoteIdentifier( "type_decimal" ) . ", " . $db->quoteIdentifier( "TYPE_TEXT" ) . " )
  25                      VALUES ('Norway', 4593041, 385.19, 'Norway has brown goat cheese!' )" );
  26  
  27          $db->exec( "insert into " . $db->quoteIdentifier( "PO_test" ) . " ("
  28              . $db->quoteIdentifier( "Type_VarCHAR" ) . ", " . $db->quoteIdentifier( "tYPe_inTEGer" ) . ", "
  29              . $db->quoteIdentifier( "type_decimal" ) . ", " . $db->quoteIdentifier( "TYPE_TEXT" ) . " )
  30                      VALUES ('Ukraine', 47732079, 603.70, 'Ukraine has a long coastline to the black see.' )" );
  31  
  32          $db->exec( "insert into " . $db->quoteIdentifier( "PO_test" ) . " ("
  33              . $db->quoteIdentifier( "Type_VarCHAR" ) . ", " . $db->quoteIdentifier( "tYPe_inTEGer" ) . ", "
  34              . $db->quoteIdentifier( "type_decimal" ) . ", " . $db->quoteIdentifier( "TYPE_TEXT" ) . " )
  35                      VALUES ('Germany', 82443000, 357.02, 'Home of the lederhosen!.' )" );
  36      }
  37  
  38      /**
  39       * Saves the schema from database to file.
  40       *
  41       * Use this method if you have changed the definition of the persistent object
  42       * and need to update the file on disk.
  43       */
  44      public function saveSchema()
  45      {
  46          $db = ezcDbInstance::get();
  47          $schema = ezcDbSchema::createFromDb( $db );
  48          $schema->writeToFile( 'array', dirname( __FILE__ ) . '/persistent_test_object_casesensitive.dba' );
  49      }
  50  
  51      /**
  52       * Loads the schema from file into the database.
  53       */
  54      public static function setupTable()
  55      {
  56          $db = ezcDbInstance::get();
  57          $schema = ezcDbSchema::createFromFile( 'array', dirname( __FILE__ ) . '/persistent_test_object_casesensitive.dba' );
  58          $schema->writeToDb( $db );
  59      }
  60  
  61      public static function cleanup()
  62      {
  63          $db = ezcDbInstance::get();
  64          if ( $db->getName() == "oracle" )
  65          {
  66              $db->exec( "DROP SEQUENCE " . $db->quoteIdentifier( "PO_test_id_seq" ) );
  67          }
  68          $db->exec( "DROP TABLE " . $db->quoteIdentifier( "PO_test" ) );
  69      }
  70  
  71      public function setState( array $state )
  72      {
  73          foreach ( $state as $key => $value )
  74          {
  75              $this->$key = $value;
  76          }
  77      }
  78  
  79      public function getState()
  80      {
  81          $result = array();
  82          $result['id'] = $this->id;
  83          $result['DECIMAL'] = $this->DECIMAL;
  84          $result['varChar'] = $this->varChar;
  85          $result['integer'] = $this->integer;
  86          $result['text'] = $this->text;
  87          $result['no_Such_Var'] = "bah"; // This is here to make sure it does not provoke an error.
  88          return $result;
  89      }
  90  }
  91  
  92  ?>

title

Description

title

Description

title

Description

title

title

Body