本文整理汇总了PHP中wpdb::get_row方法的典型用法代码示例。如果您正苦于以下问题:PHP wpdb::get_row方法的具体用法?PHP wpdb::get_row怎么用?PHP wpdb::get_row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpdb
的用法示例。
在下文中一共展示了wpdb::get_row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchArray
/**
* {@inheritdoc}
*/
public function fetchArray($sql)
{
$sql = $this->_prepareSql($sql);
$result = $this->_db->get_row($sql, ARRAY_N);
$this->_checkError();
return $result;
}
示例2: unserialize
function __toString()
{
// if the playlist are saved to db, i load it from db
$playlist = $this->wpdb->get_row("SELECT ID, url, playlist FROM " . $this->table_name . " WHERE url = '" . $this->url . "'");
if ($this->wpdb->num_rows > 0) {
$playlist = unserialize($playlist->playlist);
} else {
$playlist = array();
$code = implode("", file($this->url));
if ($code == "") {
$this->errors->add('no_content', __('The url $url are not valid!'));
}
preg_match_all("/section-row-track(.+)/", $code, $results);
for ($i = 0; $i < sizeof($results[0]); $i++) {
preg_match("/class=\"tracklisttrackname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match);
$title = $match[1];
preg_match("/class=\"tracklistartistname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match);
$artist = $match[1];
if ($title != "" || $artist != "") {
$playlist[] = array("title" => $title, "artist" => $artist);
}
}
$this->wpdb->show_errors();
// save to db the playlist for this url
$this->wpdb->insert($this->table_name, array("url" => $this->url, "playlist" => serialize($playlist)), array("%s", "%s"));
}
$code = "<h3>Playlist</h3><ul class='mixcloud-embed-playlist'>";
for ($i = 0; $i < count($playlist); $i++) {
$code .= "<li><span class='mixcloud-embed-position'>" . ($i + 1) . "</span>";
$code .= "<span class='mixcloud-embed-artist'>" . $playlist[$i]["artist"] . "</span>";
$code .= "<span class='mixcloud-embed-title'>" . $playlist[$i]["title"] . "</span></li>";
}
$code .= "</ul>";
return $code;
}
示例3: createChangeInfo
protected function createChangeInfo($oldEntity, $newEntity, $action = null)
{
if ($action === 'edit') {
$diff = EntityUtils::getDiff($oldEntity, $newEntity);
}
if (isset($diff['comment_approved'])) {
// determine more specific edit action
if ($oldEntity['comment_approved'] === 'trash' && $newEntity['comment_approved'] === 'post-trashed' || $oldEntity['comment_approved'] === 'post-trashed' && $newEntity['comment_approved'] === 'trash') {
$action = 'edit';
// trash -> post-trashed and post-trashed -> trash are not interesting action for us
} elseif ($diff['comment_approved'] === 'trash') {
$action = 'trash';
} elseif ($oldEntity['comment_approved'] === 'trash') {
$action = 'untrash';
} elseif ($diff['comment_approved'] === 'spam') {
$action = 'spam';
} elseif ($oldEntity['comment_approved'] === 'spam') {
$action = 'unspam';
} elseif ($oldEntity['comment_approved'] == 0 && $newEntity['comment_approved'] == 1) {
$action = 'approve';
} elseif ($oldEntity['comment_approved'] == 1 && $newEntity['comment_approved'] == 0) {
$action = 'unapprove';
}
}
if ($action === 'create' && $newEntity['comment_approved'] == 0) {
$action = 'create-pending';
}
$author = $newEntity["comment_author"];
$postTable = $this->database->prefix . 'posts';
$vpIdTable = $this->database->prefix . 'vp_id';
$result = $this->database->get_row("SELECT post_title FROM {$postTable} JOIN {$vpIdTable} ON {$postTable}.ID = {$vpIdTable}.id WHERE vp_id = UNHEX('{$newEntity['vp_comment_post_ID']}')");
$postTitle = $result->post_title;
return new CommentChangeInfo($action, $newEntity["vp_id"], $author, $postTitle);
}
示例4: getRulesetData
/**
* Fetches ruleset data from database.
*
* @param int $rulesetId Primary key of ruleset.
* @return bool|mixed Array containing ruleset data or false on error.
*/
public function getRulesetData($rulesetId)
{
if (empty($rulesetId)) {
return false;
}
$row = $this->wpdb->get_row("SELECT *\n\t\t\tFROM " . $this->wpdb->rulesets . " rs\n\t\t\tWHERE rs.id = " . (int) $rulesetId, ARRAY_A);
return $row;
}
示例5: findByAttributes
public function findByAttributes(array $attributes = array())
{
$query = 'SELECT * FROM ' . $this->_table();
$where = '';
foreach ($attributes as $key => $value) {
$where .= ($where ? ' AND ' : ' WHERE ') . $key . " = '" . $this->_wpdb->escape($value) . "'";
}
$this->_fields = $this->_wpdb->get_row($query . $where . ' LIMIT 1', 'ARRAY_A');
return $this;
}
示例6: findOneBy
/**
* @param $criteria
* @param $cast
* @return array|null|object
*/
public function findOneBy($criteria, $cast = false)
{
$returnType = $cast ? OBJECT : ARRAY_A;
$criteria = $this->parseCriteria($criteria);
if (class_exists($this->modelClass)) {
$model = new $this->modelClass();
$tableName = $this->wpdb->prefix . $model::TABLE_NAME;
$res = $this->wpdb->get_row($this->wpdb->prepare("\n SELECT *\n FROM {$tableName}\n WHERE {$criteria["where"]}\n ", $criteria["values"]), $returnType);
return $cast ? $this->cast($this->modelClass, $res) : $res;
}
return null;
}
示例7: get_translation_id
/**
* @param string $cms_id
* @param bool|TranslationProxy_Service $translation_service
*
* @return int|null translation id for the given cms_id's target
*/
public function get_translation_id($cms_id, $translation_service = false)
{
list($post_type, $element_id, , $target_lang) = $this->parse_cms_id($cms_id);
$translation = $this->wpdb->get_row($this->wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT t.translation_id, j.job_id, t.element_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_translations t\n\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_translations o\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON o.trid = t.trid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND o.element_type = t.element_type\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$this->wpdb->prefix}icl_translation_status st\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON st.translation_id = t.translation_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$this->wpdb->prefix}icl_translate_job j\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON j.rid = st.rid\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE o.element_id=%d\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND t.language_code=%s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND o.element_type LIKE %s\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1", $element_id, $target_lang, '%_' . $post_type));
$translation_id = $this->maybe_cleanup_broken_row($translation, $translation_service);
if ($translation_service && !isset($translation_id) && $translation_service) {
$job_id = $this->job_factory->create_local_post_job($element_id, $target_lang);
$job = $this->job_factory->get_translation_job($job_id, false, false, true);
$translation_id = $job ? $job->get_translation_id() : 0;
if ($translation_id) {
$this->tm_records->icl_translation_status_by_translation_id($translation_id)->update(array('status' => ICL_TM_IN_PROGRESS, 'translation_service' => $translation_service->id));
}
}
return $translation_id;
}
示例8: record_active_payment
public function record_active_payment($sub_id, $level_order, $stamp)
{
$rel = $this->_wpdb->get_row(sprintf("SELECT * FROM %s WHERE user_id = %d AND sub_id = %d", MEMBERSHIP_TABLE_RELATIONS, $this->ID, $sub_id));
if (!$rel) {
return;
}
$subscription = Membership_Plugin::factory()->get_subscription($sub_id);
$level = $subscription->get_level_at_position($level_order);
if (!$level) {
return;
}
$payment = array('member_id' => $this->ID, 'sub_id' => $sub_id, 'level_id' => $level->id, 'level_order' => $level_order, 'paymentmade' => gmdate('Y-m-d H:i:s', $stamp));
$expires = mysql2date("U", $rel->expirydate);
switch ($level->level_period_unit) {
case 'd':
$paymentexpires = strtotime('+' . $level->level_period . ' days', $expires);
break;
case 'w':
$paymentexpires = strtotime('+' . $level->level_period . ' weeks', $expires);
break;
case 'm':
$paymentexpires = strtotime('+' . $level->level_period . ' months', $expires);
break;
case 'y':
$paymentexpires = strtotime('+' . $level->level_period . ' years', $expires);
break;
}
$payment['paymentexpires'] = gmdate('Y-m-d H:i:s', $paymentexpires);
$this->_wpdb->insert(MEMBERSHIP_TABLE_MEMBER_PAYMENTS, $payment);
}
示例9: array
/**
* Build login cookie.
*/
function build_blog_cookie($action = 'login', $userblog_id = '')
{
global $blog_id;
if ($action == '') {
$action = 'login';
}
$url = false;
if (class_exists('domain_map') && defined('DOMAIN_MAPPING')) {
$domain = $this->db->get_var("SELECT domain FROM {$this->db->dmtable} WHERE blog_id = '{$userblog_id}' ORDER BY id LIMIT 1");
if ($domain) {
$dom = str_replace('.', '', $domain);
$url = 'http://' . $domain . '/';
}
} else {
$domains = $this->db->get_row("SELECT domain, path FROM {$this->db->blogs} WHERE blog_id = '{$userblog_id}' LIMIT 1");
$dom = str_replace('.', '', $domains->domain);
$url = 'http://' . $domains->domain . $domains->path;
}
if ($url) {
$key = get_site_option("multi_domains_cross_domain_{$dom}", array());
$user_id = get_current_user_id();
if (!isset($key[$user_id]['action']) || isset($key[$user_id]['action']) && $key[$user_id]['action'] !== $action) {
$key[$user_id] = array('domain' => $url, 'action' => $action);
update_site_option("multi_domains_cross_domain_{$dom}", $key);
}
$hash = md5(AUTH_KEY . 'multi_domains');
if ($blog_id !== $userblog_id && 'login' == $action) {
// Removing transient check
echo '<link rel="stylesheet" href="' . $url . $hash . '.css?build=' . date("Ymd", strtotime('-24 days')) . '&id=' . $user_id . '" type="text/css" media="screen" />';
set_transient("multi_domains_{$dom}_{$user_id}", 'add', 60 * 15);
}
}
}
示例10: get_term_by_tt_id
/**
* Get a term by its term_taxonomy_id.
*
* @param int $tt_id term_taxonomy_id
* @return array
*/
private function get_term_by_tt_id($tt_id)
{
$sql = "\nSELECT terms.`term_id`, terms.`name`, terms.`slug`, tax.`taxonomy`\nFROM {$this->wpdb->terms} terms\n INNER JOIN {$this->wpdb->term_taxonomy} tax\n ON tax.`term_taxonomy_id` = %d\nWHERE tax.`term_id` = terms.`term_id`\nLIMIT 1";
$query = $this->wpdb->prepare($sql, $tt_id);
$result = $this->wpdb->get_row($query, ARRAY_A);
// $result might be NULL, but we need a predictable return type.
return empty($result) ? array() : $result;
}
示例11: get_term_by_term_taxonomy_id
/**
* Get a term by its term taxonomy ID.
*
* @param int $term_taxonomy_id Term taxonomy ID.
*
* @return array
*/
private function get_term_by_term_taxonomy_id($term_taxonomy_id)
{
$sql = "\nSELECT t.term_id, t.name, tt.taxonomy\nFROM {$this->wpdb->terms} t, {$this->wpdb->term_taxonomy} tt\nWHERE tt.term_id = t.term_id AND tt.term_taxonomy_id = %d\nLIMIT 1";
$query = $this->wpdb->prepare($sql, $term_taxonomy_id);
$result = $this->wpdb->get_row($query, ARRAY_A);
// $result might be NULL, but we need a predictable return type.
return empty($result) ? array() : $result;
}
示例12: get
/**
* Fetches and returns a row from the database.
*
* @param int $id Database id of the row.
* @return array An associative array with column names as keys.
**/
public function get($id)
{
$form = $this->db->get_row("SELECT * FROM {$this->table_name} WHERE id={$id}", ARRAY_A);
if ($form) {
$form["fields"] = $this->unserialize($form["fields"]);
$form["settings"] = $this->unserialize($form["settings"]);
$form["emails"] = $this->unserialize($form["emails"]);
}
return $form;
}
示例13: load
/**
* Load entity from database.
*
* @param integer $id
* @return boolean
*/
public function load($id)
{
$row = $this->wpdb->get_row(sprintf('SELECT * FROM %s WHERE id = %d', $this->table_name, $id));
if ($row) {
$this->setData($row);
$this->loaded = true;
} else {
$this->loaded = false;
}
return $this->loaded;
}
示例14: get_form
/**
* Get the data for a particular form.
*
* @author Jeremy Pry
*
* @param int $form_id The ID of the form to retrieve.
*
* @return array The array of form data.
*/
public function get_form($form_id)
{
// Retrieve the raw data from the DB.
$form_results = $this->wpdb->get_row($this->wpdb->prepare("SELECT * FROM {$this->prefixed_table_name} WHERE id = %d", $form_id), ARRAY_A);
// If there were no results, then return an empty array.
if (null === $form_results) {
/**
* Filter the form data that is retrieved from the Database.
*
* @param array $form_settings The array of processed form data.
* @param int $form_id The form ID.
* @param array $form_results The raw data from the database.
*/
return apply_filters('yikes-easy-mailchimp-extender-form-data', array(), $form_id, $form_results);
}
// Populate array with new settings.
$form_settings = $this->prepare_data_for_display($form_results);
/** This filter is documented in this function above. */
return apply_filters('yikes-easy-mailchimp-extender-form-data', $form_settings, $form_id, $form_results);
}
开发者ID:yikesinc,项目名称:yikes-inc-easy-mailchimp-extender,代码行数:29,代码来源:class-yikes-inc-easy-mailchimp-extender-forms.php
示例15: AND
/**
* @param string $slug
* @param string $post_type
* @param string|bool $language
*
* @return string
*/
function get_translated_slug($slug, $post_type, $language = false)
{
if ($post_type) {
$language = $language ? $language : $this->sitepress->get_current_language();
if (!isset($this->translated_slugs[$post_type][$language])) {
$slug_original = $this->wpdb->get_row($this->wpdb->prepare("SELECT s.value, s.language\r\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\r\n\t\t\t\t\t\t\t\t\t\t AND (s.context = %s OR s.context = %s)", 'URL slug: ' . $post_type, 'default', 'WordPress'));
if ((bool) $slug_original === true) {
$this->translated_slugs[$post_type][$slug_original->language] = $slug_original->value;
$slugs_translations = $this->wpdb->get_results($this->wpdb->prepare("SELECT t.value, t.language\r\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\r\n\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_string_translations t ON t.string_id = s.id\r\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\r\n\t\t\t\t\t\t\t\t\t\t AND (s.context = %s OR s.context = %s)\r\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.status = %d\r\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.value <> ''", 'URL slug: ' . $post_type, 'default', 'WordPress', ICL_TM_COMPLETE));
foreach ($slugs_translations as $translation) {
$this->translated_slugs[$post_type][$translation->language] = $translation->value;
}
foreach ($this->sitepress->get_active_languages() as $lang) {
if (!isset($this->translated_slugs[$post_type][$lang['code']])) {
$this->translated_slugs[$post_type][$lang['code']] = $slug;
}
}
}
}
$slug = !empty($this->translated_slugs[$post_type][$language]) ? $this->translated_slugs[$post_type][$language] : $slug;
}
return $slug;
}