CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.1 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.1
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Query
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Interface StatementInterface

Namespace: Cake\Database

Constants

  • string
    FETCH_TYPE_ASSOC ¶
    'assoc'

    Maps to PDO::FETCH_ASSOC.

  • string
    FETCH_TYPE_NUM ¶
    'num'

    Maps to PDO::FETCH_NUM.

  • string
    FETCH_TYPE_OBJ ¶
    'obj'

    Maps to PDO::FETCH_OBJ.

Method Summary

  • bind() public

    Binds a set of values to statement object with corresponding type.

  • bindValue() public

    Assign a value to a positional or named variable in prepared query. If using positional variables you need to start with index one, if using named params then just use the name in any order.

  • closeCursor() public

    Closes the cursor, enabling the statement to be executed again.

  • columnCount() public

    Returns the number of columns in the result set.

  • errorCode() public

    Fetch the SQLSTATE associated with the last operation on the statement handle.

  • errorInfo() public

    Fetch extended error information associated with the last operation on the statement handle.

  • execute() public

    Executes the statement by sending the SQL query to the database. It can optionally take an array or arguments to be bound to the query variables. Please note that binding parameters from this method will not perform any custom type conversion as it would normally happen when calling bindValue.

  • fetch() public

    Fetches the next row from a result set and converts fields to types based on TypeMap.

  • fetchAll() public

    Fetches the remaining rows from a result set and converts fields to types based on TypeMap.

  • fetchAssoc() public

    Fetches the next row from a result set using PDO::FETCH_ASSOC and converts fields to types based on TypeMap.

  • fetchColumn() public

    Fetches the next row from a result set using PDO::FETCH_NUM and converts fields to types based on TypeMap.

  • getBoundParams() public

    Get the bound params.

  • lastInsertId() public

    Returns the latest primary inserted using this statement.

  • queryString() public

    Returns prepared query string.

  • rowCount() public

    Returns the number of rows affected by the last SQL statement.

Method Detail

bind() ¶ public

bind(array $params, array $types): void

Binds a set of values to statement object with corresponding type.

Parameters
array $params

list of values to be bound

array $types

list of types to be used, keys should match those in $params

Returns
void

bindValue() ¶ public

bindValue(string|int $column, mixed $value, string|int|null $type = 'string'): void

Assign a value to a positional or named variable in prepared query. If using positional variables you need to start with index one, if using named params then just use the name in any order.

It is not allowed to combine positional and named variables in the same statement.

Examples:

$statement->bindValue(1, 'a title');
$statement->bindValue('active', true, 'boolean');
$statement->bindValue(5, new \DateTime(), 'date');
Parameters
string|int $column

name or param position to be bound

mixed $value

The value to bind to variable in query

string|int|null $type optional

name of configured Type class

Returns
void

closeCursor() ¶ public

closeCursor(): void

Closes the cursor, enabling the statement to be executed again.

This behaves the same as PDOStatement::closeCursor().

Returns
void

columnCount() ¶ public

columnCount(): int

Returns the number of columns in the result set.

This behaves the same as PDOStatement::columnCount().

Returns
int
Links
https://php.net/manual/en/pdostatement.columncount.php

errorCode() ¶ public

errorCode(): string

Fetch the SQLSTATE associated with the last operation on the statement handle.

This behaves the same as PDOStatement::errorCode().

Returns
string
Links
https://www.php.net/manual/en/pdostatement.errorcode.php

errorInfo() ¶ public

errorInfo(): array

Fetch extended error information associated with the last operation on the statement handle.

This behaves the same as PDOStatement::errorInfo().

Returns
array
Links
https://www.php.net/manual/en/pdostatement.errorinfo.php

execute() ¶ public

execute(array|null $params = null): bool

Executes the statement by sending the SQL query to the database. It can optionally take an array or arguments to be bound to the query variables. Please note that binding parameters from this method will not perform any custom type conversion as it would normally happen when calling bindValue.

Parameters
array|null $params optional

list of values to be bound to query

Returns
bool

fetch() ¶ public

fetch(string|int $mode = PDO::FETCH_NUM): mixed

Fetches the next row from a result set and converts fields to types based on TypeMap.

This behaves the same as PDOStatement::fetch().

Parameters
string|int $mode optional

PDO::FETCH_* constant or fetch mode name. Valid names are 'assoc', 'num' or 'obj'.

Returns
mixed
Throws
InvalidArgumentException
Links
https://www.php.net/manual/en/pdo.constants.php

fetchAll() ¶ public

fetchAll(string|int $mode = PDO::FETCH_NUM): array

Fetches the remaining rows from a result set and converts fields to types based on TypeMap.

This behaves the same as PDOStatement::fetchAll().

Parameters
string|int $mode optional

PDO::FETCH_* constant or fetch mode name. Valid names are 'assoc', 'num' or 'obj'.

Returns
array
Throws
InvalidArgumentException
Links
https://www.php.net/manual/en/pdo.constants.php

fetchAssoc() ¶ public

fetchAssoc(): array

Fetches the next row from a result set using PDO::FETCH_ASSOC and converts fields to types based on TypeMap.

This behaves the same as PDOStatement::fetch() except an empty array is returned instead of false.

Returns
array

fetchColumn() ¶ public

fetchColumn(int $position): mixed

Fetches the next row from a result set using PDO::FETCH_NUM and converts fields to types based on TypeMap.

This behaves the same as PDOStatement::fetch() except only a specific column from the row is returned.

Parameters
int $position

Column index in result row.

Returns
mixed

getBoundParams() ¶ public

getBoundParams(): array

Get the bound params.

Returns
array

lastInsertId() ¶ public

lastInsertId(string|null $table = null, string|null $column = null): string|int

Returns the latest primary inserted using this statement.

Parameters
string|null $table optional

table name or sequence to get last insert value from

string|null $column optional

the name of the column representing the primary key

Returns
string|int

queryString() ¶ public

queryString(): string

Returns prepared query string.

Returns
string

rowCount() ¶ public

rowCount(): int

Returns the number of rows affected by the last SQL statement.

This behaves the same as PDOStatement::rowCount().

Returns
int
Links
https://www.php.net/manual/en/pdostatement.rowcount.php
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs