public static function getRowsCount($table, $condition = array()) { Trace::addMessage(__CLASS__, sprintf('getRowsCount. Table:"%s", $condition:%s', $table, print_r($condition, true))); $result = parent::getRowsCount($table, $condition); Trace::addMessage(__CLASS__, 'Rows counting finished'); return $result; }
public static function pack() { $count = DBSimple::getRowsCount(Record::tableName); if (self::IsLogTooBig($count)) { self::storeExtraRecords(); } }
public function testReSave() { $this->factoryColumn(self::Login); $this->column->setValue(['facebook' => self::UID]); $this->column->onUpdate(new \Extasy\ORM\QueryBuilder('select')); // $this->assertEquals(1, DBSimple::getRowsCount(SocialNetworks::UIDTable)); }
public function testGrant() { ACL::create('test/test2'); ACL::grant('test/test2', 'e1'); $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE)); $found = DBSimple::get(ACL_GRANT_TABLE, array('actionId' => 2)); $this->assertEquals('e1', $found['entity']); }
public function testAuditRecordCreated() { $fixture = DBSimple::getRowsCount(Record::tableName); // $api = new RestartServer(); $api->exec(); // $this->assertEquals($fixture + 1, DBSimple::getRowsCount(Record::tableName)); }
public function testNewTasksNotRestarted() { $job = new TestAction(); $job->insert(); // $api = new Restart(['id' => $job->id->getValue(), 'actionDate' => '']); $api->exec(); // $this->assertEquals(1, DBSimple::getRowsCount(TestAction::TableName)); }
public function testDeleteAndCheckEntityDeletion() { ACL::create('test/test2/test3'); ACL::grant('test/test2/test3', 'o1'); ACL::grant('test', 'o2'); ACL::remove('test/test2'); $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE)); // Проверяем, что удалились именно нужные данные $this->assertEquals(true, ACL::isGranted('test', 'o2')); }
public function testGarbageCollection() { $job = new TestAction(); $job->status = Job::FinishedStatus; $job->actionDate = date('Y-m-d H:i:s', strtotime('-1 day')); $job->insert(); $this->assertEquals(1, DBSimple::getRowsCount(Job::TableName)); $runner = new Runner(); $runner->resolveJobs(); $this->assertEquals(0, DBSimple::getRowsCount(Job::TableName)); }
/** * */ public function testRemoveEntity() { ACL::create('test'); ACL::create('test2'); ACL::create('test3'); ACL::grant('test', 'obj1'); ACL::grant('test2', 'obj2'); ACL::grant('test3', 'obj1'); ACL::removeEntity('obj1'); $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE)); $this->assertEquals(true, ACL::isGranted('test2', 'obj2')); }
protected function loadLastFail() { $lastId = !empty($this->successId) ? $this->successId : 0; $condition = array('user_id' => $this->user->id->getValue(), 'status' => LoginAttempt::FailStatus, sprintf('`id` > "%d"', DB::escape($lastId)), sprintf('`date` < NOW() ')); $this->failCount = DBSimple::getRowsCount(LoginAttempt::TableName, $condition); $last = DBSimple::get(LoginAttempt::TableName, $condition, 'order by `id` desc'); if (!empty($last)) { $model = new LoginAttempt($last); $this->failLastIp = $model->host->getValue(); $this->failLastDate = $model->date->getValue(); } }
public function testRecordNotAddedInEnableLoggingDisabled() { $initial = DBSimple::getRowsCount(Record::tableName); // $log = Log::getByName('Log1'); $log->setupLogging(false); // $result = Record::add('Log1', '1', '2'); $this->assertTrue(empty($result)); // $result = DBSimple::getRowsCount(Record::tableName); $this->AssertEquals($initial, $result); }
protected function getRowsCount() { return DBSimple::getRowsCount(SYSTEMREGISTER_TABLE); }
protected function getRowsCount() { return DBSimple::getRowsCount(ACL_TABLE); }
protected function isUniq($login) { $count = DBSimple::getRowsCount(USERS_TABLE, array('login' => $login, sprintf('id <> %d', $this->document->id->getValue()))); return $count == 0; }
protected function getItemTitle($row) { $pageTitle = sprintf('<a class="itemTitle" href="./%s?parent=%d">%s</a>', $this->getPageUrl(), $row['id'], $row['name']); if (empty($row['visible'])) { $pageTitle .= ' <span class="important">[Скрыта]</span>'; } $count = \Faid\DBSimple::getRowsCount(SITEMAP_TABLE, ['parent' => $row['id']]); if (!empty($count)) { $pageTitle .= sprintf('<span>, имеет %d %s %s</span>', $count, IntegerHelper::formatWord($count, 'дочерни', array('й', 'х', 'х')), IntegerHelper::formatWord($count, 'документ', array('', 'а', 'ов'))); } if (!empty($row['document_name'])) { $pageTitle = $this->userFilterDescription($row, $pageTitle); } return $pageTitle; }
public static function getNewCount() { return DBSimple::getRowsCount(Record::tableName, array('viewed' => 0)); }
protected function getViewedCount() { return DBSimple::getRowsCount(Record::tableName, array('viewed' => '1')); }
/** * */ public static function testLoginAttempts() { self::reloadAttemptsConfig(); // $host = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'; // Check that per-host limit not exceeded $perHostAttempts = 1 + DBSimple::getRowsCount(self::LoginAttemptsTable, array('host' => ip2long($host), 'date > NOW() - INTERVAL 1 hour')); // Check that per-session limit not exceeded if (empty($_SESSION[self::LogSessionKey])) { $_SESSION[self::LogSessionKey] = 1; } else { $_SESSION[self::LogSessionKey]++; } $perSessionAttempts = $_SESSION[self::LogSessionKey]; if ($perHostAttempts > self::$perHost) { $error = sprintf('Per host login/forgot password attempts exceeded. Current host count: %d, limit: %d ', $perHostAttempts, self::$perHost); throw new LoginAttemptsException($error); } // if ($perSessionAttempts > self::$perSession) { throw new LoginAttemptsException(sprintf('Per session login/forgot password attempts exceeded %d:%d', $perSessionAttempts, self::$perSession)); } }