Selects a single post meta value.
@param postId The post id.
@param metaKey The key.
@return The meta value or {@code null} if none.
@throws SQLException on database error.
493305
public Meta selectPostMetaValue(final long postId, final String metaKey) throws SQLException {
      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      Timer.Context ctx = metrics.selectPostMetaTimer.time();

      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(selectPostMetaValueSQL);
         stmt.setLong(1, postId);
         stmt.setString(2, metaKey);
         rs = stmt.executeQuery();
         return rs.next() ? new Meta(rs.getLong(1), rs.getString(2), rs.getString(3)) : null;
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt, rs);
      }
   }
721755
public Map<Long, Post> selectPostMap(final Collection<Long> postIds, final boolean withResolve) throws SQLException {

      Map<Long, Post> postMap = Maps.newHashMapWithExpectedSize(postIds.size());

      Connection conn = null;
      Statement stmt = null;
      ResultSet rs = null;
      Timer.Context ctx = metrics.selectPostMapTimer.time();
      StringBuilder sql = new StringBuilder(selectPostSQL).append(postsTableName).append(" WHERE ID IN (");
      sql.append(inJoiner.join(postIds));
      sql.append(")");
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.createStatement();
         rs = stmt.executeQuery(sql.toString());
         while(rs.next()) {
            Post.Builder post = postFromResultSet(rs);
            postMap.put(post.getId(), withResolve ? resolve(post).build() : post.build());
         }
         return postMap;
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt, rs);
      }
   }
13603
public Post postReblog(String blogName, Long postId, String reblogKey) {
        return this.postReblog(blogName, postId, reblogKey, null);
    }
711616
public function getPostMeta($postId, $metaName, $fetchOneResult = false)
    {
        return $this->postMetaManager->getPostMeta($postId, $metaName, $fetchOneResult);
    }
1224009
public boolean updatePostTitle(long postId, final String title) throws SQLException {
      Connection conn = null;
      PreparedStatement stmt = null;
      Timer.Context ctx = metrics.updatePostTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(updatePostTitleSQL);
         stmt.setString(1, title);
         stmt.setLong(2, postId);
         return stmt.executeUpdate() > 0;
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt);
      }
   }
322769
@When("^I query the database with '(.+?)'$")
    public void selectData(String query) throws Exception {
        Statement myStatement = null;
        //postgres table
        List<String> sqlTable = new ArrayList<String>();
        List<String> sqlTableAux = new ArrayList<String>();
        Connection myConnection = this.commonspec.getConnection();
        java.sql.ResultSet rs = null;
        try {
            myStatement = myConnection.createStatement();
            rs = myStatement.executeQuery(query);
            //column names
            ResultSetMetaData resultSetMetaData = rs.getMetaData();
            int count = resultSetMetaData.getColumnCount();
            for (int i = 1; i <= count; i++) {
                sqlTable.add(resultSetMetaData.getColumnName(i).toString());
            }
            //takes column names and column count
            while (rs.next()) {
                for (int i = 1; i <= count; i++) {
                    //aux list without column names
                    sqlTableAux.add(rs.getObject(i).toString());
                }
            }
            sqlTable.addAll(sqlTableAux);

            //sends raws to environment variable
            for (int i = 0; i < sqlTable.size(); i++) {
                ThreadProperty.set("queryresponse" + i, sqlTable.get(i));
            }
            ThreadProperty.remove("queryresponse" + sqlTable.size());
            rs.close();
            myStatement.close();
        } catch (Exception e) {
            e.printStackTrace();
            Assertions.assertThat(rs).as("There are no response from SELECT").isNotNull();
        }
    }
401663
private Object getValue(PageContext pc, SQL sql, Query querySource, int row, Collection.Key key, Object value) throws PageException {
	if (value instanceof ZSelectItem) return executeExp(pc, sql, querySource, ((ZSelectItem) value).getExpression(), row);
	return querySource.getAt(key, row);
    }
