项目作者: mastro-elfo

项目描述 :
PHP class to manage mysqli DB
高级语言: PHP
项目地址: git://github.com/mastro-elfo/MYDB.git
创建时间: 2017-05-29T14:29:21Z
项目社区:https://github.com/mastro-elfo/MYDB

开源协议:MIT License

下载


MYDB

See also comments in code.

MYDB::last_query

The last executed query.

MYDB::query

Sends a generic query. Also saves the query string to $this->last_query.

Params

  • string $query The query string

Return

Returns false on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries will return a mysqli_result object. For other successful queries will return true. See also http://php.net/manual/en/mysqli.query.php.

MYDB::insert

Creates and sends an ‘INSERT INTO’ query.

Params

  • string $table The table name
  • array $data Associative array. Keys are field names, Values are field values.

Return

The last insert id on success, 0 on failure

Example

  1. $db->insert('Table', [
  2. 'Field1' => 'Value1',
  3. 'Field2' => 'Value2'
  4. ]);

MYDB::replace

Creates and sends a ‘REPLACE INTO’ query

Params

  • string $table Table name
  • array $data Associative array. Keys are field names, Values are field values.

Return

The last insert id on success, 0 on failure

MYDB::update

Creates and sends an ‘UPDATE’ query.

Params

  • string $table The table name
  • array $data Associative array. Keys are field names, Values are field values.
  • array $where WHERE clause. Items are joined with AND.

Return

true on success, false on failure

MYDB::upsert

Create and sends an ‘INSERT INTO’ query. On duplicate key sends an ‘UPDATE’ query.

Params

  • string $table The table name
  • array $data Associative array. Keys are field names, Values are field values.
  • array $where WHERE clause. This became part of $data in the ‘INSERT INTO’ query, and a real WHERE clause in the ‘UPDATE’ query.

Return

Returns false on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries will return a mysqli_result object. For other successful queries will return true. See also http://php.net/manual/en/mysqli.query.php.

MYDB::select

Create and sends a ‘SELECT’ query.

Params

  • string $table Table name
  • mixed $fields array of fields names or '*' for all
  • array $where WHERE clause. Items are joined with AND.
  • array $orderby ORDER BY clause. [field_name => 'ASC|DESC', ...]
  • mixed $limit LIMIT clause. Use one number to limit results number or two comma separated numbers for paging.

Return

For successful queries return a mysqli_result object. Returns false on failure.

MYDB::delete

Creates and sends a ‘DELETE’ query.

Params

  • string $table Table name
  • array $where WHERE clause. Items are joined with AND.

Return

true on success, false on failure