本文整理汇总了PHP中Sql::pSelectRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::pSelectRow方法的具体用法?PHP Sql::pSelectRow怎么用?PHP Sql::pSelectRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql::pSelectRow方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* @param $duration_mode "1d", "2w", "2m"
*/
static function add($type, $owner, $text, $duration_mode = '', $start_mode = '')
{
$length = parse_duration($duration_mode);
if (!$length) {
throw new \Exception('odd duration ' . $duration_mode);
}
switch ($start_mode) {
case 'thismonday':
$dayofweek = date('N');
$mon = date('n');
$day = date('j');
$timeStart = mktime(6, 0, 0, $mon, $day - $dayofweek + 1);
//06:00 Monday current week
break;
case 'nextmonday':
$dayofweek = date('N');
$mon = date('n');
$day = date('j');
$timeStart = mktime(6, 0, 0, $mon, $day - $dayofweek + 1 + 7);
//06:00 Monday next week
break;
case 'nextfree':
$q = 'SELECT time_end FROM tblPolls' . ' WHERE owner = ? AND deleted_by = ?' . ' ORDER BY time_start DESC' . ' LIMIT 1';
$data = Sql::pSelectRow($q, 'ii', $owner, 0);
$timeStart = $data ? ts($data['timeEnd']) : time();
break;
default:
throw new \Exception('eexp');
}
$timeEnd = $timeStart + $length;
return self::addPollExactPeriod($type, $owner, $text, $timeStart, $timeEnd);
}
示例2: get
public static function get($type, $owner, $name, $default = '')
{
$q = 'SELECT value FROM ' . self::$tbl_name . ' WHERE owner = ? AND type = ? AND name = ?';
$res = Sql::pSelectRow($q, 'iis', $owner, $type, $name);
if ($res) {
return $res['value'];
}
return $default;
}
示例3: foreach
// 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/>';
}
$collations = Sql::pSelectMapped('SHOW VARIABLES LIKE "%collation%"');
foreach ($collations as $ch_name => $val) {
示例4: getByReference
public static function getByReference($type, $reference)
{
$q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ? AND reference = ?';
$row = Sql::pSelectRow($q, 'ii', $type, $reference);
return SqlObject::loadObject($row, __CLASS__);
}
示例5: getLatestByOwner
public static function getLatestByOwner($type, $owner)
{
$q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ? AND owner = ?' . ' ORDER BY time_saved DESC' . ' LIMIT 1';
$row = Sql::pSelectRow($q, 'ii', $type, $owner);
return SqlObject::loadObject($row, __CLASS__);
}
示例6: get
public static function get($id)
{
$q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE id = ?' . ' AND time_deleted IS NULL';
$row = Sql::pSelectRow($q, 'i', $id);
return SqlObject::loadObject($row, __CLASS__);
}
示例7: d
d($x);
$q = 'REPLACE tblSessionData (session_id,session_data,expires) VALUES(?, ?, ?)';
$xxx = Sql::pUpdate($q, 'sss', 666, "hejhej", sql_datetime( time() ) );
d($xxx);
$q = 'INSERT INTO tblLikes (owner,type) VALUES (?, ?)';
$id = Sql::pInsert($q, 'ii', 4,9);
if ($id < 2) echo "FAIL 5\n";
$w = new Word();
$w->id = 8;
$w->value = "sten";
if (SqlObject::exists($w, 'oWord') != true) echo "FAIL 10\n";
$w = new Word();
$w->id = 8;
$w->value = "st2en";
if (SqlObject::exists($w, 'oWord') == true) echo "FAIL 11\n";
*/
// TODO more reliable test of ListToObjects
$q = 'SELECT * FROM tblBookmarks' . ' WHERE owner = ? AND type = ?';
$list = Sql::pSelect($q, 'ii', 2, 100);
$objs = SqlObject::ListToObjects($list, 'Bookmark');
if (count($objs) < 5) {
echo "FAIL 20\n";
}
$q = 'SELECT * FROM tblBookmarks' . ' WHERE id = ?';
$row = Sql::pSelectRow($q, 'i', 66);
$obj = SqlObject::RowToObject($row, 'Bookmark');
if ($obj->id != 66) {
echo "FAIL 30\n";
}
$bb = Bookmark::get(66);
d($bb);
示例8: getByName
public static function getByName($s)
{
$q = 'SELECT * FROM tblUserGroups WHERE name = ?';
return Sql::pSelectRow($q, 's', $s);
}
示例9: getByOwner
public static function getByOwner($id)
{
$q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ?' . ' ORDER BY time_saved DESC' . ' LIMIT 1';
$res = Sql::pSelectRow($q, 'i', $id);
return SqlObject::loadObject($res, __CLASS__);
}