本文整理汇总了PHP中Sql::pSelectItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::pSelectItem方法的具体用法?PHP Sql::pSelectItem怎么用?PHP Sql::pSelectItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql::pSelectItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isReservedUsername
public static function isReservedUsername($s)
{
$s = trim($s);
$q = 'SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE type = ?' . ' AND value = ?';
$val = Sql::pSelectItem($q, 'is', RESERVED_USERNAME, $s);
if ($val) {
return true;
}
return false;
}
示例2: addToGroup
/** Adds the user to a user group */
public static function addToGroup($user_id, $grp_id)
{
$q = 'SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE groupId = ? AND userId = ?';
if (Sql::pSelectItem($q, 'ii', $grp_id, $user_id)) {
return true;
}
$q = 'INSERT INTO ' . self::$tbl_name . ' SET groupId = ?, userId = ?';
Sql::pInsert($q, 'ii', $grp_id, $user_id);
return true;
}
示例3: hasAnswered
/** Has current user rated item/answered poll? */
static function hasAnswered($type, $id)
{
$session = SessionHandler::getInstance();
if (!$session->id) {
return true;
}
$q = 'SELECT owner FROM ' . self::$tbl_name . ' WHERE type = ? AND userId = ? AND owner = ?';
if (Sql::pSelectItem($q, 'iii', $type, $session->id, $id)) {
return true;
}
return false;
}
示例4: store
public function store()
{
$q = 'SELECT id FROM ' . self::$tbl_name . ' WHERE owner = ? AND season = ? AND episode = ?';
$this->id = Sql::pSelectItem($q, 'iii', $this->owner, $this->season, $this->episode);
if ($this->id) {
$q = 'UPDATE ' . self::$tbl_name . ' SET owner = ?, title = ?, date = ?, info = ?, season = ?, episode = ?, link = ? WHERE id = ?';
Sql::pUpdate($q, 'isssiisi', $this->owner, $this->title, $this->date, $this->info, $this->season, $this->episode, $this->link, $this->id);
return $this->id;
}
$q = 'INSERT INTO ' . self::$tbl_name . ' SET owner = ?, title = ?, date = ?, info = ?, season = ?, episode = ?, link = ?';
return Sql::pInsert($q, 'isssiis', $this->owner, $this->title, $this->date, $this->info, $this->season, $this->episode, $this->link);
}
示例5: getUnreadCount
/** @return number of unread messages in the Inbox */
public static function getUnreadCount($user_id)
{
$q = 'SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE `to` = ? AND time_read IS NULL' . ' ORDER BY time_sent DESC';
return Sql::pSelectItem($q, 'i', $user_id);
}
示例6: foreach
$q = 'SHOW GRANTS FOR CURRENT_USER';
$priv = Sql::pSelect($q);
// ex: GRANT USAGE ON *.* TO 'savak'@'%' IDENTIFIED BY PASSWORD '*0...
// ex: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*xxx'
// ex: GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*xxx' WITH GRANT OPTION
/// XXXXX FIXME: censor password from string instead of cut it!!!!
//d($priv);
echo '<h2>Privileges</h2>';
foreach ($priv as $p) {
$key = key($p);
$val = current($p);
echo $key . ': <b>' . substr($val, 0, 60) . '</b>...<br/>';
}
echo '<br/>';
echo '<h2>Time</h2>';
$db_time = Sql::pSelectItem('SELECT NOW()');
echo 'Database time: ' . $db_time . '<br/>';
echo 'Webserver time: ' . now() . '<br/>';
$uptime = Sql::pSelectRow('SHOW STATUS WHERE Variable_name = ?', 's', 'Uptime');
echo 'Database uptime: <b>' . elapsed_seconds($uptime['Value']) . '</b><br/>';
echo '<br/>';
echo '<h2>Character sets</h2>';
$charsets = Sql::pSelectMapped('SHOW VARIABLES LIKE "%character_set%"');
foreach ($charsets as $ch_name => $val) {
echo $ch_name . ' = ';
if (!in_array($val, array('utf8'))) {
echo '<font color="red">' . $val . '</font>';
} else {
echo $val;
}
echo '<br/>';
示例7: getStatusByReference
public static function getStatusByReference($type, $reference)
{
$q = 'SELECT approved FROM ' . self::$tbl_name . ' WHERE type = ? AND reference = ?';
return Sql::pSelectItem($q, 'ii', $type, $reference);
}
示例8: isLiked
public static function isLiked($owner, $type, $user_id)
{
$q = 'SELECT id FROM ' . self::$tbl_name . ' WHERE owner = ? AND type = ? AND user = ?';
$id = Sql::pSelectItem($q, 'iii', $owner, $type, $user_id);
return $id ? true : false;
}
示例9: getName
public static function getName($id)
{
$q = 'SELECT name FROM ' . self::$tbl_name . ' WHERE id = ?' . ' AND time_deleted IS NULL';
return Sql::pSelectItem($q, 'i', $id);
}
示例10: getUnseenCount
public static function getUnseenCount($to)
{
$q = 'SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE `to` = ?';
return Sql::pSelectItem($q, 'i', $to);
}
示例11: read
public function read($id)
{
$q = 'SELECT session_data FROM tblSessionData WHERE session_id = ? AND expires > ?';
return Sql::pSelectItem($q, 'ss', $id, sql_datetime(time()));
}
示例12: save
function save()
{
$session = SessionHandler::getInstance();
if (!$this->id) {
$q = 'SELECT groupId FROM tblUserGroups WHERE name = ?';
$this->id = Sql::pSelectItem($q, 's', $this->name);
}
if ($this->id) {
$q = 'UPDATE tblUserGroups SET name = ?, info = ?, level = ? WHERE groupId = ?';
Sql::pUpdate($q, 'ssii', $this->name, $this->info, $this->level, $this->id);
} else {
$q = 'INSERT INTO tblUserGroups SET createdBy = ?, timeCreated = NOW(), name = ?, info = ?, level = ?';
$this->id = Sql::pInsert($q, 'issi', $session->id, $this->name, $this->info, $this->level);
}
return $this->id;
}
示例13: exists
/**
* Compares the object:s set properties to table columns
* @return true if object exists
**/
public static function exists($obj, $tblname)
{
if (!is_alphanumeric($tblname)) {
throw new \Exception('very bad');
}
$reflect = self::reflectQuery($obj, '', false);
$q = 'SELECT COUNT(*) FROM ' . $tblname . ' WHERE ' . implode(' AND ', $reflect->cols);
return Sql::pSelectItem($q, $reflect->str, $reflect->vals) ? true : false;
}
示例14: SubjectExists
public static function SubjectExists($type, $subject)
{
$q = 'SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE type = ? AND subject = ?';
$cnt = Sql::pSelectItem($q, 'is', $type, $subject);
return $cnt ? true : false;
}
示例15: getCount
public static function getCount($type, $owner)
{
$q = 'SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE type = ? AND owner = ?';
return Sql::pSelectItem($q, 'ii', $type, $owner);
}