class \mpf\datasources\sql\SqlCommand

class \mpf\datasources\sql\SqlCommand

Description of SqlCommand

@author mirel

Attributes
public string $table

Name of the table used for query

public \mpf\datasources\sql\PDOConnection $connection

-no description found-

public int $offset

Offset from wich to start reading/updating

public int $limit

Maximum number of elements to be returned;

public string $condition

String sql ready condition;

public string $order

Column or expression used for order;

public string $having

Having condition; Can be used in addition to group

public string $group

Column or expression to be used for grouping

public mixed $with

An array of relation names or a string with relation names separated by ","; Can only be used from a model. @example "child1, child2, child2.subchild2"

public mixed $fields = "*"

Fields to be selected; Can be an array of field or a string with columns / expressions separated by ,

public string $join = ""

Extra joins can be manually written here. Can be used when there is no model but relations are still needed in the query;

public string $procedure

Set procedure name and arguments for select; @link https://dev.mysql.com/doc/refman/5.0/en/select.html

public string $into = ""

Possible options: OUTFILE 'filename' export options DUMPFILE 'filename' varname [, varname] @link https://dev.mysql.com/doc/refman/5.0/en/select.html

public bool $for_update

If set to true "FOR UPDATE" will be added to query;

public bool $lock_in_share_mode

If set to true "LOCK IN SHARE MODE" will be added to query;

public bool $ignore

If set to true will be used for INSER & UPDATE queries;

protected string[] $params = []

List of parameters linked to current condition;

protected int $currentPos

Used by next() method to record current position.

Methods

public \mpf\datasources\sql\SqlCommand compare (array $columns2values = [])

  • $columns2values

    -no description found-

-no description found-

public int truncate ()

Truncate selected table from database.

public int drop ()

Drop selected table from database.

public \mpf\datasources\sql\SqlCommand where (string $condition, string[] $params = [])

  • $condition

    -no description found-

  • $params

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand andWhere (mixed $condition, string[] $params = [])

  • $condition

    -no description found-

  • $params

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand orWhere (mixed $condition, string[] $params = [])

  • $condition

    -no description found-

  • $params

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand setParam (mixed $name, mixed $value)

  • $name

    -no description found-

  • $value

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand setParams (array $params)

  • $params

    -no description found-

Set multiple params

public \mpf\datasources\sql\SqlCommand fields (string $fields)

  • $fields

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand orderBy (string $order)

  • $order

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand groupBy (string $group)

  • $group

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand having (string $having)

  • $having

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand offset (int $index)

  • $index

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand limit (int $number)

  • $number

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand join (string $joinString)

  • $joinString

    -no description found-

-no description found-

public \mpf\datasources\sql\SqlCommand cache (mixed $seconds)

  • $seconds

    -no description found-

Cache result for the selected interval

public \mpf\datasources\sql\SqlCommand into (string $into)

  • $into

    -no description found-

Select into option.

public string[] first ()

Returns a single row as assoc array

public null next ()

Return results one by one. If a limit is set it won't go further than the selected limit. Also it will start from the selected offset if one is set.

public string get ()

Creates select query, executes it and returns the result as assoc array.

public int count ()

Return number of rows for current options.

public int increment (string $column, int $value)

  • $column

    -no description found-

  • $value

    -no description found-

Updates a single column and increments it with selected value. Returns number of affected rows.

public int insert (string $columns, string $duplicateKey = null, string[] $params = [])

  • $columns

    -no description found-

  • $duplicateKey

    Can have the value "ignore" or list of columns to update

  • $params

    Optional params in case that string is sent to duplicate key

Inserts a new row and returns the id or false if failed.

public int update (mixed $columns)

  • $columns

    -no description found-

Update selected columns and return the number of affected rows.

public int delete ()

Deletes rows that match condition. It will return number of affected rows.