本文整理汇总了PHP中FD::db方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::db方法的具体用法?PHP FD::db怎么用?PHP FD::db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCachedImages
/**
* Retrieves a list of cached images
*
* @since 1.3
* @access public
* @param string
* @return
*/
public function getCachedImages($options = array())
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_links_images');
if (isset($options['storage'])) {
$sql->where('storage', $options['storage']);
}
if (isset($options['exclusion']) && !empty($options['exclusion'])) {
$sql->where('id', $options['exclusion'], 'NOT IN');
}
if (isset($options['limit'])) {
$sql->limit($options['limit']);
}
$db->setQuery($sql);
$result = $db->loadObjectList();
if (!$result) {
return $result;
}
$images = array();
foreach ($result as $row) {
$linkImage = FD::table('LinkImage');
$linkImage->bind($row);
$images[] = $linkImage;
}
return $images;
}
示例2: getItems
public function getItems()
{
$db = FD::db();
$query = 'SELECT * FROM ' . $db->nameQuote('#__social_toolbar') . ' WHERE ' . $db->nameQuote('state') . '=' . $db->Quote(SOCIAL_STATE_PUBLISHED);
$db->setQuery($query);
return $db->loadObjectList();
}
示例3: store
public function store($updateNulls = false)
{
if (empty($this->ordering)) {
$this->ordering = $this->getNextOrder('type = ' . FD::db()->quote($this->type) . ' AND parent_uid = ' . FD::db()->quote($this->parent_uid));
}
parent::store($updateNulls);
}
示例4: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_clusters_categories');
$sql->where('type', 'group');
$sql->where('ordering', '0');
$db->setQuery($sql);
$result = $db->loadObjectList();
foreach ($result as $row) {
$table = FD::table('GroupCategory');
$table->bind($row);
$table->ordering = $table->getNextOrder('type = ' . $db->quote('group'));
$table->store();
}
$sql->clear();
$sql->select('#__social_clusters_categories');
$sql->where('type', 'group');
$sql->order('ordering');
$sql->order('id');
$db->setQuery($sql);
$result = $db->loadObjectList();
$counter = 1;
foreach ($result as $row) {
$table = FD::table('GroupCategory');
$table->bind($row);
$table->ordering = $counter;
$table->store();
$counter++;
}
return true;
}
示例5: getFields
public static function getFields(&$params)
{
$db = FD::db();
$sql = $db->sql();
static $fields = null;
if (!$fields) {
// later we need to respect the module settings.
$elements = array('address', 'birthday', 'gender', 'joomla_fullname', 'joomla_username');
$db = FD::db();
$sql = $db->sql();
$query = 'select a.`unique_key`, a.`title`, b.`element`';
$query .= ' from `#__social_fields` as a';
$query .= ' inner join `#__social_fields_steps` as fs on a.`step_id` = fs.`id` and fs.`type` = ' . $db->Quote('profiles');
$query .= ' inner join `#__social_profiles` as p on fs.`uid` = p.`id`';
$query .= ' inner join `#__social_apps` as b on a.`app_id` = b.`id` and b.`group` = ' . $db->Quote('user');
$query .= ' where a.`searchable` = ' . $db->Quote('1');
$query .= ' and a.`state` = ' . $db->Quote('1');
$query .= ' and a.`unique_key` != ' . $db->Quote('');
$query .= ' and p.`state` = ' . $db->Quote('1');
$string = "'" . implode("','", $elements) . "'";
$query .= ' and b.`element` IN (' . $string . ')';
$sql->raw($query);
// echo $sql;exit;
$db->setQuery($sql);
$results = $db->loadObjectList();
// manual grouping / distinct
if ($results) {
foreach ($results as $result) {
//$fields[ $result->unique_key ] = $result;
$fields[$result->element] = $result;
}
}
}
return $fields;
}
示例6: loadByUIDBatch
public function loadByUIDBatch($ids)
{
$db = FD::db();
$sql = $db->sql();
$streamIds = array();
foreach ($ids as $pid) {
if (!isset(self::$_streamitems[$pid])) {
$streamIds[] = $pid;
}
}
if ($streamIds) {
foreach ($streamIds as $pid) {
self::$_streamitems[$pid] = false;
}
$idSegments = array_chunk($streamIds, 5);
//$idSegments = array_chunk( $streamIds, count($streamIds) );
$query = '';
for ($i = 0; $i < count($idSegments); $i++) {
$segment = $idSegments[$i];
$ids = implode(',', $segment);
$query .= 'select * from `#__social_stream_item` where `uid` IN ( ' . $ids . ')';
if ($i + 1 < count($idSegments)) {
$query .= ' UNION ';
}
}
$sql->raw($query);
$db->setQuery($sql);
$results = $db->loadObjectList();
if ($results) {
foreach ($results as $row) {
self::$_streamitems[$row->uid] = $row;
}
}
}
}
示例7: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_fields_data', 'a');
$sql->column('a.*');
$sql->leftjoin('#__social_fields', 'b');
$sql->on('a.field_id', 'b.id');
$sql->leftjoin('#__social_apps', 'c');
$sql->on('b.app_id', 'c.id');
$sql->where('c.type', 'fields');
$sql->where('c.element', array('birthday', 'datetime'), 'IN');
$db->setQuery($sql);
$result = $db->loadObjectList();
$json = FD::json();
foreach ($result as $row) {
$table = FD::table('fielddata');
$table->bind($row);
if ($json->isJsonString($table->data)) {
$table->datakey = 'date';
$table->store();
}
}
return true;
}
示例8: broadcast
/**
* Broadcast a message to a set of profiles on the site.
*
* @since 1.3
* @access public
* @param int The profile id to target. 0 for all
* @param string The message to be broadcasted
* @param string The title for the announcement
* @return
*/
public function broadcast($id, $content, $createdBy, $title = '', $link = '')
{
$db = FD::db();
$sql = $db->sql();
$query = array();
$query[] = 'INSERT INTO ' . $db->quoteName('#__social_broadcasts');
$query[] = '(`target_id`,`target_type`,`title`,`content`,`link`,`state`,`created`,`created_by`)';
// Get the creation date
$date = FD::date();
$query[] = 'SELECT';
$query[] = '`user_id`,' . $db->Quote(SOCIAL_TYPE_USER) . ',' . $db->Quote($title) . ',' . $db->Quote($content) . ',' . $db->Quote($link) . ',1,' . $db->Quote($date->toSql()) . ',' . $db->Quote($createdBy);
$query[] = 'FROM ' . $db->quoteName('#__social_profiles_maps');
$query[] = 'WHERE 1';
if (!empty($id)) {
$query[] = 'AND ' . $db->quoteName('profile_id') . '=' . $db->Quote($id);
}
// Exclude the broadcaster because it would be pretty insane if I am spamming myself
$my = FD::user();
$query[] = 'AND `user_id` !=' . $db->Quote($my->id);
$query = implode(' ', $query);
$sql->raw($query);
$db->setQuery($sql);
$state = $db->Query();
if (!$state) {
return $state;
}
// Get the id of the new broadcasted item
$id = $db->insertid();
return $id;
}
示例9: init
public function init($options = array())
{
$this->db = FD::db();
if (isset($options['mode'])) {
$this->mode = $options['mode'];
}
if (isset($options['key'])) {
$this->key = $options['key'];
}
if (isset($options['tablename'])) {
$this->tablename = $options['tablename'];
}
if (isset($options['tablekey'])) {
$this->tablekey = $options['tablekey'];
}
$table = $this->getTable();
if (empty($this->tablename)) {
$this->tablename = $table->getTableName();
}
if (empty($this->tablekey)) {
$this->tablekey = $table->getKeyName();
}
if ($this->mode === 'full') {
$this->initTable();
}
}
示例10: main
public function main()
{
// Loop through 200 users at one time
$limit = 200;
// Set all points status to 0 first.
$db = FD::db();
$sql = $db->sql();
$sql->update('#__social_points_history');
$sql->set('state', 0);
$db->setQuery($sql);
$db->Query();
// Now we need to merge all of these records into 1
$sql->clear();
// We need to use Joomla's date instead of mysql's NOW() because the timezone on mysql could be different.
$date = FD::date();
$query = array();
$query[] = 'INSERT INTO `#__social_points_history`(`points_id`,`user_id`,`points`,`created`,`state`,`message`)';
$query[] = "SELECT 0, `user_id` ,SUM(`points`), '" . $date->toSql() . "', 1, 'COM_EASYSOCIAL_POINTS_AGGREGATED' FROM `#__social_points_history` GROUP BY `user_id`";
$query = implode(' ', $query);
$sql->raw($query);
$db->setQuery($sql);
$db->Query();
// Then we need to delete all the unpublished records
$sql->clear();
$sql->delete('#__social_points_history');
$sql->where('state', 0);
$db->setQuery($sql);
$db->Query();
// Also delete any points history that is assigned to guests
$sql->clear();
$sql->delete('#__social_points_history');
$sql->where('user_id', 0);
$db->setQuery($sql);
$db->Query();
}
示例11: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_fields_data', 'a')->column('a.*')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.field_id')->leftjoin('#__social_apps', 'c')->on('c.id', 'b.app_id')->where('a.datakey', '')->where('c.type', 'fields')->where('c.element', 'joomla_fullname');
$db->setQuery($sql);
$result = $db->loadObjectList();
$json = FD::json();
foreach ($result as $row) {
if ($json->isJsonString($row->data)) {
$data = $json->decode($row->data);
// Split json object into each individual row
foreach ($data as $k => $v) {
if (!empty($v)) {
$table = $this->getTable($row->field_id, $row->uid, $row->type, $k);
$table->data = $v;
$table->raw = $v;
$table->store();
}
}
}
// Remove the row with empty key
$sql->clear();
$sql->delete('#__social_fields_data')->where('id', $row->id);
$db->setQuery($sql);
$db->query();
}
return true;
}
示例12: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
// reset fields privacy if the option is customize, set it back to only me.
$query = "update `#__social_privacy` as a";
$query .= " left join `#__social_privacy_map` as b on a.`id` = b.`privacy_id`";
$query .= " left join `#__social_privacy_items` as c on a.`id` = c.`privacy_id`";
$query .= " set a.`options` = " . $db->Quote('{"options":["public","member","friend","only_me"]}') . ",";
$query .= " b.`value` = if(b.`value` = '100', '40', b.`value`),";
$query .= " c.`value` = if(c.`value` = '100', '40', c.`value`)";
$query .= " where a.`type` = 'field'";
$sql->raw($query);
$db->setQuery($sql);
$db->query();
// now we need to remove fields privacy of 'joomla_username' and 'joomla_fullname'
$query = "delete a, b, c";
$query .= " from `#__social_privacy` as a";
$query .= " left join `#__social_privacy_map` as b on a.`id` = b.`privacy_id`";
$query .= " left join `#__social_privacy_items` as c on a.`id` = c.`privacy_id`";
$query .= " where a.`type` = 'field'";
$query .= " and a.`rule` in ('joomla_fullname', 'joomla_username')";
$sql->clear();
$sql->raw($query);
$db->setQuery($sql);
$db->query();
return true;
}
示例13: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
// For country field
$sql->select('#__social_fields_data', 'a')->column('a.*')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.field_id')->leftjoin('#__social_apps', 'c')->on('c.id', 'b.app_id')->where('a.datakey', '')->where('c.type', 'fields')->where('c.element', 'country');
$db->setQuery($sql);
$result = $db->loadObjectList();
$json = FD::json();
// Load up the list of countries
$file = SOCIAL_ADMIN_DEFAULTS . '/countries.json';
$list = FD::makeObject($file);
foreach ($result as $row) {
if ($json->isJsonString($row->data)) {
$data = $json->decode($row->data);
// Split json object into each individual row
foreach ($data as $k => $v) {
if (!empty($v)) {
$table = $this->getTable($row->field_id, $row->uid, $row->type, $k);
$country = $list->{$v};
$table->data = $country;
$table->raw = $country;
$table->store();
}
}
}
// Remove the row with empty key
$sql->clear();
$sql->delete('#__social_fields_data')->where('id', $row->id);
$db->setQuery($sql);
$db->query();
}
return true;
}
示例14: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_apps');
$sql->where('type', 'fields');
$db->setQuery($sql);
$result = $db->loadObjectList();
foreach ($result as $row) {
$file = SOCIAL_FIELDS . '/' . $row->group . '/' . $row->element . '/' . $row->element . '.xml';
if (!JFile::exists($file)) {
continue;
}
$table = FD::table('App');
$table->bind($row);
$parser = FD::get('Parser');
$parser->load($file);
$val = $parser->xpath('unique');
$unique = 0;
if ($val) {
$unique = (string) $val[0];
$unique = $unique == 'true' ? 1 : 0;
}
$table->unique = $unique;
$table->store();
}
return true;
}
示例15: getItems
public function getItems($options = array())
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_clusters_nodes', 'a');
$sql->column('a.*');
$eventid = isset($options['eventid']) ? $options['eventid'] : 0;
$sql->where('cluster_id', $eventid);
if (isset($options['state'])) {
$sql->where('state', $state);
}
if (isset($options['admin'])) {
$sql->where('admin', $options['admin']);
}
$ordering = $this->getState('ordering');
if (!empty($ordering)) {
$direction = $this->getState('direction');
if ($ordering == 'username') {
$sql->leftjoin('#__users', 'b');
$sql->on('a.uid', 'b.id');
$sql->order('b.username', $direction);
} elseif ($ordering == 'name') {
$sql->leftjoin('#__users', 'b');
$sql->on('a.uid', 'b.id');
$sql->order('b.name', $direction);
} else {
$sql->order($ordering, $direction);
}
}
$this->setTotal($sql->getTotalSql());
$result = $this->getData($sql->getSql());
$guests = $this->bindTable('EventGuest', $result);
return $guests;
}