Пример #1
0
 /**
  * escape a column's value, or return the default value if none specified
  *
  * @return string
  */
 public static function column_value_default($node_schema, $node_table, $data_column_name, $node_col)
 {
     // if marked, make it null or default, depending on column options
     if (isset($node_col['null']) && strcasecmp('true', $node_col['null']) == 0) {
         $value = 'NULL';
     } else {
         if (isset($node_col['empty']) && strcasecmp('true', $node_col['empty']) == 0) {
             if (pgsql8::E_ESCAPE) {
                 $value = "E''";
             } else {
                 $value = "''";
             }
         } else {
             if (isset($node_col['sql']) && strcasecmp($node_col['sql'], 'true') == 0) {
                 if (strcasecmp($node_col, 'default') === 0) {
                     $value = 'DEFAULT';
                 } else {
                     $value = '(' . $node_col . ')';
                 }
             } else {
                 if (strlen($node_col) == 0) {
                     // is there a default defined for the column?
                     $dummy_data_column = new stdClass();
                     $column_default_value = xml_parser::column_default_value($node_table, $data_column_name, $dummy_data_column);
                     if ($column_default_value != NULL) {
                         $value = $column_default_value;
                     } else {
                         $value = 'NULL';
                     }
                 } else {
                     //$node_column = dbx::get_table_column($node_table, $data_column_name);
                     $node_column = xml_parser::inheritance_get_column($node_table, $data_column_name);
                     $node_column = $node_column[0];
                     if ($node_column === NULL) {
                         throw new exception("Failed to find table " . $node_table['name'] . " column " . $data_column_name . " for default value check");
                     }
                     $value_type = pgsql8_column::column_type(dbsteward::$new_database, $node_schema, $node_table, $node_column, $foreign);
                     $value = pgsql8::value_escape($value_type, dbsteward::string_cast($node_col));
                 }
             }
         }
     }
     return $value;
 }
Пример #2
0
 /**
  * escape a column's value, or return the default value if none specified
  *
  * @NOTE: it is critical to note that colmn values should always be escaped with this function
  *        as it also converts MSSQL specific values from postgresql ones
  *
  * @return string
  */
 public static function column_value_default($node_schema, $node_table, $data_column_name, $node_col)
 {
     // if marked, make it null or default, depending on column options
     if (isset($node_col['null']) && strcasecmp('true', $node_col['null']) == 0) {
         return 'NULL';
     }
     // columns that specify empty attribute are made empty strings
     if (isset($node_col['empty']) && strcasecmp('true', $node_col['empty']) == 0) {
         return "''";
     }
     // don't esacape columns marked literal sql values
     if (isset($node_col['sql']) && strcasecmp($node_col['sql'], 'true') == 0) {
         return '(' . $node_col . ')';
     }
     $node_column = dbx::get_table_column($node_table, $data_column_name);
     if ($node_column === NULL) {
         throw new exception("Failed to find table " . $node_table['name'] . " column " . $data_column_name . " for default value check");
     }
     $value_type = mysql5_column::column_type(dbsteward::$new_database, $node_schema, $node_table, $node_column);
     // else if col is zero length, make it default, or DB NULL
     if (strlen($node_col) == 0) {
         // is there a default defined for the column?
         $dummy_data_column = new stdClass();
         $column_default_value = xml_parser::column_default_value($node_table, $data_column_name, $dummy_data_column);
         if ($column_default_value != NULL) {
             // run default value through value_escape to allow data value conversions to happen
             $value = mysql5::value_escape($value_type, $column_default_value);
         } else {
             $value = 'NULL';
         }
     } else {
         $value = mysql5::value_escape($value_type, dbsteward::string_cast($node_col));
     }
     return $value;
 }
Пример #3
0
 /**
  * escape a column's value, or return the default value if none specified
  *
  * @NOTE: it is critical to note that colmn values should always be escaped with this function
  *        as it also converts MSSQL specific values from postgresql ones
  *
  * @return string
  */
 public static function column_value_default($node_schema, $node_table, $data_column_name, $node_col)
 {
     // if marked, make it null or default, depending on column options
     if (isset($node_col['null']) && strcasecmp('true', $node_col['null']) == 0) {
         $value = 'NULL';
     } else {
         if (isset($node_col['empty']) && strcasecmp('true', $node_col['empty']) == 0) {
             // string escape prefix needed? -- see pgsql8::E_ESCAPE usage
             $value = "''";
         } else {
             if (isset($node_col['sql']) && strcasecmp($node_col['sql'], 'true') == 0) {
                 $value = '(' . $node_col . ')';
             } else {
                 $node_column = dbx::get_table_column($node_table, $data_column_name);
                 if ($node_column === NULL) {
                     throw new exception("Failed to find table " . $node_table['name'] . " column " . $data_column_name . " for default value check");
                 }
                 $value_type = mssql10_column::column_type(dbsteward::$new_database, $node_schema, $node_table, $node_column, $foreign);
                 // else if col is zero length, make it default, or DB NULL
                 if (strlen($node_col) == 0) {
                     // is there a default defined for the column?
                     $dummy_data_column = new stdClass();
                     $column_default_value = xml_parser::column_default_value($node_table, $data_column_name, $dummy_data_column);
                     if ($column_default_value != NULL) {
                         // run default value through value_escape to allow data value conversions to happen
                         $value = mssql10::value_escape($value_type, $column_default_value);
                     } else {
                         $value = 'NULL';
                     }
                 } else {
                     $value = mssql10::value_escape($value_type, dbsteward::string_cast($node_col));
                 }
             }
         }
     }
     return $value;
 }