本文整理汇总了PHP中Mysql::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::getInstance方法的具体用法?PHP Mysql::getInstance怎么用?PHP Mysql::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mysql
的用法示例。
在下文中一共展示了Mysql::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_answered
function is_answered($task_id)
{
$uid = (int) $_SESSION['uid'];
$sql = "select * from moderators_history where task_id={$task_id} && to_usr!=from_usr order by id desc limit 0,1;";
$from_usr = Mysql::getInstance()->query($sql)->first('from_usr');
return $from_usr == $uid;
}
示例2: __construct
public function __construct()
{
$this->mysqlInstance = \Mysql::getInstance();
$this->reseller_id = NULL;
$this->admin_id = NULL;
$this->admin_login = NULL;
}
示例3: check
public function check($page, $action = 'view')
{
if ($this->admin->getLogin() == 'admin') {
return true;
}
return (bool) Mysql::getInstance()->from('acl')->where(array('gid' => $this->admin->getGID(), 'page' => $page, 'acl.' . $action => 1))->get()->first();
}
示例4: getInstance
public static function getInstance($id = false)
{
if (!$id) {
foreach (self::$connectionData as $k => $v) {
$idC = $k;
break;
}
} else {
$idC = $id;
}
$connection = Model::getConnectionData($idC);
$database = NULL;
// Debug::print_r("getInstance $id ", $connection);
if (Run::MYSQL === true && $connection['type_db'] == "mysql") {
$database = Mysql::getInstance($id);
if ($id) {
Mysql::setActive($id);
}
self::$query = new MysqlQuery($id);
return $database;
} else {
if (Run::POSTGRE === true && $connection['type_db'] == "postgre") {
$database = Postgre::getInstance($id);
if ($id) {
Postgre::setActive($id);
}
self::$query = new PostgreQuery($id);
return $database;
} else {
return false;
}
}
}
示例5: delete
public function delete(RESTApiRequest $request, $parent_id)
{
$user = \Mysql::getInstance()->from('users')->where(array('id' => $parent_id))->get()->first();
if (!empty($user['now_playing_link_id'])) {
switch ($user['now_playing_type']) {
case 1:
// tv
if (time() - strtotime($user['now_playing_start']) > 30 * 60) {
// more then 30 min
\Mysql::getInstance()->insert('played_itv', array('itv_id' => $user['now_playing_link_id'], 'uid' => $parent_id, 'playtime' => 'NOW()', 'user_locale' => $user['locale']));
}
break;
case 2:
// video
if (time() - strtotime($user['now_playing_start']) > 60 * 60) {
// more then 1 hour (70% can't be counted)
\Mysql::getInstance()->insert('played_video', array('video_id' => $user['now_playing_link_id'], 'uid' => $parent_id, 'playtime' => 'NOW()'));
}
break;
case 11:
// tvarchive
if (time() - strtotime($user['now_playing_start']) > 60) {
// more then 1 min
$program = \Mysql::getInstance()->from('epg')->where(array('id' => $user['now_playing_link_id']))->get()->first();
if (!empty($program)) {
\Mysql::getInstance()->insert('played_tv_archive', array('ch_id' => $program['ch_id'], 'uid' => $parent_id, 'playtime' => 'NOW()', 'length' => time() - strtotime($user['now_playing_start'])));
}
}
break;
}
}
return \Mysql::getInstance()->update('users', array('now_playing_type' => '', 'now_playing_content' => '', 'last_active' => 'NOW()'), array('id' => $parent_id))->result();
}
示例6: set_karaoke_returned
function set_karaoke_returned($id, $val, $txt)
{
if (!$id) {
return;
}
Mysql::getInstance()->update('karaoke', array('returned' => $val, 'reason' => $txt, 'done' => intval(!$val)), array('id' => $id));
}
示例7: get_users_count_in_tariff
function get_users_count_in_tariff($tariff)
{
$tariff_ids = array($tariff['id']);
if ($tariff['user_default'] == 1) {
$tariff_ids[] = 0;
}
return Mysql::getInstance()->from('users')->count()->in('tariff_plan_id', $tariff_ids)->get()->counter();
}
示例8: MysqlQuery
function MysqlQuery($id)
{
$this->query_string = "";
$this->_line = __LINE__;
$this->_function = __FUNCTION__;
$this->_class = __CLASS__;
$this->_file = __FILE__;
$this->mysql = Mysql::getInstance($id);
}
示例9: executeSql
public function executeSql($file)
{
$fileInfo = file_get_contents($file);
$sql = $this->parseSql($fileInfo);
unset($fileInfo);
$mysql = Mysql::getInstance();
foreach ($sql as $s) {
$mysql->execute($s);
}
}
示例10: filter
private function filter($profile)
{
if (empty($profile)) {
throw new RESTNotFound("User not found");
}
$profile = array_intersect_key($profile, $this->fields_map);
$themes = \Middleware::getThemes();
$profile['theme'] = empty($profile['theme']) || !array_key_exists($profile['theme'], $themes) ? \Mysql::getInstance()->from('settings')->get()->first('default_template') : $profile['theme'];
$profile['themes'] = $themes;
return $profile;
}
示例11: __construct
public function __construct()
{
$this->db = Mysql::getInstance();
$this->xml_url = $this->xml_url . '?' . time();
$this->weekday_arr = array('', _('Sun'), _('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'));
$this->tod_arr = array(_('Night'), _('Morning'), _('Day'), _('Evening'));
$this->month_arr = array('', _('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec'));
$this->cloudiness_arr = array(_('clear'), _('partly cloudy'), _('cloudy'), _('overcast'));
$this->precipitation_arr = array('', '', '', '', _('rain'), _('rainfall'), _('snow'), _('snow'), _('thunderstorm'), _('no data'), _('w/o precipitation'));
$this->direction_arr = array('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW');
}
示例12: update
public function update(RESTRequest $request)
{
$stb_list = $request->getConvertedIdentifiers();
if (empty($stb_list)) {
throw new RESTCommandException('Empty stb list');
}
foreach ($stb_list as $uid) {
Mysql::getInstance()->update('users', array('access_token' => strtoupper(md5(microtime(1) . uniqid()))), array('id' => $uid));
Mysql::getInstance()->update('access_tokens', array('token' => 'invalid_' . md5(microtime(1) . uniqid()), 'refresh_token' => 'invalid_' . md5(microtime(1) . uniqid())), array('uid' => $uid));
}
return true;
}
示例13: setOff
public function setOff()
{
$this->checkIfInitialized();
if ($this->storage['status'] == 0) {
return true;
}
$result = Mysql::getInstance()->update('storages', array('status' => 0), array('id' => $this->storage['id']));
if ($result) {
Mysql::getInstance()->insert('master_log', array('log_txt' => "Storage " . $this->storage['storage_name'] . " has been disabled after " . $this->max_failures . " failures in " . $this->stat_period . "s", 'added' => 'NOW()'));
}
return $result;
}
示例14: getCollectionByAttribute
public function getCollectionByAttribute($attribute, $like)
{
$bdd = Mysql::getInstance();
$select = 'SELECT id FROM chauffeurs where ' . $attribute . ' LIKE "%' . $like . '%"';
$req = $bdd->prepare($select);
$req->execute();
$chauffeurs = array();
foreach ($req->fetchAll() as $row) {
$chauffeur = new Chauffeurs();
$chauffeur->load($row["id"]);
$chauffeurs[] = $chauffeur;
}
return $chauffeurs;
}
示例15: writePackageSubscribeLog
public static function writePackageSubscribeLog($user_id, $package_id, $set_state)
{
$data = array('user_id' => $user_id, 'set_state' => $set_state, 'package_id' => $package_id);
if (!empty(Stb::getInstance()->id) && (empty($_SERVER['TARGET']) || $_SERVER['TARGET'] !== 'API' && $_SERVER['TARGET'] !== 'ADM')) {
$data['initiator_id'] = Stb::getInstance()->id;
$data['initiator'] = 'user';
} else {
$data['initiator_id'] = Admin::getInstance()->getId();
if (!empty($data['initiator_id'])) {
$data['initiator'] = 'admin';
}
}
Mysql::getInstance()->insert('package_subscribe_log', $data);
}