public function columns($table) { if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) { $starttime = lib_datetime_microtime(); } $store = array(); $object_result = core_database::i()->query("\n\t\t\t\tselect * from `" . core_database::i()->real_escape_string($table) . "` LIMIT 1;\n\t\t\t"); $object_fields = $object_result->fetch_fields(); for ($i = 0; $i < count($object_fields); $i++) { $store[] = $object_fields[$i]->name; } if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) { $endtime = lib_datetime_microtime(); core_debug::i()->add('query', $query, round($endtime - $starttime, 6)); } return $store; }
/** * Delete record prototype */ public function delete() { // <editor-fold defaultstate="collapsed" desc="BUILD QUERY"> $pad = ' '; $str_ident = '##' . get_called_class() . ' ' . __FUNCTION__ . '()' . " \n"; $obj_data->sanitize(); $str_update = 'DELETE FROM ' . static::$db_table . " \n"; if (array_key_exists($query_column, static::$db_columns)) { $str_where = 'WHERE `' . core_database::i()->real_escape_string($query_column) . '` = "' . core_database::i()->real_escape_string($query) . '"' . " \n"; } else { core_debug::i()->add('500', 'Unknown db_column', '"' . $query_column . '"'); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="QUERY DATABASE"> try { $this->array_result = core_database::i()->debug_query($str_update . $pad . $str_set . $pad . $str_where); } catch (Exception $e) { core_debug::i()->add('500', $e->getMessage(), ''); } // </editor-fold> }
/** * Cleans up the members for database insertion */ public function sanitize() { foreach ($this as $key => $value) { if ($key != '_properties') { if (array_key_exists($key, static::$db_columns)) { switch (static::$db_columns[$key]) { case 'int': $this->{$key} = (int) $value; break; case 'bool': $this->{$key} = (bool) $value; break; case 'float': $this->{$key} = (double) $value; break; case 'datetime': $this->{$key} = 'FROM_UNIXTIME(' . (int) $value . ')'; break; case 'string': $this->{$key} = '"' . (string) core_database::i()->real_escape_string($value) . '"'; break; default: throw new Exception('Sanitize Failed - Unknown Type "' . static::$db_columns[$key] . '"'); } } } } }