system/Database/Forge.php
public function createTable(string $table, bool $if_not_exists = false, array $attributes = [])
	{
		if ($table === '')
		{
			throw new \InvalidArgumentException('A table name is required for that operation.');
		}

		$table = $this->db->DBPrefix . $table;

		if (count($this->fields) === 0)
		{
			throw new \RuntimeException('Field information is required.');
		}

		$sql = $this->_createTable($table, $if_not_exists, $attributes);

		if (is_bool($sql))
		{
			$this->reset();
			if ($sql === false)
			{
				if ($this->db->DBDebug)
				{
					throw new DatabaseException('This feature is not available for the database you are using.');
				}

				return false;
			}
		}

		if (($result = $this->db->query($sql)) !== false)
		{
			empty($this->db->dataCache['table_names']) || ($this->db->dataCache['table_names'][] = $table);

			// Most databases don't support creating indexes from within the CREATE TABLE statement
			if (! empty($this->keys))
			{
				for ($i = 0, $sqls = $this->_processIndexes($table), $c = count($sqls); $i < $c; $i++)
				{
					$this->db->query($sqls[$i]);
				}
			}
		}

		$this->reset();

		return $result;
	}
public function createTable(string $table, bool $if_not_exists = false, array $attributes = [])
	{
		if ($table === '')
		{
			throw new \InvalidArgumentException('A table name is required for that operation.');
		}

		$table = $this->db->DBPrefix . $table;

		if (count($this->fields) === 0)
		{
			throw new \RuntimeException('Field information is required.');
		}

		$sql = $this->_createTable($table, $if_not_exists, $attributes);

		if (is_bool($sql))
		{
			$this->reset();
			if ($sql === false)
			{
				if ($this->db->DBDebug)
				{
					throw new DatabaseException('This feature is not available for the database you are using.');
				}

				return false;
			}
		}

		if (($result = $this->db->query($sql)) !== false)
		{
			empty($this->db->dataCache['table_names']) || ($this->db->dataCache['table_names'][] = $table);

			// Most databases don't support creating indexes from within the CREATE TABLE statement
			if (! empty($this->keys))
			{
				for ($i = 0, $sqls = $this->_processIndexes($table), $c = count($sqls); $i < $c; $i++)
				{
					$this->db->query($sqls[$i]);
				}
			}
		}

		$this->reset();

		return $result;
	}
Create Table

@param string  $table         Table name
@param boolean $if_not_exists Whether to add IF NOT EXISTS condition
@param array   $attributes    Associative array of table attributes

@return mixed
@throws \CodeIgniter\Database\Exceptions\DatabaseException