for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Soluble\Schema\Source\Mysql;
use Soluble\Schema\Db\Wrapper\MysqlConnectionAdapter;
abstract class AbstractMysqlDriver
{
/**
*
* @param MysqlConnectionAdapter $adapter
* @param strinbg $schema database name
*/
public function __construct(MysqlConnectionAdapter $adapter, $schema)
$this->adapter = $adapter;
adapter
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->schema = $schema;
schema
}
* Disable innodbstats will increase speed of metadata lookups
* @return void
protected function disableInnoDbStats()
$sql = "show global variables like 'innodb_stats_on_metadata'";
try {
$results = $this->adapter->query($sql);
if (count($results) > 0) {
$row = $results->offsetGet(0);
$value = strtoupper($row['Value']);
// if 'on' no need to do anything
if ($value != 'OFF') {
$this->mysql_innodbstats_value = $value;
mysql_innodbstats_value
// disabling innodb_stats
$this->adapter->execute("set global innodb_stats_on_metadata='OFF'");
} catch (\Exception $e) {
// do nothing, silently fallback
* Restore old innodbstats variable
protected function restoreInnoDbStats()
$value = $this->mysql_innodbstats_value;
if ($value !== null) {
// restoring old variable
$this->adapter->execute("set global innodb_stats_on_metadata='$value'");
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: