Por mas que lo he revisado no encuentro el problema
Este es la definicion de la tabla y el código desde donde se monta la query
email_list_subscribers
Código:
Columna Tipo Nulo Predeterminado
subscriberid int(11) No*
listid int(11) No* 0*
emailaddress varchar(200) Sí* NULL*
domainname varchar(100) Sí* NULL*
format char(1) Sí* NULL*
confirmed char(1) Sí* 0*
confirmcode varchar(32) Sí* NULL*
requestdate int(11) Sí* 0*
requestip varchar(20) Sí* NULL*
confirmdate int(11) Sí* 0*
confirmip varchar(20) Sí* NULL*
subscribedate int(11) Sí* 0*
bounced int(11) Sí* 0*
unsubscribed int(11) Sí* 0*
unsubscribeconfirmed char(1) Sí* 0*
formid int(11) Sí* 0*
Código PHP:
function GetSubscribersFromSegment($segmentIDs, $countonly = false, $queuedetails = null, $sortdetails = array())
{
$return = array('count' => 0, 'subscriberlist' => 0, 'lists' => array());
if (empty($sortdetails)) {
$sortdetails = array('SortBy' => 'emailaddress', 'Direction' => 'asc', 'Max' => 100);
}
require_once(dirname(__FILE__) . '/segment.php');
$count = 0;
$lists = array();
$selectQueries = array();
foreach ($segmentIDs as $id) {
$segmentAPI = new Segment_API();
// Cannot load segment
$status = $segmentAPI->Load($id);
if (!$status) {
return array();
}
// Get lists that are used in this segment
$tempLists = $segmentAPI->GetMailingListUsed();
$lists = array_merge($lists, $tempLists);
// Get count
$count += $segmentAPI->GetSubscribersCount(0, true);
// Get query
$tempQuery = $segmentAPI->GetSubscribersQueryString(true);
$selectQueries[] = preg_replace('/^SELECT .*? FROM?/i', '', $tempQuery);
}
unset($segmentAPI);
checksize($count, (isset($sortdetails['Max'])? $sortdetails['Max'] : 100), $countonly);
$return['count'] = $count;
$return['lists'] = $lists;
if (empty($selectQueries)) {
return array();
}
if ($countonly) {
return $return;
}
if (empty($queuedetails)) {
$temp = 'SELECT DISTINCT subscribers.subscriberid AS subscriberid FROM ';
$selectQuery = $temp . implode(" UNION {$temp}", $selectQueries);
} else {
$queueID = intval($queuedetails['queueid']);
$queueType = $this->Db->Quote($queuedetails['queuetype']);
$queueOwnerID = intval($queuedetails['ownerid']);
$temp = "SELECT DISTINCT {$queueID}, '{$queueType}', {$queueOwnerID}, subscribers.subscriberid, 0 FROM ";
$selectQuery = 'INSERT INTO [|PREFIX|]queues (queueid, queuetype, ownerid, recipient, processed)';
$selectQuery .= $temp . implode(" UNION {$temp}", $selectQueries);
}
setmax($sortdetails, $selectQuery);
$selectQuery = preg_replace('/l.subscribedate/', 'subscribers.subscribedate', $selectQuery);
$search_result = $this->Db->Query($selectQuery);
if (!$search_result) {
trigger_error(__CLASS__ . '::' . __METHOD__ . " -- Unable to query database with the following query string: {$selectQuery}", E_USER_NOTICE);
return array();
}
if (!empty($queuedetails)) {
return array();
}
$subscriber_results = array();
while ($row = $this->Db->Fetch($search_result)) {
$subscriber_results[] = $row;
}
$return['subscriberlist'] = $subscriber_results;
return $return;
}