public static function get($table, $condition, $order = '') { Trace::addMessage(__CLASS__, sprintf('Get from table:"%s" with condition:"%s" and order:"%s"', $table, print_r($condition, true), $order)); $result = parent::get($table, $condition, $order); Trace::addMessage(__CLASS__, sprintf('Getting from "%s" finished', $table)); return $result; }
public function getLastJob() { $jobData = DBSimple::get(Job::TableName, array('status' => Job::NewStatus, 'actionDate <= NOW() '), 'order by `id` asc'); if (!empty($jobData)) { return Job::factory($jobData); } }
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 static function factoryById($id) { $found = DBSimple::get(self::TableName, array('id' => intval($id))); if (empty($found)) { throw new \NotFoundException('Job not found'); } return self::factory($found); }
public function testCreateWithCheckValues() { ACL::create('test/test2'); $result = DBSimple::get(ACL_TABLE, array('id' => 1)); $this->assertEquals('test', $result['name']); $result = DBSimple::get(ACL_TABLE, array('id' => 2)); $this->assertEquals('test2', $result['name']); }
public static function getLast() { $found = DBSimple::get(\EmailLogModel::getTableName(), '', 'order by id desc'); if (empty($found)) { throw new \NotFoundException('Last log message not found. Log table empty'); } $log = new \EmailLogModel($found); return $log; }
public static function getByName($name) { $found = DBSimple::get(Log::tableName, array('name' => $name)); if (empty($found)) { throw new \NotFoundException('Log record not found'); } $result = new Log($found); return $result; }
public static function getByName($name) { $found = DBSimple::get(self::TableName, array('name' => $name)); if (empty($found)) { throw new \NotFoundException('Unknown social network name - ' . $name); } $result = new Network($found); return $result; }
/** * Возвращает информацию о скрипте на основании его файла и пути для редактирования в админке */ public static function getScriptByAdminInfo($szPath, $szAdminUrl = '') { $szPath = \Faid\DB::escape($szPath); $szAdminUrl = \Faid\DB::escape($szAdminUrl); $condition = array(sprintf('STRCMP(`script`,"%s") = 0', $szPath)); if (!empty($szAdminUrl)) { $condition[] = sprintf('STRCMP(`script_admin_url`,"%s") = 0', $szAdminUrl); } return DBSimple::get(SITEMAP_TABLE, $condition); }
public function testFactoryMethod() { $job = new TestAction(); $job->insert(); // $row = DBSimple::get(TestAction::TableName, array('id' => $job->id->getValue())); $newJob = Job::factory($row); // $this->AssertEquals(get_class($job), get_class($newJob)); }
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 testDeleteModel() { $model = new testModel(); $model->get(1); $model->delete(); // $model = new testModel(); $result = $model->get(1); // $this->assertEquals($result, false); // $result = DBSimple::get(testModel::TableName, array('id' => 1)); // $this->assertEquals($result, null); }
public function update($group, $permissions) { if (empty($group)) { $this->AddAlert('Группа пользователей не выбрана'); $this->jump('./'); } set_time_limit(0); $page = 0; $groupInfo = DBSimple::get(ACL_TABLE, ['name' => $group]); if (empty($groupInfo)) { throw new \InvalidArgumentException(sprintf('Group "%s" not found, failed to update group permissions', htmlspecialchars($group))); } $permissions = $this->filterPermissionsByGroup($group, $permissions); do { // получаем пользователей $sql = <<<SQL \tselect u.* from %s as u \tinner join %s as r \ton r.entity = concat("%s", u.id) \twhere r.actionId = "%s" \torder by id asc \tlimit %d,%d SQL; $sql = sprintf($sql, \UserAccount::getTableName(), \ACL_GRANT_TABLE, \Faid\DB::escape(\UserAccount::ModelName), $groupInfo['id'], $page * self::Limit, self::Limit); $data = DB::query($sql); // устанавливаем каждому права foreach ($data as $row) { $user = new \UserAccount($row); $tmp = $user->rights->getValue(); $tmp = array_merge($tmp, $permissions); $user->rights = $tmp; $user->update(); } $page++; } while (sizeof($data) != 0); $this->addAlert('Права обновлены'); $this->jump('./'); }
/** * * @param unknown $url */ public static function exists($url) { $found = DBSimple::get(self::getTableName(), array('url' => $url)); return !empty($found); }
public static function activateEmail($code) { $found = DBSimple::get(self::getTableName(), array('email_confirmation_code' => $code)); if (empty($found)) { throw new NotFoundException('Confirmation code not found '); } $result = new UserAccount($found); $result->email->setValue($result->new_email->getValue()); $result->new_email->setValue(''); $result->email_confirmation_code->setValue(''); $result->update(); return $result; }
public static function getByUID($uid, $network) { $network = Network::getByName($network); $found = DBSimple::get(self::UIDTable, ['uid' => $uid, 'network_id' => $network->id->getValue()]); if (empty($found)) { throw new SocialNetworksException('UID not found'); } $user = \UserAccount::getById($found['user_id']); return $user; }
public static function findByEmail($email) { $result = DBSimple::get(UserAccount::getTableName(), array(sprintf('`email` = "%s" ', DB::escape($email), DB::escape($email)))); return $result; }
protected function searchInHistory($url) { $found = DBSimple::get(SITEMAP_HISTORY_TABLE, array('url' => $url)); if (!empty($found)) { return \Sitemap_Sample::get($found['page_id']); } return null; }
protected static function get($path) { // Разрезаем путь $pathList = self::getPath($path); // Получаем элемент пути $condition = array('fullPath' => $path); $data = DBSimple::get(ACL_TABLE, $condition); if (empty($data)) { throw new ACLException('Path "' . $path . '" not found'); } return $data; }