/** * @expectedException FailedAssertionException */ public function testGetDatabaseNameFromConnectionString() { $dsn = 'mysql:host=localhost;port=3306;dbname=zurmo'; // Not Coding Standard $databaseName = RedBeanDatabase::getDatabaseNameFromDsnString($dsn); $this->assertEquals('zurmo', $databaseName); $dsn = 'mysql:host=localhost;'; // Not Coding Standard $databaseName = RedBeanDatabase::getDatabaseNameFromDsnString($dsn); }
public function testGetDatabaseNameFromConnectionString() { $dsn = 'mysql:host=localhost;port=3306;dbname=zurmo'; // Not Coding Standard $databaseName = RedBeanDatabase::getDatabaseNameFromDsnString($dsn); $this->assertEquals('zurmo', $databaseName); $dsn = 'mysql:host=localhost;'; // Not Coding Standard try { $databaseName = RedBeanDatabase::getDatabaseNameFromDsnString($dsn); $this->fail(); } catch (NotSupportedException $e) { } catch (FailedAssertionException $e) { } }
public static function getTableRowsCountTotal() { if (RedBeanDatabase::getDatabaseType() != 'mysql') { throw new NotSupportedException(); } $databaseName = RedBeanDatabase::getDatabaseNameFromDsnString(Yii::app()->db->connectionString); $sql = "show tables"; $totalCount = 0; $rows = R::getAll($sql); $columnName = 'Tables_in_' . $databaseName; foreach ($rows as $row) { $tableName = $row[$columnName]; $tableSql = "select count(*) count from " . $tableName; $row = R::getRow($tableSql); $totalCount = $totalCount + $row['count']; } return $totalCount; }