Skip to content
Christian Blanquera edited this page Mar 11, 2018 · 3 revisions

API

bind

Binds a value and returns the bound key

Usage

$database->bind(*string|array|number|null $value);

Parameters

  • *string|array|number|null $value - What to bind

Returns string

Example

$database->bind('foo');

collection

Returns collection

Usage

$database->collection(array $data);

Parameters

  • array $data - Initial collection data

Returns Eden\Sql\Collection

Example

$database->collection();

delete

Returns the delete query builder

Usage

$database->delete(*string|null $table);

Parameters

  • *string|null $table - The table name

Returns Eden\Sql\Delete

Example

$database->delete('foo');

deleteRows

Removes rows that match a filter

Usage

$database->deleteRows(*string|null $table, array|string $filters);

Parameters

  • *string|null $table - The table name
  • array|string $filters - Filters to test against

Returns Eden\Sql\Collection

Example

$database->deleteRows('foo');

getBinds

Returns all the bound values of this query

Usage

$database->getBinds();

Parameters

Returns array


getConnection

Returns the connection object if no connection has been made it will attempt to make it

Usage

$database->getConnection();

Parameters

Returns resource - PDO connection resource


getLastInsertedId

Returns the last inserted id

Usage

$database->getLastInsertedId(string|null $column);

Parameters

  • string|null $column - A particular column name

Returns int - the id

Example

$database->getLastInsertedId();

getModel

Returns a model given the column name and the value

Usage

$database->getModel(*string $table, *string $name, *scalar|null $value);

Parameters

  • *string $table - Table name
  • *string $name - Column name
  • *scalar|null $value - Column value

Returns Eden\Sql\Model|null

Example

$database->getModel('foo', 'foo', $value);

getQueries

Returns the history of queries made still in memory

Usage

$database->getQueries(int|string|null $index);

Parameters

  • int|string|null $index - A particular index to return

Returns array|null - the queries

Example

$database->getQueries();

getRow

Returns a 1 row result given the column name and the value

Usage

$database->getRow(*string $table, *string $name, *scalar|null $value);

Parameters

  • *string $table - Table name
  • *string $name - Column name
  • *scalar|null $value - Column value

Returns array|null

Example

$database->getRow('foo', 'foo', $value);

insert

Returns the insert query builder

Usage

$database->insert(string|null $table);

Parameters

  • string|null $table - Name of table

Returns Eden\Sql\Insert

Example

$database->insert();

insertRow

Inserts data into a table and returns the ID

Usage

$database->insertRow(*string $table, *array $setting, bool|array $bind);

Parameters

  • *string $table - Table name
  • *array $setting - Key/value array matching table columns
  • bool|array $bind - Whether to compute with binded variables

Returns Eden\Sql\Index

Example

$database->insertRow('foo', array('foo' => 'bar'));

insertRows

Inserts multiple rows into a table

Usage

$database->insertRows(*string $table, array $setting, bool|array $bind);

Parameters

  • *string $table - Table name
  • array $setting - Key/value 2D array matching table columns
  • bool|array $bind - Whether to compute with binded variables

Returns Eden\Sql\Index

Example

$database->insertRows('foo');

model

Returns model

Usage

$database->model(array $data);

Parameters

  • array $data - The initial data to set

Returns Eden\Sql\Model

Example

$database->model();

query

Queries the database

Usage

$database->query(*string $query, array $binds);

Parameters

  • *string $query - The query to ran
  • array $binds - List of binded values

Returns array

Example

$database->query('foo');

search

Returns search

Usage

$database->search(string|null $table);

Parameters

  • string|null $table - Table name

Returns Eden\Sql\Search

Example

$database->search();

select

Returns the select query builder

Usage

$database->select(string|array $select);

Parameters

  • string|array $select - Column list

Returns Eden\Sql\Select

Example

$database->select();

setBinds

Sets all the bound values of this query

Usage

$database->setBinds(*array $binds);

Parameters

  • *array $binds - key/values to bind

Returns Eden\Sql\Index

Example

$database->setBinds(array('foo' => 'bar'));

setCollection

Sets default collection

Usage

$database->setCollection(*string $collection);

Parameters

  • *string $collection - Collection class name

Returns Eden\Sql\Index

Example

$database->setCollection('foo');

setModel

Sets the default model

Usage

$database->setModel(*string Model);

Parameters

  • *string Model - class name

Returns Eden\Sql\Index

Example

$database->setModel('foo');

setRow

Sets only 1 row given the column name and the value

Usage

$database->setRow(*string $table, *string $name, *scalar|null $value, *array $setting);

Parameters

  • *string $table - Table name
  • *string $name - Column name
  • *scalar|null $value - Column value
  • *array $setting - Key/value array matching table columns

Returns Eden\Sql\Index

Example

$database->setRow('foo', 'foo', $value, array('foo' => 'bar'));

update

Returns the update query builder

Usage

$database->update(string|null $table);

Parameters

  • string|null $table - Name of table

Returns Eden\Sql\Update

Example

$database->update();

updateRows

Updates rows that match a filter given the update settings

Usage

$database->updateRows(*string $table, *array $setting, array|string $filters, bool|array $bind);

Parameters

  • *string $table - Table name
  • *array $setting - Key/value array matching table columns
  • array|string $filters - Filters to test against
  • bool|array $bind - Whether to compute with binded variables

Returns Eden\Sql\Index

Example

$database->updateRows('foo', array('foo' => 'bar'));