w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Specifying branch arguments to git fetch, merge, and push
git fetch upstream devel is the same than: git fetch upstream refs/heads/devel You don't provide a destination in your refspec, so the fetch update FETCH_HEAD, as explained in "In git, how do I check out a remote repository's remote branches?". This is a short-lived ref, used if you do a pull (fetch + merge). git fetch upstream fetches everything, so there is no single ref to update. git merge must specify the source of the merge, in your case the remote branch devel (upstream/devel since upstream is the name of your updated remote, updated after the fetch) git merge devel would merge the local branch devel on the current branch... and if you are already on devel, that would result in a no-op. But git push also specify the source, here a local branch devel, a remote destination o

Categories : GIT

How to merge two wordpress queries and randomize?
You would have to use the WP Query in such a way that it isn't setting the MAIN query. By running two separate queries you can iterate through each without impacting the other. Once you have them broken into two separate queries, all you need to do is define your algorithm for iterating through them.

Categories : PHP

Trying to merge a COUNT query in to an existing SELECT query
SELECT contact.id_contact, contact.cname, contact.cemail, contact.trading_id, trading_name.trading_name,CustomerAlertCountTotal FROM contact INNER JOIN trading_name ON contact.trading_id = trading_name.id_trading_name LEFT JOIN (SELECT COUNT(AlertID) AS CustomerAlertCountTotal,AlertTradingID FROM customer_support_dev.customer_alerts )as count on count.AlertTradingID=contact.trading_id WHERE (CHAR_LENGTH(contact.cname) > 0) ORDER BY contact.cname

Categories : Mysql

SQL query too big - Can I merge this?
Queries of this form: Show rows which do not have a match in the other table. Can be done like this: select <columns> from <table1> left outer join <table2> on <join_condition> where table2.column IS NULL This will find rows from table1 which do not have anything in table2 matching the join condition. For your summing query, I would do something like this... select table1.order_number, total = sum(table2.order_amount) from table1 left outer join table2 on table1.order_number = table2.order_number group by order_number having total < (some_number) OR total is null That combines getting orders which have no matches, and getting orders with less than some total order_amount.

Categories : SQL

Merge query: set map and 'created' property upon creation
That last one should work IMO--can you make a github issue? We'll see what the neo guys say, but I think it should be ok to have comma separated sets. As an alternative, you can do multiple ON CREATEs: MERGE (n:User {email: {email}}) ON CREATE n SET n = {user} ON CREATE n SET n.created = timestamp() WITH n WHERE n.created = timestamp() RETURN n

Categories : Neo4j

pass arguments into anchor after sql query
I don't think it is possible this way. You will have first to retrieve the result (as an associative array) and then call Codeigniter's anchor function on the result. Your RDBMS is totally ignorant of the anchor function. Something that might look like this : $query = $this->datatables->select('first_name','roll_num') ->from('students') ->get(); $results = $query->result(); anchor("cancel/{$results[0]->first_name}/{$results[0]->roll_num}", 'Delete', array('onClick' =>"return confirm('Are you sure you want to delete?')")); I did not tried the above code, so it might have some synthax fixing, but I thinkthe general solution is there.

Categories : PHP

Can I use binding arguments in a copy_to query?
From the psycopg docs: Reads data from a file-like object appending them to a database table "What's a file-like object?" you might ask. File objects are described in the python documentation and the distinction between them and file-like objects are indicated there. In general, it's an object that supports methods like open()/read()/write()/close() with the signatures matching that of the file object. So the way to bind it would be either to use a real file (consider the tempfile module), or an in-memory "file" like that in StringIO.

Categories : Python

Format in TSQL of simple 'Merge into' query using 'Case'
I don't think merge is necessarily meant to be used in the way you are describing, and if you got it to work it would be somewhat inscrutable code. Merge is meant to compare defined column relations between tables and either update or insert into the tables depending on those relations. I think you are better off just using a couple IF...INSERT ... ELSE ... UPDATE... statements. It would be just as fast and easier to read for what you are trying to accomplish.

Categories : Sql Server

