get_table_name() . ' ( ' . $columns_sql . ' ) ' . $this->get_charset_collate(); return $this->modify_table( $sql, $this->get_table_name() ); } /** * Get lasso url detail object by product id and product_type * * @param string $product_id Product id. * @param string $product_type Product type. Default is amazon. */ public static function get_by_product_id_and_type( $product_id, $product_type = Amazon_Api::PRODUCT_TYPE ) { if ( ! $product_id ) { return null; } $sql = ' SELECT lud.* FROM ' . self::get_wp_table_name( 'posts' ) . ' AS wpp LEFT JOIN ' . ( new self() )->get_table_name() . ' AS lud ON wpp.id = lud.lasso_id WHERE wpp.post_type = %s AND lud.product_id = %s AND lud.product_type = %s AND wpp.post_status = "publish" '; $prepare = self::prepare( $sql, Constant::LASSO_POST_TYPE, $product_id, $product_type ); // phpcs:ignore $result = self::get_row( $prepare ); if ( $result ) { return ( new self() )->map_properties( $result ); } return null; } }