public static function getEntries($user_id) { if (!is_numeric($user_id)) { throw new \Exception('ehm'); } $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ?' . ' ORDER BY time_created DESC'; $list = Sql::pSelect($q, 'i', $user_id); return SqlObject::loadObjects($list, __CLASS__); }
public static function getByType($type) { if (!is_numeric($type)) { throw new \Exception('hmmm'); } $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ?' . ' ORDER BY time_created DESC'; $list = Sql::pSelect($q, 'i', $type); return SqlObject::ListToObjects($list, __CLASS__); }
public static function getList($type, $owner) { if (!is_numeric($owner) || !is_numeric($type)) { throw new \Exception('noo'); } $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ? AND type = ?'; $list = Sql::pSelect($q, 'ii', $owner, $type); return SqlObject::ListToObjects($list, __CLASS__); }
/** * @return list of most recent blogs (by publish time) */ public static function getRecent($count) { if (!is_numeric($count)) { return false; } $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE time_published IS NOT NULL' . ' ORDER BY time_published DESC' . ' LIMIT ' . $count; $list = Sql::pSelect($q); return SqlObject::loadObjects($list, __CLASS__); }
public static function getByCategory($type, $cat, $uploader = 0) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ?' . ' AND category = ?' . ($uploader ? ' AND uploader = ?' : '') . ' AND time_deleted IS NULL'; if ($uploader) { $list = Sql::pSelect($q, 'iii', $type, $cat, $uploader); } else { $list = Sql::pSelect($q, 'ii', $type, $cat); } return SqlObject::loadObjects($list, __CLASS__); }
public static function getAllBetween($time_start, $time_end) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE timeCreated BETWEEN "' . sql_datetime($time_start) . '" AND "' . sql_datetime($time_end) . '"' . ' ORDER BY timeCreated DESC'; return Sql::pSelect($q); }
/** @return all messages in the Outbox */ public static function getOutbox($user_id) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE `from` = ?' . ' ORDER BY time_sent DESC'; $list = Sql::pSelect($q, 'i', $user_id); return SqlObject::loadObjects($list, __CLASS__); }
/** * @return 2d array of all settings for owner */ public static function getAll($type, $owner) { $q = 'SELECT id, name, value, category' . ' FROM ' . self::$tbl_name . ' WHERE type = ? AND owner = ?'; return Sql::pSelect($q, 'ii', $type, $owner); }
$session->requireSuperAdmin(); echo '<h1>MySQL information</h1>'; echo 'Driver: <b>' . get_class($db) . '</b><br/>'; echo 'Server version: <b>' . $db->db_handle->server_info . '</b><br/>'; echo 'Client version: <b>' . $db->db_handle->client_info . '</b><br/>'; echo 'Host: <b>' . $db->host . ':' . $db->port . '</b><br/>'; echo 'Username: <b>' . $db->username . '</b><br/>'; // echo 'Password: '******'(blank)').'<br/>'; echo 'Database: <b>' . $db->database . '</b><br/>'; echo 'Configured charset: <b>' . $db->charset . '</b><br/>'; echo 'Connection charset: <b>' . $db->db_handle->character_set_name() . '</b><br/>'; echo 'Host info: <b>' . $db->db_handle->host_info . '</b><br/>'; echo '<br/>'; $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/>';
/** * @return all most recent coordinates for objects not owned by $exclude_owner */ public static function getOtherThan($type, $exclude_owner) { $q = 'SELECT MAX(time_saved) AS time_saved,id,owner,type,country,name,latitude,longitude,accuracy' . ' FROM ' . self::$tbl_name . ' WHERE type = ? AND owner != ?' . ' GROUP BY owner'; $list = Sql::pSelect($q, 'ii', COORD_EXACT, $exclude_owner); return SqlObject::loadObjects($list, __CLASS__); }
public static function getDenied() { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE time_handled IS NOT NULL AND approved = ?'; $list = Sql::pSelect($q, 'i', 0); return SqlObject::loadObjects($list, __CLASS__); }
public static function getRecent($room, $microtime, $limit) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE room = ? AND microtime > ?' . ' ORDER BY microtime DESC' . ' LIMIT ?'; $list = Sql::pSelect($q, 'idi', $room, $microtime, $limit); return SqlObject::loadObjects($list, __CLASS__); }
static function getActivePolls($type, $owner = 0) { $q = 'SELECT * FROM tblPolls' . ' WHERE type = ? AND owner = ? AND deleted_by = ? AND NOW() BETWEEN time_start AND time_end' . ' ORDER BY time_start ASC,text ASC'; $list = Sql::pSelect($q, 'iii', $type, $owner, 0); return SqlObject::loadObjects($list, __CLASS__); }
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);
public static function getAll($type) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ?' . ' ORDER BY value ASC'; $res = Sql::pSelect($q, 'i', $type); return SqlObject::loadObjects($res, __CLASS__); }
static function getAll() { $arr = array(); foreach (Sql::pSelect('SELECT * FROM tblUserGroups') as $row) { $item = new UserGroup(); $item->loadFromSql($row); $arr[] = $item; } return $arr; }
/** * Fetches all items where $field_name = $value * @param $field_name * @param $value * @param $tblname * @param $classname * @param $order_field * @param $order 'desc', 'asc' or empty */ public static function getAllByField($field_name, $value, $tblname, $classname, $order_field = '', $order = 'asc') { if (!is_alphanumeric($tblname)) { throw new \Exception('tblname should be alphanumeric, isnt: ' . $tblname); } if (!is_alphanumeric($field_name)) { throw new \Exception('field_name should be alphanumeric, isnt: ' . $field_name); } if (!is_alphanumeric($order_field)) { throw new \Exception('order_field should be alphanumeric, isnt: ' . $order_field); } if (!Sql::isValidOrder($order)) { throw new \Exception('odd order ' . $order); } $form = self::stringForm($value); $q = 'SELECT * FROM ' . $tblname . ' WHERE ' . $field_name . ' = ?' . ($order_field ? ' ORDER BY ' . $order_field . ' ' . strtoupper($order) : ''); $list = Sql::pSelect($q, $form, $value); return SqlObject::ListToObjects($list, $classname); }
public static function getPokes($to) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE `to` = ?'; $list = Sql::pSelect($q, 'i', $to); return SqlObject::loadObjects($list, __CLASS__); }
public static function getByOwner($id) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ? OR owner = ?' . ' ORDER BY owner ASC, name ASC'; $res = Sql::pSelect($q, 'ii', 0, $id); return SqlObject::loadObjects($res, __CLASS__); }
/** * @return all likes of object, except by user_id */ public static function getAllExcept($owner, $type, $user_id) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ? AND type = ? AND user != ?'; $list = Sql::pSelect($q, 'iii', $owner, $type, $user_id); return SqlObject::loadObjects($list, __CLASS__); }
public static function getAll($type, $owner) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ? AND owner = ?' . ' ORDER BY time_created DESC'; $list = Sql::pSelect($q, 'ii', $type, $owner); return SqlObject::loadObjects($list, __CLASS__); }
public static function getAllByOwner($id) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ?'; $list = Sql::pSelect($q, 'i', $id); return SqlObject::loadObjects($list, __CLASS__); }
public static function getNewUsers($limit = 10) { $q = 'SELECT * FROM ' . self::$tbl_name . ' ORDER BY time_created DESC LIMIT ' . intval($limit); $list = Sql::pSelect($q); return SqlObject::loadObjects($list, 'User'); }
public static function getAll($type, $owner) { $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE type = ? AND owner = ?'; $list = Sql::pSelect($q, 'ii', $type, $owner); return $list; }