Query callback with arguments and synchronous queries
A) I personally like lodash (or underscore if you prefer) partial() for this. It takes a function and a number of arguments and returns a function with the provided arguments applied and the remaining arguments still open. It's very much like the functional concept of currying. B) For combining multiple asynchronous results I highly recommend async. The syntax will take a little getting used to, but makes thing like this very easy. Quick sample: async.parallel([ one: function(callback){ db.fetch(options, callback); }, two: function(callback){ db.fetch(options, callback); } ], function(err, results){ // this callback will get called when either parallel call gives an error // or when both have called the callback if (err) { // handle err

Categories : Node Js

JdbcTemplate : Issue with dynamically configurable query arguments
the 2013-06-28,DATE||helloWorld,VARCHAR is a good way you can make some handlers to parse it,like: Map<String,IConvert> converts = new HashMap<String, IConvert>(){ put("varchar",new StringConver()); put("date",new DateConver()); } //then converts.get(type).toParam(string) what I guess Why the error is not coming when log4j is in info mode, the error is coming with debug mode! The jdbcDriver will not throw exception when you setString() to a date type,but will return a warnings like 'Code: 1292 SQL State: HY000 --- Incorrect date value' Maybe the dbcTemplate using debug mode to treat it.

Categories : Java

Any idea why I am getting 'arguments are of the wrong type' error when trying to insert to db with parameterized query?
I think you forgot to include adovbs.inc, and thus the ADO constants such as adChar arent recognized. Try put this at the top of your ASP page: <!--#include virtual="/adovbs.inc"--> If that doesn't work, see this here which explains how to set up the inc file: http://www.4guysfromrolla.com/webtech/faq/Beginner/faq7.shtml

Categories : SQL

passing multiple arguments to sql query in code igniter without using active records
//do it as: function get_values($id, $age) { $this->db->where("id",$id); $this->db->where("unit",$age); $query=$this->db->get("tblRegister"); return $query->result_array(); }

Categories : PHP

How can I pass an unkown number of arguments to C#'s "Database.Open("DatabaseName").Query()" method?
I'm not sure I quite understand what you need from the question, but it looks like you're substituting a series of placeholders in the SQL with another value. If that's the case, you can use String.Format to replace the values like this: object val = "a"; object anotherVal = 2.0; var result = string.Format("{0} - {1}", new[] { val, anotherVal }); This way, you can substitute as many values as you need by simply creating the arguments array to be the right size. If you're creating a SQL query on the fly, then you need to be wary of SQL injection, and substituting user-supplied text directly into a query is a bit of a no-no from this point of view. The best way to avoid this is to use parameters in the query, which automatically then get sanitised to prevent SQL i

Categories : C#

What's the difference between "svn merge --reintegrate" and svn merge without reintegrate if I'd like to merge a branch onto the trunk
A sync merge is something completely different than a reintegration merge. The former is used to merge all changes made on the parent branch to the target branch (typically a feature branch), that have not already been merged. The latter is used to merge a (feature) branch back into the parent branch. Basically that means a temporary clone of the (feature) branch is created, a sync merge is made from the parent branch to the temporary branch, and finally the parent branch is replaced by the temporary branch. In other words, the temporary branch contains all changes made to the (feature) branch and parent branch. For some reason, some developers do not understand the difference. So, the SVN developers removed the option --reintegrate in SVN 1.8. With this version, the tool detects automati

Categories : Svn

Can I add an ID to the divs in this Wordpress query?
Yes (edited): <?php $i = 1; $id = 2; echo '<div class="row content-block" id="block-1">'; if ( $project->have_posts() ) : while ( $project->have_posts() ) : $project->the_post(); get_template_part('project', 'content'); if($i % 12 == 0) {echo '</div><div class="row content-block" id="block-' .$id .'">'; $id++;} $i++; endwhile; endif; echo '</div>'; ?>

Categories : PHP

Query Form in Wordpress
Here is the basic hard coded option field demonstration for loading the next specific option field for the country's states. I do recommend doing this with AJAX and your database but is far beyond the scope of this question. HTML FORM: <form action="submit.php" id="test"> <select id="country"> <option value="Argentina">Argentina</option> <option value="Mexico">Mexico</option> <option value="Russia">Russia</option> </select> <input type="submit" value="Submit" /> </form> PHP SCRIPT, file name: submit.php <?php if ( isset ( $_POST['test'] ) ) { $country = $_POST['country']; if ( isset ( $country ) && $country == 'Russia') { get_template_part('russia_states'); // this includes in russi

