I run this SQL in my PHP script:
$sql = "SELECT u.id AS id, ul.meta_value AS lastpaymentdate, rd.meta_value AS noemails
FROM wp_users u
LEFT JOIN wp_usermeta rd ON rd.user_id=u.id AND rd.meta_key='noemails'
LEFT JOIN wp_usermeta ul ON ul.user_id=u.id AND ul.meta_key='lastpaymentdate'
WHERE u.user_email = 'testemail@domain.com'";
$rs = $db->Execute($sql);
Here is the data that it would output if I ran it in a SQL console:
+------+-----------------+----------+
| id | lastpaymentdate | noemails |
+------+-----------------+----------+
2523 2013-10-30 0
I need to get the lastpaymentdate (2013-10-30) into the array $lastRenewalDateParts.
What I've come up with is:
$lastRenewalDateParts = explode('-', $rs->data[0][1]);
However, its not working properly. It's giving me an empty array. Where could I be going wrong?
EDIT: Here is the result of print_r($rs):
mysqli_driver_ResultSet Object
(
[connectionId] => mysqli Object
(
[affected_rows] => 1
[client_info] => 5.5.30
[client_version] => 50530
[connect_errno] => 0
[connect_error] =>
[errno] => 0
[error] =>
[field_count] => 3
[host_info] => Localhost via UNIX socket
[info] =>
[insert_id] => 0
[server_info] => 5.5.38-35.2
[server_version] => 50538
[stat] => Uptime: 2030485 Threads: 19 Questions: 2452324326 Slow queries: 6246 Opens: 22784920 Flush tables: 1 Open tables: 16800 Queries per second avg: 1207.752
[sqlstate] => 00000
[protocol_version] => 10
[thread_id] => 44573449
[warning_count] => 0
)
[fields] => Array
(
[id] => 2523
[lastpaymentdate] => 2013-10-30
[noemails] => 0
)
[resultId] => mysqli_result Object
(
[current_field] => 0
[field_count] => 3
[lengths] => Array
(
[0] => 4
[1] => 10
[2] => 1
)
[num_rows] => 1
[type] => 0
)
[_currentRow] => 0
[_numOfRows] => 1
[_numOfFields] => 3
[fetchMode] => 1
[EOF] =>
[record] => Array
(
)
)
I went about accessing the data incorrectly. My original attempt was coming up empty:
echo $rs->data[0][1];
The correct way to access the date field:
echo $rs->fields[lastpaymentdate];
Thank you Jay!