删除符合条件的项
@param mixed $muti
- mysql的情况: bool true 删除多条 返回影响数 false: 只能删除一条

@param string $table
@param mixed $condition
@return bool/int
337198
public static function remove($table, $condition, $muti = true)
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->remove($table, $condition, $muti);
    }
1023166
public function one(string $condition = '', array $params = []) {
        $this->model->builder->select('*')
            ->from($this->model->tableName);
        if ($condition) {
            $this->model->builder->where($condition, $params);
        }
        $r = $this->model->builder->limit(1)
            ->query();
        if (!is_array($r) || 0 === count($r)) {
            return null;
        }
        return $this->model->setup($r[0]);
    }
1283394
public static function count($table, $condition, $field = '1')
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->count($table, $condition, $field);
    }
603072
public function equals(\Skeleton\Pager\Sql\Condition $condition) {
		if ($this->get_local_field() != $condition->get_local_field()) {
			return false;
		}

		if ($this->get_comparison() == '=' AND $condition->get_comparison() == 'IN') {
			foreach ($condition->get_value() as $value) {
				if (in_array($value, $this->get_value())) {
					return true;
				}
			}
		}

		if ($condition->get_comparison() == '=' AND $this->get_comparison() == 'IN') {
			foreach ($this->get_value() as $value) {
				if (in_array($value, $condition->get_value())) {
					return true;
				}
			}
		}

		if ($this->get_comparison() != $condition->get_comparison()) {
			return false;
		}

		if (!is_array($this->get_value()) and !is_array($condition->get_value())) {
			if ($this->get_value() != $condition->get_value()) {
				return false;
			}
		} elseif (is_array($this->get_value()) and is_array($condition->get_value())) {
			$diff = array_diff($this->get_value(), $condition->get_value());
			if (count($diff) > 0) {
				return false;
			}
		} else {
			return false;
		}

		return true;
	}
1305647
public function where( $condition ) {
		if ( ! $condition instanceof ConditionInterface ) {
			$condition = func_get_args();
		}

		$condition = $this->router->mergeConditionAttribute(
			$this->getAttribute( 'condition' ),
			$condition
		);

		return $this->attribute( 'condition', $condition );
	}
966469
private function setManyToManyJoin($table, $alias, $condition = null)
    {
        if (!in_array($alias, $this->tables)) {
            if ($condition) {
                $this->queryBuilder->join($table, $alias, 'WITH', $condition);
            } else {
                $this->queryBuilder->join($table, $alias);
            }
            $this->tables[] = $alias;
        }
    }
322761
public function addTable($alias, $table, $condition = null, $joinType = 'LEFT', $prefix = null)
    {
        $tableStorage = [];

        $tableStorage['name'] = $table;
        $tableStorage['join'] = strtoupper($joinType);

        $condition = trim((string) new QueryElement('', (array) $condition, ' AND '));

        if (!$condition) {
            $tableStorage['join'] = 'FROM';
        }

        // Remove too many spaces
        $condition = preg_replace('/\s(?=\s)/', '', $condition);

        $tableStorage['condition'] = $condition;
        $tableStorage['prefix'] = $prefix;

        $this->tables[$alias] = $tableStorage;

        return $this;
    }
833268
protected function findIndexesForTableConditions(
        array $conditions,
        TableInterface $table,
        $tableName
    ) {
        $indexes = array();

        /* @var $tableSchema TableSchema */
        $tableSchema = $table->getTableSchema();

        $conditionColumns = array();

        foreach ($conditions as $condition) {
            /* @var $condition ConditionJob */

            $column = $condition->getFirstParameter();
            $fixedValue = $condition->getLastParameter();

            if ($fixedValue instanceof ColumnSpecifier) {
                list($column, $fixedValue) = [$fixedValue, $column];
            }

            if ($column instanceof ColumnSpecifier) {
                /* @var $column ColumnSpecifier */

                if (is_null($column->getTable()) || $column->getTable() === $tableName) {
                    $columnId = $tableSchema->getColumnIndex($column->getColumn());

                    if (is_int($columnId) && $columnId >= 0) {
                        $conditionColumns[$column->getColumn()] = $columnId;
                    }
                }
            }
        }

        if (!empty($conditionColumns)) {
            foreach ($tableSchema->getIndexIterator() as $indexId => $indexSchema) {
                /* @var $indexSchema IndexSchema */

                $indexColumns = $indexSchema->getColumns();

                if (empty(array_diff($indexColumns, $conditionColumns))) {
                    /* @var $index IndexInterface */
                    $index = $table->getIndex($indexId);

                    $indexes[] = $index;
                }
            }
        }

        return $indexes;
    }
686839
public function hasTable($table) {
        //$sql = $this->grammar->compileTableExists();
        $table = $this->connection->getTablePrefix() . $table;
        return count($this->connection->select(array($table))) > 0;
    }
82133
public function max($table, $field, $conditions = false)
    {
        return $this->executeAggregate('MAX', $table, $field, $conditions);
    }
1373900
public function checkTableExist($table, $con=NULL)
    {
        $connection = $this->checkConnection($con);
        $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1");
        if($query !== false)
        {
            return true;
        }
    }
1342187
public function count($condition = null, $params = null, $distinct=false) {
		if ($condition) {
			$this->driver->where($condition, $params);
		}
		return $this->driver->count($distinct);
	}
960129
public function hasTable($table)
    {
        $table = $this->connection->getTablePrefix().$table;

        return count($this->connection->selectFromWriteConnection(
            $this->grammar->compileTableExists(), [$table]
        )) > 0;
    }
690831
public function seek($condition = array(), $order=array()){
		$where = array();
		$orderBy = array();
		foreach ($condition as $key=>$value){
			if ($value!=NULL && is_object($value) && get_class($value)==NotSet::class){
				// nuevo. el campo no está establecido
			}else{
				$where[] = sprintf("`%s` = %s", $key, $this->getColumn($key)->sqlVal($value));
			}
		}
		foreach ($order as $key=>$value){
			$orderBy[] = sprintf("`%s` %s", $key, $value);
		}
		if (count($where)>0){
			$sWhere = " WHERE ".implode(' and ', $where);
		}else{
			$sWhere = "";
		}
		if (count($orderBy)>0){
			$sOrder = " ORDER BY ".implode(',', $orderBy);
		}else{
			$sOrder = "";
		}
		$sSql = sprintf("SELECT * FROM `%s` %s %s LIMIT 0,1", $this->getTableName(), $sWhere, $sOrder);
		$rows = $this->model->getRecords($sSql);
		if (count($rows)>0){
			return $this->fromRowToModelRow($rows[0]);
		}else{
			//return NULL;
			throw new \Exception("Registro no localizado");
		}
	}
2075
public function tableExists( $table )
    {
        $query = "SELECT COUNT(*) AS count FROM information_schema.tables
                  WHERE table_schema = ? AND table_name = ?";

        $params = [ $this->name, $table ];

        $statement = $this->database->prepare( $query );
        $statement->execute( $params );

        $results = $statement->fetchAll();

        return ( 0 < ( int ) $results[ 0 ][ 'count' ] );
    }
778057
protected function count_while_true( $condition ) {
		$count = 0;

		foreach ( $this->elements as $element ) {
			if ( ! $condition($element) ) {
				break;
			}
			$count++;
		}

		return $count;
	}
33446
function OuterJoin(Table $table, Condition $condition, $prepend = false)
    {
        return $this->Join($table, JoinType::Outer(), $condition, $prepend);
    }