Categories : Wordpress

Wordpress custom query
If you're loading it from a standalone PHP file (ie not from within your WordPress theme), you'll have to call wp-load.php to initialise the WordPress variables (including $wpdb). Have a look at this answer, including the comment about only needing wp-load.php. I'd consider using a relative path (what that would be would depend on where you put your page relative to WordPress) rather than using $_SERVER['DOCUMENT_ROOT'];, but that's just a personal preference. EDIT Rereading after seeing your comment, I've just realised $wpdb->words probably won't exist. Try $words = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "words") instead. That'll generate the table name correctly as wp_words. Of course, you'll need to populate it the same way.

Categories : PHP

How to print a wordpress query?
Add this in your functions.php then add ?debug=sql after the url, for example http://someUrl.com/something?debug=sql Or http://localhost/localCopy?debug=sql Also <?php echo $GLOBALS['wp_query']->request; ?> should work, just put it right after the loop if you didn't it before.

Categories : Wordpress

Wordpress Query Grandchildren Only
I found the answer here. While I admit this works for my application, I'm not sure on what exactly the code is doing, sure, you're interrogating a query with another query to see if there are any grandchildren, however a little lost on the details of what the implode() is for. <?php // set the id of current page $gen1_ids = get_the_ID(); // query the id for children (or at least that's what I think this query does) $gen2 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen1_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC"); $gen2_ids = implode($gen2,', '); //query children if they have children $gen3 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->pos

Categories : Wordpress

Custom wordpress sql query with pagination
You need to put $paged parameter into your code and then call the previous/next links. See this: https://codex.wordpress.org/Pagination#Adding_the_.22paged.22_parameter_to_a_query

Categories : Wordpress

Query to add taxonomies terms in WordPress
also as an additional idea is to somehow amend the second part of the code after //Handle metadata function set_custom_taxonomies($type) { global $json_api; $taxonomies = get_taxonomies(array( 'object_type' => array($type), 'public' => true, '_builtin' => false ), 'objects'); foreach ($taxonomies as $taxonomy_id => $taxonomy) { $taxonomy_key = "taxonomy_$taxonomy_id"; if (!$json_api->include_value($taxonomy_key)) { continue; } $taxonomy_class = $taxonomy->hierarchical ? 'JSON_API_Category' : 'JSON_API_Tag'; $terms = get_the_terms($this->id, $taxonomy_id); $this->$taxonomy_key = array(); if (!empty($terms)) { $taxonomy_terms = array(); foreach ($terms as $term) { $taxonomy_terms[] = new $taxonomy_class($term); } $this

Categories : PHP

Execute Query Within Wordpress Shortcode
return returns the value, which is what you need, but also exits the function. Also in WP you have a get_ prefixed version of your helper functions, which also returns a value instead of directly echoing it. so what you might want to try is something like: function myfunction(){ $string = 'lets'; $string .= ' build some string '; $string .= get_the_permalink(); return $string; } see http://php.net/manual/en/language.operators.string.php

Categories : PHP

Wordpress else statement on custom query
Add curly braces (or put a colon after the : if ( $spQuery->have_posts() ) instead of curly braces) <ul class="posts"> <?php if ( $spQuery->have_posts() ) { while ( $spQuery->have_posts() ) : $spQuery->the_post(); ?> <li><?php the_post_thumbnail( 'themename-bw-image' ); ?></li> <?php endwhile; wp_reset_postdata(); ?> </ul> <?php } else { ?> <p>No Posts Currently Added.</p> <?php } ?>

Categories : PHP

