connect_error) { throw new \Exception('Connect Error ' . $mysqli->connect_error , $mysqli->connect_errno); } $mysqli->set_charset('utf8'); return $mysqli; } /** * 指定默认的数据表名(不含前缀) * @access public * @param string $name * @return $this */ public function name($name) { $this->name = $name; return $this; } /** * 指定默认数据表名(含前缀) * @access public * @param string $table 表名 * @return $this */ public function setTable($table) { $this->table = $table; return $this; } /** * 得到当前或者指定名称的数据表 * @access public * @param string $name * @return string */ public function getTable($name = '') { if ($name || empty($this->table)) { $name = $name ?: $this->name; $tableName = $this->prefix; if ($name) { $tableName .= $name; } } else { $tableName = $this->table; } return $tableName; } }