/**
  *  プロパティ定義を取得する
  *
  *  @access protected
  *  @return array   プロパティ定義
  */
 function _getPropDef()
 {
     if (is_null($this->table_def)) {
         return null;
     }
     foreach ($this->table_def as $table_name => $table_attr) {
         // use 1st one
         break;
     }
     $cache_manager =& Ethna_CacheManager::getInstance('localfile');
     $cache_manager->setNamespace('ethna_app_object');
     $cache_key = $this->my_db_ro->getDSN();
     $cache_key = preg_replace('|[:/@+]|', '', $cache_key);
     $cache_key = "{$cache_key}-{$table_name}";
     $prop_def = $cache_manager->get($cache_key, $this->prop_def_cache_lifetime);
     if (PEAR::isError($prop_def) == false) {
         return $prop_def;
     }
     $r = $this->my_db_ro->getMetaData($table_name);
     if (Ethna::isError($r)) {
         return null;
     }
     $prop_def = array();
     foreach ($r as $i => $field_def) {
         $primary = strpos($field_def['flags'], "primary_key") === false ? false : true;
         // TODO: db independent
         $seq = strpos($field_def['flags'], "auto_increment") === false ? false : true;
         $key = strpos($field_def['flags'], "key") === false ? false : true;
         switch ($field_def['type']) {
             case 'int':
                 $type = VAR_TYPE_INT;
                 break;
             case 'datetime':
                 $type = VAR_TYPE_DATETIME;
                 break;
             case 'blob':
             default:
                 $type = VAR_TYPE_STRING;
                 break;
         }
         $prop_def[$field_def['name']] = array('primary' => $primary, 'seq' => $seq, 'key' => $key, 'type' => $type, 'form_name' => $this->_fieldNameToFormName($field_def));
     }
     $cache_manager->set($cache_key, $prop_def);
     return $prop_def;
 }
 /**
  *  プロパティ定義を取得します。キャッシュされている場合は、
  *  そこから取得します。
  *
  *  @access protected
  *  @return array   プロパティ定義
  */
 function _getPropDef()
 {
     if (is_null($this->table_def)) {
         return null;
     }
     foreach ($this->table_def as $table_name => $table_attr) {
         // use 1st one
         break;
     }
     $cache_manager =& Ethna_CacheManager::getInstance('localfile');
     $cache_manager->setNamespace('ethna_app_object');
     $cache_key = md5($this->my_db_ro->getDSN() . '-' . $table_name);
     if ($cache_manager->isCached($cache_key, $this->prop_def_cache_lifetime)) {
         $prop_def = $cache_manager->get($cache_key, $this->prop_def_cache_lifetime);
         if (Ethna::isError($prop_def) == false) {
             return $prop_def;
         }
     }
     $r = $this->my_db_ro->getMetaData($table_name);
     if (Ethna::isError($r)) {
         return null;
     }
     $prop_def = array();
     foreach ($r as $i => $field_def) {
         $primary = in_array('primary_key', $field_def['flags']);
         $seq = in_array('sequence', $field_def['flags']);
         $required = in_array('not_null', $field_def['flags']);
         $key = in_array('primary_key', $field_def['flags']) || in_array('multiple_key', $field_def['flags']) || in_array('unique_key', $field_def['flags']);
         switch ($field_def['type']) {
             case 'int':
                 $type = VAR_TYPE_INT;
                 break;
             case 'boolean':
                 $type = VAR_TYPE_BOOLEAN;
                 break;
             case 'datetime':
                 $type = VAR_TYPE_DATETIME;
                 break;
             default:
                 $type = VAR_TYPE_STRING;
                 break;
         }
         $prop_def[$field_def['name']] = array('primary' => $primary, 'seq' => $seq, 'key' => $key, 'type' => $type, 'required' => $required, 'length' => $field_def['len'], 'form_name' => $this->_fieldNameToFormName($field_def), 'table' => $table_name);
     }
     $cache_manager->set($cache_key, $prop_def);
     return $prop_def;
 }