Skip to content

EM_Booking#get() - wrong table usage #1

@XedinUnknown

Description

@XedinUnknown

The Problem

When using EM_Booking#get(), an SQL error is thrown.

Possible Cause

get() tries to retrieve the table name from $wpdb:

$sql = "SELECT * FROM ". $wpdb->EM_BOOKINGS_TABLE ." WHERE " . implode(' AND ', $conds);

That results in a query like the following:

SELECT * FROM  WHERE 1

That's because there's no such thing as $wpdb->EM_BOOKINGS_TABLE.

Suggested Solution

Use constants, the same way as everywhere else in the plugin:

$sql = "SELECT * FROM ". EM_BOOKINGS_TABLE ." WHERE " . implode(' AND ', $conds);

Remarks

I am aware that this repo has not been updated in a long time. However, the problem still presents on 5.9.x: see trac.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions