8 – Adding a ‘OR’ condition to query

I need to add a OR condition to my query so that I can get all nodes related to a particular term. Here is what I have done :

$query = Drupal::database()->select('taxonomy_index', 'ti');
$query->fields('ti', ('nid'));

$or_group = $query->orConditionGroup()->condition('ti.tid', $params(1), 'IN');

$query->condition('ti.tid', $params(0), 'IN');
$query->condition('ti.status', 1);



This is the how the query get build :


SELECT ti.nid AS nid

FROM {taxonomy_index} ti

WHERE (ti.tid IN (:db_condition_placeholder_0))

AND (ti.status = :db_condition_placeholder_1)

AND (ti.tid IN (:db_condition_placeholder_2));


Array (

(:db_condition_placeholder_0) => 170

(:db_condition_placeholder_1) => 1

(:db_condition_placeholder_2) => 227


As you can see the last “AND” condition should be “OR”.


Is it possible to query a node for all addresses?

For instance, can I run a query on a bitcoin node, that returns all addresses with more than 1 bitcoin on them?

co.combinatorics – A query on Galvin’s theorem for bipartite graphs

The Galvin’s theorem is the generalized version of Dinitz conjecture that states that if the maximum degree of any bipartite graph is $Delta$, then its edges are colorable properly if each of its edges is given a list of $Delta$ colors to choose from.

The proof, as I have seen, is by using the fact that there exists a kernel perfect orientation of the line graph of bipartite graph. But, I have a method as follows: We know that even cycles are chromatic edge-choosable. The bipartite graphs consist of even cycles and possible chords (matchings). As each of the even cycle can be list edge colored with a list of exactly two colors, and the chords (matchings) can be list edge colored using a list having just one color, I think a suitable greedy list edge coloring ( by assigning a list of $Delta$ colors to each edge) would solve the problem.

What is the defect in the method above? Thanks beforehand.

query – Diferents Url who load in the same template

I’m creating a online store with wordpress. Could I do this?

Example with Nodejs in the backend and pug in the frontend i can do:

An url https://anything/animals/:animal/
and load an unique template for each animal
Having this estructure in the url


Loading the description, image… from a api rest

mysql cursor not fetching data from select query inside stored procedure

I have written the following procedure but the the cursor is not displaying or inserting any data. I have ran the select query separately and it returns data properly.

I tried checking other solutions on stack overflow and dba stack exchange but the solutions are not fixing the issue.

The most close answer found was This

As advise in the answers in the above mentioned links I renamed all the variables with _ in varibalename but still it cursor doesn’t display or insert data

Any help would be appriciated.


CREATE PROCEDURE getUniquePartnerIds()


DECLARE cursor_Partnerid CURSOR FOR 
SELECT DISTINCT(partnerId) FROM multiplepartners WHERE partnerId NOT IN (SELECT partnerId FROM partner_language);

OPEN cursor_Partnerid;
get_PartnerId: LOOP
FETCH cursor_Partnerid INTO temp_partnerId;
SELECT temp_partnerId;
IF is_finished = 1 THEN LEAVE get_PartnerId;
END IF;     
-- INSERT INTO `partner_language`(`partnerid`)
-- VALUES (temp_partnerId);     
END LOOP get_PartnerId;
CLOSE cursor_Partnerid;


wp query – previous_posts_link & next_posts_link doesn’t generate any output

Hey I am using a WPQuery to loop through and show blog categories in posts. It’s in a page tempplate. has 21 posts and I want them to show 10 per page with navigation links for next pages of 10 posts but below code is not outputting that buttons

enter image description here

<div class="container-blog-post d-flex flex-wrap justify-content-start">

$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
        $args = array(
            'post_type'      => 'post',
            'category_name'  => 'blog',
            'posts_per_page' => 10,
            'orderby'        => 'date',
            'order'          => 'DESC', 
            'paged' => $paged

        $the_query = new WP_Query( $args ); ?>

        <?php if ( $the_query->have_posts() ) : ?>

            <?php while ( $the_query->have_posts() ) : $the_query->the_post(); 

                if(has_post_thumbnail()) {
                    $image = get_the_post_thumbnail_url();
                    $image = get_template_directory_uri().'/assets/images/default.svg';

                $url   = get_permalink();
                $title = get_the_title();
                $text  = excerpt(20);
                $date = get_the_date();

              <a href="<?php echo $url; ?>" class="single-post card">
                <figure class="image-wrapping">
                  <img src="<?php echo $image; ?>" alt="">
                <div class="body-post card-body">
                  <h3 class="title-post card-title"><?php echo $title; ?></h3>
                  <p class="card-text line-clamp-2"><?php echo excerpt(10); ?></p>
                  <button class="btn-read-more arrow">Read more</button>
                  <div class="button-post">
                    <span class="date-post"><?php echo $date; ?></span><span class="author-post"><?php echo the_author(); ?></span>

            <?php endwhile; ?>
            <div class="previous">
                <?php previous_posts_link(); ?>
        <div class="next">
            <?php next_posts_link(); ?>
            <?php wp_reset_postdata(); ?>
        <?php endif; ?>  


wpdb – get_results query with accent

I’m trying to do an sql query and I don’t understand something
I get a value with $ _POST, this value is equal to ‘définition’.
I made this request:
$sql = "SELECT DISTINCT * FROM". $ wpdb-> prefix. "posts WHERE post_title LIKE '%". $ _POST ('value'). "% '";

A var_dump($sql) gives "SELECT DISTINCT * FROM datatablename.posts WHERE post_title LIKE '% definition%'";

If I do
$res = $wpdb->get_results($sql);
I get an empty array

but, if in my code I put directly
$sql = "SELECT DISTINCT * FROM datatablename.posts WHERE post_title LIKE '% definition%'";
(I immediately replace $ _POST with my value),
$res is an array with a post

The problem stems from the accent, because if $_POST('value') = 'finition' it’s okay

My datatable is in utf8mb4_unicode_ci

What can be done to solve this problem ?

wp query – 3 posts from each existing category on one page

The following is not working…

<?php $categories = get_categories( array(
'orderby' => 'name',
'parent'  => 0
) ); 
foreach($categories as $category):
    $args = array(
    'cat' => $category->name,
    'posts_per_page' => 3,);
    $category_posts = new WP_Query( $args );

    if( $category_posts->have_posts() ): ?>
        <h2><?php echo $category->name; ?></h2>
        <div class="row">
        <?php  while( $category_posts->have_posts() ):
            $category_posts->the_post(); ?>
            <div class="blog-post-tile" style="background-image: url(<?php 
                echo get_the_post_thumbnail_url(get_the_ID(), 'full');?>)">
                <h3 class="blog-post-tile__title">
                    <?php the_title(); ?>
        <?php endwhile; ?>          
    <?php endif;

My goal is to display on one page 3 latest posts from all existing categories. By now this code displays for each category same posts. It reads good category names just it seems like query is not reseted and it show posts again… To be honest it works at the beginning but it looks like I changed something in the code and broke it. I can’t find solution again.

sql server – Python SQlite Query to select recently added data in the table

I am using selenium to scrape data from a website and store it in an SQLite table I want to fetch recently added rows from the table. how to do it using Python SQLite?

Example: Consider a table Contest, which is adding a certain amount of records daily. Now the table contains only 4 records and I have added that data on my website but after some time 2 more records are added to the table now I want to fetch only the recently added records. How to do it?

Here is my table

| ID |   CODE   |       Name        |    Start     |      End      |

| 1  |  XYB23Q  |    SOME NAME 1    |  2020-08-18  |  2020-10-30   |
| 2  |  A1B25C  |    SOME NAME 2    |  2020-10-12  |  2020-11-20   |

| 3  |  WYB3K5  |    SOME NAME 3    |  2020-06-18  |  2020-12-15   |

| 4  |  NYB26R  |    SOME NAME 4    |  2020-09-24  |  2021-02-24   |

Now, after some time more records would be added to the table I want to fetch those newly added records and display it on my website.

| ID  |   CODE   |       Name        |    Start     |      End      |

|  1  |  XYB23Q  |    SOME NAME 1    |  2020-08-18  |  2020-10-30   |
|  2  |  A1B25C  |    SOME NAME 2    |  2020-10-12  |  2020-11-20   |

|  3  |  WYB3K5  |    SOME NAME 3    |  2020-06-18  |  2020-12-15   |

|  4  |  NYB26R  |    SOME NAME 4    |  2020-09-24  |  2021-02-24   |
|  5  |  ABC26K  |    SOME NAME 5    |  2020-10-23  |  2021-10-31   |

|  6  |  NRBM6C  |    SOME NAME 6    |  2020-10-24  |  2020-10-27   |

I want to fetch only the last two rows from that table and add it to my website. Also once a contest ends remove it from the table.

performance – Benchmark of a query execution’s time elapsed versus the number of rows retrieved

We currently have a Financial report that does a lot of complex aggregate functions, joins around 10+ tables and runs for around 3.5 hours and retrieves around 500,000 records.
One of our clients wants this report to generate faster, but our development manager thinks that 3.5 hours is reasonable considering our current table structures.

I know a query’s performance would largely depend on the number of joins, indexes, partitions and aggregate functions, etc. But I’m curious to know if there’s a benchmark of an acceptable execution time for a certain number of rows retrieved. I remember someone stating that there’s a document about it but I’ve searched all over and couldn’t find any.

Perhaps someone here has any articles to share?

Thank you!