1079622
public function seePostMetaFor( $post_id, $meta_key, $meta_value = null ) {
		$metas = get_post_meta( $post_id, $meta_key );

		$message = sprintf( 'Post meta %s does not exist', $meta_key );
		$this->assertNotEmpty( $metas, $message );

		if ( func_num_args() > 2 ) {
			$message = sprintf( 'Post meta %s does not contain expected value', $meta_key );
			$this->assertContains( $meta_value, $metas, $message );
		}
	}
844254
public function getMidByKey( $post_id, $meta_key ) {

		/** @var \wpdb $wpdb */
		global $wpdb;
		$mid = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s LIMIT 1 ", $post_id, $meta_key ) );
		if ( ! empty( $mid ) ) {
			return absint( $mid );
		}

		return false;
	}
343870
function mf_get_post_values( $post_id ) {
    global $wpdb;

    $raw = $wpdb->get_results(
      "SELECT
        mfpm.meta_id,
        mfpm.field_name,
        mfpm.field_count,
        mfpm.group_count,
        pm.meta_value
      FROM
        ".MF_TABLE_POST_META." as mfpm
      LEFT JOIN
       ".$wpdb->postmeta." as pm
      ON
        ( mfpm.meta_id = pm.meta_id )
      WHERE
        mfpm.post_id = ".$post_id
    );

    $data = array();

    foreach( $raw as $key => $field ){
      $data[$field->field_name][$field->group_count][$field->field_count] = $field->meta_value;
    }

    return $data;
  }
725599
function getMeta(key) {
  return baseQuery(key)
    .select('meta')
    .where('id', key)
    .then(pullValFromRows(key, 'meta'));
}
593685
public function delete($post_id, string $key, $where = '')
    {
        $post_id = (int) ($post_id ?? get_the_ID());

        if (!$post_id || !$key) {
            return; // Not possible.
        }
        delete_post_meta($post_id, $this->key($key), $where);
    }
1094228
private void get(final StringBuilder sql) {
        sql.append("SELECT * FROM ").append(getName()).append(" WHERE ").append(JdbcRepositories.getDefaultKeyName()).append(" = ?");
    }
1305584
public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) {
    try {
      //
      //   invoking JDK 1.4 method by reflection
      //
      return ((Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null).invoke(meta, null)).booleanValue();
    } catch(Throwable e) {
      getLogger().info("Could not call supportsGetGeneratedKeys method. This may be recoverable");
      return false;
    }
  }
849584
private void readMetadata() throws SQLException {
    if (valid) {
      return;
    }

    String[] metaInfos = queryMetaInfos(isFunction);
    String paramList = metaInfos[0];
    String functionReturn = metaInfos[1];

    parseParamList(isFunction, paramList);

    // parse type of the return value (for functions)
    if (isFunction) {
      parseFunctionReturnParam(functionReturn);
    }

  }
377961
public boolean updatePostAuthor(final long postId, final long authorId) throws SQLException {

      Connection conn = null;
      PreparedStatement stmt = null;
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(updatePostAuthorSQL);
         stmt.setLong(1, authorId);
         stmt.setLong(2, postId);
         return stmt.executeUpdate() > 0;
      } finally {
         SQLUtil.closeQuietly(conn, stmt);
      }
   }
985863
void performPostExecute() throws SQLException {

        resultOut.clearLobResults();

        generatedResult = null;

        if (resultIn == null) {
            return;
        }

        Result current = resultIn;

        while (current.getChainedResult() != null) {
            current = current.getUnlinkChainedResult();

            if (current.getType() == ResultConstants.WARNING) {
                SQLWarning w = Util.sqlWarning(current);

                if (rootWarning == null) {
                    rootWarning = w;
                } else {
                    rootWarning.setNextWarning(w);
                }
            } else if (current.getType() == ResultConstants.ERROR) {
                errorResult = current;
            } else if (current.getType() == ResultConstants.DATA) {
                generatedResult = current;
            }
        }

        if (resultIn.isData()) {
            currentResultSet = new JDBCResultSet(connection.sessionProxy,
                    this, resultIn, resultIn.metaData,
                    connection.connProperties);
        }
    }