/** * @return Constraint[] */ public function getConstraints() { if (!isset($this->constraints)) { $driver_class = $this->database->getConnection()->getDriverClass(); $this->constraints = $driver_class::getConstraints($this); } return $this->constraints; }
public function fetchRowCount() { if ($this->paginate === false) { throw new \Wave\Exception('Wave\\DB::fetchRowCount can only be used when paginating'); } $sql = 'SELECT FOUND_ROWS() AS row_count;'; $statement = $this->database->getConnection()->prepare($sql); $statement->execute(); $rslt = $statement->fetch(Connection::FETCH_ASSOC); return $rslt['row_count']; }
public static function getTables(DB $database) { $table_sql = 'SELECT TABLE_NAME, ENGINE, TABLE_COLLATION, TABLE_COMMENT ' . 'FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = ?;'; $table_stmt = $database->getConnection()->prepare($table_sql); $table_stmt->execute(array($database->getName())); $tables = array(); while ($table_row = $table_stmt->fetch()) { $table = new DB\Table($database, $table_row['TABLE_NAME'], $table_row['ENGINE'], $table_row['TABLE_COLLATION'], $table_row['TABLE_COMMENT']); $tables[$table_row['TABLE_NAME']] = $table; } return $tables; }
public static function getTables(DB $database) { $table_sql = 'SELECT "table_name", "table_type" FROM "information_schema"."tables" WHERE "table_schema" = ?'; $table_stmt = $database->getConnection()->prepare($table_sql); $table_stmt->execute(array($database->getSchema())); $tables = array(); while ($table_row = $table_stmt->fetch()) { $table = new DB\Table($database, $table_row['table_name']); $tables[$table_row['table_name']] = $table; } return $tables; }