CrossPHP
  • Namespace
  • Class
  • Download

Namespaces

  • Cross
    • Auth
    • Cache
      • Driver
      • Request
    • Core
    • DB
      • Connecter
      • Drivers
      • SQLAssembler
    • Exception
    • Http
    • I
    • Lib
      • Document
    • Module
    • MVC
    • Runtime
  • None

Classes

  • MySQLAssembler
  • PgSQLAssembler
  • SQLAssembler
  • SQLiteAssembler

Class SQLAssembler

Direct known subclasses

Cross\DB\SQLAssembler\MySQLAssembler, Cross\DB\SQLAssembler\PgSQLAssembler, Cross\DB\SQLAssembler\SQLiteAssembler

Namespace: Cross\DB\SQLAssembler
Package: Cross\DB\SQLAssembler
Author:

wonli wonli@live.com Class SQLAssembler


Located at DB/SQLAssembler/SQLAssembler.php

Methods summary

public
# __construct( string $table_prefix = '' )

初始化时可以指定表前缀

初始化时可以指定表前缀

Parameters

$table_prefix
public
# add( string $table, array & $data, boolean $multi = false )

插入

插入

Parameters

$table
表名称
$data
要处理的数据关联数组
$multi

是否批量插入数据

批量插入数据时$data的结构如下:
     $data = array(
         'fields' => array(字段1,字段2,...),
         'values' => array(
                     array(字段1的值, 字段2的值),
                     array(字段1的值, 字段2的值))
     );
public mixed|
# find( string $table, string $fields, string $where, integer|string $order = 1, array & $page = array('p' => 1, 'limit' => 50), integer|string $group_by = 1 )

带分页功能的查询

带分页功能的查询

Parameters

$table
表名称, 复杂情况下, 以LEFT JOIN为例: table_a a LEFT JOIN table_b b ON a.id=b.aid
$fields
要查询的字段 所有字段的时候为'*'
$where
查询条件
$order
排序
$page
分页参数 默认返回50条记录
$group_by

Returns

mixed|

Throws

Cross\Exception\CoreException
public mixed|
# update( string $table, string $data, string $where )

更新

更新

Parameters

$table
$data
$where

Returns

mixed|

Throws

Cross\Exception\CoreException
public mixed|
# del( string $table, string|array $where, boolean $multi = false )

删除

删除

Parameters

$table
$where
$multi

是否批量删除数据 $where = array( 'fields' => array(字段1,字段2,...), 'values' => array( array(字段1的值, 字段2的值), array(字段1的值, 字段2的值)) );

Returns

mixed|

Throws

Cross\Exception\CoreException
public string
# select( string $fields = '*', string $modifier = '' )

select

select

Parameters

$fields
$modifier

Returns

string
public string
# insert( string $table, string $modifier, array $data, array & $params = array() )

insert

insert

Parameters

$table
$modifier
$data
$params

Returns

string
public string
# replace( string $table, string $modifier = '' )

replace

replace

Parameters

$table
$modifier

Returns

string
public string
# from( $table )

Parameters

$table

Returns

string
public string
# where( string|array $where, array & $params )

Parameters

$where
$params

Returns

string

Throws

Cross\Exception\CoreException
public string
# limit( integer $start, boolean|integer $end = false )

Parameters

$start
$end

Returns

string
public string
# offset( integer $offset )

Parameters

$offset

Returns

string
public string
# orderBy( $order )

Parameters

$order

Returns

string
public string
# groupBy( $group )

Parameters

$group

Returns

string
public string
# having( $having )

Parameters

$having

Returns

string
public string
# procedure( $procedure )

Parameters

$procedure

Returns

string
public string
# into( $var_name )

Parameters

$var_name

Returns

string
public string
# set( string $data, array & $params = array() )

Parameters

$data
$params

Returns

string
public string
# on( string $on )

Parameters

$on

Returns

string
public string
# parseFields( string|array $fields )

解析字段

解析字段

Parameters

$fields

Returns

string
public string
# parseWhere( string|array $where, array & $params )

解析where

解析where

Parameters

$where
$params

Returns

string

Throws

Cross\Exception\CoreException
public integer|string
# parseOrder( string $order )

解析order

解析order

Parameters

$order

Returns

integer|string
public integer
# parseGroup( string $group_by )

解析group by

解析group by

Parameters

$group_by

Returns

integer
public string
# getSQL( )

Returns

string
protected
# setSQL( $sql )

Parameters

$sql
public string|array
# getParams( )

Returns

string|array
public string
# getPrefix( )

获取表前缀

获取表前缀

Returns

string
protected
# setParams( $params )

Parameters

$params
protected array
# parseCondition( string $operator, string $field, string|array $field_config, boolean $is_mixed_field, string $condition_connector, string $connector, array & $params )

解析where条件

解析where条件

Parameters

$operator
字段和值之间的操作符
$field
字段名
$field_config
字段值配置
$is_mixed_field
区别默认字段和复合字段(带括号的字段)
$condition_connector
每个条件之间的连接符
$connector
每个字段之间的连接符
$params
包含字段值的数组(prepare之后传递的参数)

Returns

array

Throws

Cross\Exception\CoreException

Properties summary

protected string $sql
#
protected string $params
#
protected string $table_prefix

表前缀

表前缀

#
protected boolean $offset_is_valid

offset()在limit()中已经传递了第二个参数时不再生效

offset()在limit()中已经传递了第二个参数时不再生效

# true
CrossPHP API documentation generated by ApiGen