Creating an Angular factory from custom database table

Guess I should have read the error page more carefully, because it contained the answer in plain English. In the factory request is should simply match the request to the response signature (an array in my case), thus becoming: angular.module(“app”).controller(“MainController”, [“$scope”, “commentRepository”, function ($scope, commentRepository) { commentRepository.query(function(data) { $scope.comments = data; }); }]); Instead of … Read more

Get last element from wpdb as a string

Okay, I figured it out: global $wpdb; $par_order = $reservation->transaction_id; $store = wp_get_current_user(); $store_id = $store->ID; $sql = “SELECT ID FROM $wpdb->posts WHERE post_type=”shop_order” AND post_parent = $par_order AND post_author = $store_id”; $sub_orders = $wpdb->get_var($wpdb->prepare($sql,$seller_id)); thank you @czerspalace for the clue

Getting record from three wpdb tables

You don’t want to ask wpdb for each field. This is the wrapper for SQL queries Like so (not tested): <?php $my_results = $wpdb->get_results( SELECT posts.post_author, dopbsp_calendars.user_id, dopbsp_reservations.price_total, dopbsp_reservations.check_in, dopbsp_reservations.check_out, dopbsp_reservations.start_hour, dopbsp_reservations.end_hour, dopbsp_calendars.id, posts.post_title, posts.ID As ID1, posts.post_parent, dopbsp_reservations.transaction_id FROM wp_posts INNER JOIN posts.post_author ON dopbsp_calendars.user_id dopbsp_calendars ON wp_posts.post_author = dopbsp_calendars.user_id, dopbsp_reservations ); Then see … Read more

Create a stored procedure on plugin activation

As an example, let’s say you were planning on the following stored procedure: SELECT * FROM wp_posts Instead of actually stashing this inside MySQL, let’s create a PHP function: function {plugin_prefix}_get_posts() { global $wpdb; return $wpdb->get_results( “SELECT * FROM $wpdb->posts” ); } Now we can call this whenever we need it: $posts = {plugin_prefix}_get_posts(); // … Read more

wont add form details to database or send me mail

/** * Since the install of WP-Mail-SMTP we need to make sure the FROM is the same as the one specified in the plugin * These filters will overwrite any FROM send by other plugins. */ add_filter(‘wp_mail_from’,’custom_wp_mail_from’); function custom_wp_mail_from($email) { return get_option(‘mail_from’); } add_filter(‘wp_mail_from_name’,’custom_wp_mail_from_name’); function custom_wp_mail_from_name($name) { return get_option(‘mail_from_name’); } Might be this will help … Read more

Combine posts and postmeta

$args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_query’ => array( array( ‘key’ => ‘name_of_field_with_featured_as_value’, ‘value’ => ‘featured’, ‘compare’ => ‘=’, ), ), ); $query = new WP_Query($args); if($query->have_posts()) : //usual loop code but with $query as above, note that post related functions are called as usual, e.g. simply the_title(), not $query->the_title() endif;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)