Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Counts all elements in an array or in a Countable object
<?php count(Countable|array $value, int $mode = COUNT_NORMAL): int
<?php public function __construct(array $data)
{
$this->data = $data;
if (count($data) === 0) {
return;
}
<?php return;
}
$this->columnCount = count($data[0]);
}
<?php public function rowCount(): int
{
return count($this->data);
}
public function columnCount(): int
<?php public function delete($table, array $criteria, array $types = [])
{
if (count($criteria) === 0) {
throw InvalidArgumentException::fromEmptyCriteria();
}
<?php public function insert($table, array $data, array $types = [])
{
if (count($data) === 0) {
return $this->executeStatement('INSERT INTO ' . $table . ' () VALUES ()');
}
<?php }
try {
if (count($params) > 0) {
if ($this->needsArrayParameterConversion($params, $types)) {
[$sql, $params, $types] = $this->expandArrayParameters($sql, $params, $types);
}
<?php }
$stmt = $connection->prepare($sql);
if (count($types) > 0) {
$this->_bindTypedValues($stmt, $params, $types);
$result = $stmt->execute();
} else {
<?php }
try {
if (count($params) > 0) {
if ($this->needsArrayParameterConversion($params, $types)) {
[$sql, $params, $types] = $this->expandArrayParameters($sql, $params, $types);
}
<?php $stmt = $connection->prepare($sql);
if (count($types) > 0) {
$this->_bindTypedValues($stmt, $params, $types);
$result = $stmt->execute();
<?php throw new InvalidArgumentException('primary or replica configuration missing');
}
if (count($params['replica']) === 0) {
throw new InvalidArgumentException('You have to configure at least one replica.');
}
<?php private function withOptions(array $initializers, array $options): array
{
if (count($options) !== 0) {
$initializers[] = new Options($options);
}
<?php $this->boundValues = array_fill(0, count($this->columnNames), null);
$refs = [];
foreach ($this->boundValues as &$value) {
<?php private function bindUntypedValues(array $values)
{
$params = [];
$types = str_repeat('s', count($values));
foreach ($values as &$v) {
$params[] =& $v;
<?php public function acceptPositionalParameter(string $sql): void
{
$position = count($this->parameterMap) + 1;
$param = ':param' . $position;
$this->parameterMap[$position] = $param;
<?php public function postConnect(ConnectionEventArgs $args)
{
if (count($this->_defaultSessionVars) === 0) {
return;
}