Documentation ¶
Index ¶
- func BoolToFloat64(b bool) float64
- func BoolToInt(b bool) int
- func Concat(left, right interface{}) string
- func FileExists(f string) bool
- func Microtime() float64
- func Scandir(d string) array.String
- func StrDec(s string) string
- func StrInc(s string) string
- func ToInt(s interface{}) int
- func Truthy(i interface{}) bool
- type Bool
- type Rows
- type SQL
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolToFloat64 ¶
BoolToFloat converts b to float the same way like PHP do.
func Concat ¶
func Concat(left, right interface{}) string
Concat joins two values, interfaces, to one string. Represents PHP's "." concat operator.
func FileExists ¶
FileExists checks if the file with the given name exists. It does the same thing as PHP file_exists.
func Microtime ¶
func Microtime() float64
Microtime returns current Unix timestamp with microseconds. It represents PHP function with the same name, with one big difference, this value is always float.
See php.net/manual/en/function.microtime.php for more details.
func Scandir ¶
Scandir returns every file and folder found in the directory. If d is not valid directory, empty array is returned. It does the same thing as PHP scandir, here it is just wrapper to "hide" extra information, only name is required. Right now it does not return "." and "..", but these directories does not make much sense anyways.
Types ¶
type Bool ¶
type Bool interface { // ToBool is the only method implemented // in this interface. The name is specific // enough so no collisions should be ever // discovered. ToBool() bool }
Bool is used to add an option to implement non-implicit conversion. Used in std.Array and std.SQL.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows wraps *sqlx.Rows, the main goal is to rename a method to make it more clear what it does, and hide SQL package in the transpiled script.
func (*Rows) Next ¶
Next is one of the methods use to implement mysqli_fetch_array(). Instead of returning struct or a false, which represents if the result is empty, Next is used only for this flag "is empty".
func (*Rows) Scan ¶
func (r *Rows) Scan(t interface{})
Scan fills passed pointer to struct t with values found in the rows. It is the second implementation of mysqli_fetch_array(). In PHP it has two arguments, first one is here represented by Rows, the second one defines returned value type. Here I support only MYSQLI_ASSOC, which is here implemented as struct. This is probably the only way how to make strictly typed with the current set of supported operations in the transpiler.
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL wraps MySQL connection. The main purpose is to behave the same way as PHP SQL connection does.
func NewSQL ¶
NewSQL creates struct SQL with defined server, user, and its password. Function call is the same like mysqli_connect().
func (*SQL) Close ¶
func (s *SQL) Close()
Close is another wrapper for connection, but this one is not present in PHP. Closes SQL connection.
func (*SQL) Query ¶
Query performs SQL query defined in q. It returns std.Rows. It is the alias for mysqli_query(), where connection is the struct, not the first argument.
func (*SQL) SelectDB ¶
SelectDB adds information about table. With this information the connection is really opened. It is opened as "Unsafe" connection. This hides issues with not reading every column in `SELECT *` etc. It is the alias for mysqli_select_db(), where connection is the struct, not the first argument.
Notes ¶
Bugs ¶
it does not support diferent bases like HEX etc.