Wordpress post query by author
<?php while (have_posts() ) : the_post(); ?> <?php $author_name = get_post_meta($post->ID, 'author_name', true); ?> <?php endwhile; ?> <?php $args = array( 'posts_per_page' => 3, 'post_type'=> 'post','meta_key'=>'author_name','meta_value'=>$author_name); query_posts($args); ?> <ul> <?php while (have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul>

Categories : Wordpress

wordpress custom query confusion
Something like this should do what you want. It's untested, as I don't have any data matching yours. It'll return dates, not strings - if you need the results as strings you'll need to do a conversion. SELECT min(STR_TO_DATE(s.meta_value, '%m/%d/%Y' )) as min_start_date, max(STR_TO_DATE(s.meta_value, '%m/%d/%Y' )) as max_start_date FROM wp_posts p LEFT JOIN wp_postmeta s ON p.ID = s.post_id AND s.meta_key = '_dabg-event-start-date' LEFT JOIN wp_postmeta e ON p.ID = e.post_id AND e.meta_key = '_dabg-event-end-date' JOIN wp_term_relationships ON p.ID = wp_term_relationships.object_id WHERE wp_term_relationships.term_taxonomy_id = '4' AND ( STR_TO_DATE(s.meta_value, '%m/%d/%Y' ) >= CURDATE() OR STR_TO_DATE( e.meta_value, '%m/%d/%Y' ) >= CURDATE() ) AND p.po

Categories : Mysql

WordPress Query: ORDER BY CASE WHEN
I wonder if you could add a filter to the query by adding that little extension on there. I'm thinking maybe posts_orderby Function function filter_case($orderby = '') { $orderby .= 'CASE WHEN [some conditions]'; return $orderby; } Before Query add_filter( 'posts_orderby', 'filter_case' ); $wp_query = new WP_Query($args); remove_filter( 'posts_orderby', 'filter_case' ); I cant gaurantee this will work first time but it could be worked on if you think it's worth pursuing? List of WP_Query filters are here.

Categories : PHP

How to order by two different things at once in a query in WordPress
According to the Codex, you simply need to separate them by a space: Multiple 'orderby' values Display pages ordered by 'title' and 'menu_order'. (title is dominant): $query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'title menu_order', 'order' => 'ASC' ) ); In your case, that would look like: 'orderby' => 'meta_value_num date' EDIT: Okay, it seems like you're trying to do something a bit more complex here. This is how I interpret it, correct my if I'm wrong: Order by air_date (in descending order, newest first). Keep only the 12 newest items according to air_date. Order the resulting 12 items by date. What orderby does is basically: Order by air_date. If any items have identical air_date values, order those by date. Keep only the top 12

Categories : PHP

WordPress WP_Query - Can't query post_title
I was intrigued by your question, and did some digging myself. http://wordpress.stackexchange.com/questions/18703/wp-query-with-post-title-like-something Basically, by defining a filter for WP_Query you can create a precise result set.

Categories : SQL

Wordpress PHP posts using category as query
In order to only display posts from a single category (or subcategory), you do not need to write any code on page.php file of wordpress. If you want to modify the way posts or list of posts work, on twenty twelve theme, check the file category.php. In order to display the posts of the wanted category you only have to call the category's link. For example, in order to show all the posts on BTCC category, just use this url: http://talkativebroadcasting.co.uk/category/BTCC/ In the same way, you can show all categories you need.

Categories : PHP

Wordpress PHP create or add to query string
Since you're using Wordpress, you can use add_query_arg: From the docs: <?php // Parameters as separate arguments add_query_arg( $param1, $param2, $old_query_or_uri ); // Parameters as array of key => value pairs add_query_arg( array('key1' => 'value1', ...), $old_query_or_uri ); ?> You can pass in a parameter and a value (or an associative array), along with the the existing URL, and it will generate a properly formatted URL for you. There also the companion remove_query_arg

Categories : PHP

SQL Wordpress Query - inner vs outer join
That's a pretty intense query. It's hard to know exactly how to do this efficiently without knowing your table structures better (seems like a few of those JOINS could be combined). Here is a stab just by editing your original query: SELECT p.*, pm.*, pm_featured.meta_value AS featured, pm_latlng.meta_value AS latlng FROM wp_posts p JOIN wp_postmeta pm ON pm.post_id = p.ID JOIN wp_postmeta pm_propdetails ON (pm_propdetails.post_id = p.ID AND pm_propdetails.meta_key = 'propdetails') LEFT JOIN wp_postmeta pm_featured ON (pm_featured.post_id = p.ID AND pm_featured.meta_key = 'featured-property') LEFT JOIN wp_postmeta pm_latlng ON (pm_latlng.post_id = p.ID AND pm_latlng.meta_key = 'martygeocoderlatlng') JOIN wp_term_relation

