Hi,
I've extended the API to get list of states. My function is as below and giving empty results. Any idea what went wrong?
namespace Tygh\Api\Entities;use Tygh\Api\AEntity;
use Tygh\Api\Response;
use Tygh\Registry;class State extends AEntity
{
public function index($id)
{
list($data) = fn_cm_get_state($id);if (!empty($data) || empty($id)) { $status = Response::STATUS_OK; } else { $status = Response::STATUS_NOT_FOUND; } return array( 'status' => $status, 'data' => $data, 'country_id' => $id ); }
…
function fn_cm_get_state($country_id) { $states = array(); if (!empty($country_id)) { $states = db_get_array("SELECT a.state_id, a.country_code, a.code, a.status, b.state, c.country FROM ?:cscart_states as a LEFT JOIN cscart_state_descriptions as b ON ( b.state_id = a.state_id AND b.lang_code = 'en' ) LEFT JOIN cscart_country_descriptions as c ON ( c.code = a.country_code AND c.lang_code = 'en' ) WHERE 1 AND a.country_code = ?s ORDER BY c.country ASC, b.state ASC", $country_id); } return $states; }