sql >> Databasteknik >  >> RDS >> Mysql

Hur sparas kategorier och underkategorier för WooCommerce i DB?

function getParentCategories() {
    global $wpdb;
    $sql = "SELECT term_id as id, name, slug FROM wp_terms where term_id in (SELECT term_id FROM wp_term_taxonomy where parent = 0 and taxonomy = 'category') order by name asc";
    $parents = $wpdb->get_results( $sql );
    return $parents;
}

function getChildCategories($id) {
    global $wpdb;
    $sql = "SELECT term_id as id, name, slug FROM wp_terms where term_id in (SELECT term_id FROM wp_term_taxonomy where parent = $id and taxonomy = 'category')  order by name asc";
    $children = $wpdb->get_results( $sql );
    return $children;
}


  1. Initiering av en MySQL-databas distribuerad i en AWS EKS

  2. SQL Server Internals:Plan Caching Pt. I – Återanvändning av planer

  3. HikariCP Postgresql Driver hävdar att de inte accepterar JDBC URL

  4. Hur anropar man Oracle MD5 hash-funktion?