Categories : Mysql

WordPress Custom Query and Pagination
use this code for pagination. http://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin

Categories : Wordpress

Wordpress sql query for last comment date
You need not query wordpress database directly. WP provides an API to retrieve this. $comments = get_comments( array( 'post_id' => $post->ID, 'orderby' => 'comment_date_gmt', 'status' => 'approve', 'number' => 1 ) ); Check out this API reference. Specifying number as 1 returns only the last comment. The date value for last comment can be retrieved as $comments[0]['date'] Now that you want to use this from outside, include the following at top of your php code require('/the/path/to/your/wp-blog-header.php'); Check out this wordpress doumentation If you get an out of loop error try adding this code. The loop starts here: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> and ends here: <?php endwhile; else: ?> &l

Categories : PHP

custom query to get posts (Wordpress)
First of all you are not using get_query_var() correctly. This is a php function and needs to be inside php tags also this function is returning the info that you require so you'll have to save it in a variable. For your example you should use it like this: <?php /* Template Name: MyCustomTemplate */ ?> <?php get_header();?> <?php global $wp_query; $gotten_cat = get_query_var( 'cat' ); $gotten_tag = get_query_var( 'tag' ); ?> Now if you fallow a link like mydomain.com/custom_page/cat=ABC&tag=XYZ then $gotten_cat will have the value "ABC" and $gotten_tag will have the value = "XYZ". At some point you need to decide if "ABC" is the category slug or the category id, same with the tag Now if we assume that ABC is the category id and XYZ is the tag id (if it is the sl

Categories : Wordpress

Custom wordpress post query
Try this while ( have_posts() ) : the_post(); echo '<li>'; the_content(); echo '</li>'; endwhile; See The Loop in Action for reference

Categories : PHP

Wordpress MySQL query not working
You need like this $row_kids = $wpdb->query("SELECT * FROM reg_children WHERE children LIKE '%$data_entry_id%' AND uid='$current_user_id'"); You have meshed with single quotes only and make sure that $wpdb has declared globally. And also the insert query also should be like $wpdb->query("INSERT INTO reg_children VALUES (NULL , '$data_entry_id', '$current_user_id' )"); and Mainly your if statement should be like if (!empty($totalRows_kids)) { You forgot closing brace and make sure that you have defined $totalRows_kids...I think that be the count of results from select query

Categories : PHP

Slow wordpress query time
Try and explain as follows. Paste the following into phpmyadmin and execute it:- EXPLAIN SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) INNER JOIN wp_terms ON (wp_term_taxonomy.term_id = wp_terms.term_id) WHERE 1=1 AND wp_posts.blog_id = '1' AND wp_term_taxonomy.taxonomy = 'post_tag' AND wp_terms.slug IN ('rate') AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 20 Then copy the results of that and paste them into your original question. It will give details of which keys were used in which tables, etc.

Categories : Mysql

WordPress Meta Query Arrays
You're going to run into problems with your current approach because, as you note, the ids are saved as serialized arrays in a single field. An easier approach would be to save each like as a single postmeta entry. So meta_key = "like" and meta_value = user ID. So for storing the likes switch from update_post_meta to add_post_meta: /** The fourth parameter, false, tells WP that there can be multiple * post_meta entries with the same meta_key. It's false by default, just here * here for reference */ add_post_meta($post->ID, 'like', $user_id, false); Then to get posts liked by a specific user you would just do: $liked_posts = $wpdb->get_results("SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = 'like' AND meta_value = $user_id"); To get results

Categories : PHP

Wordpress Query parsing only author ids
following code will helpfull for you. if(have_posts()){ $author_arr = array(); while(have_posts()){ the_post(); global $post; if(!in_array($post->post_author,$author_arr)){ $author_arr[] = $post->post_author; } } }

Categories : Arrays

WordPress Mysql Query and Duplicates
Use DISTINCT after SELECT. It will remove the duplicates $querystr = " SELECT DISTINCT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'Country' AND wpostmeta.meta_value = 'UK' AND wposts.post_type = 'post' ";

Categories : Mysql



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.