show ) ) { $response = '{ "code": 1, "response" : "Error: get.shot: You must specify the show parameter." }'; } else { $sql = "SELECT a.`asset_id` FROM `assets` a, `asset_types` at WHERE at.`type_name` = 'show' AND at.`type_id` = a.`type_id` AND a.`asset_name` = '" . $options->show . "'"; $result = $db->query( $sql ); if ( PEAR::isError( $result ) ) { $response = '{ "code": 1, "response": "' . $result->getMessage() . '" }'; } else if ( $result->numRows() == 0 ) { $response = '{ "code": 1, "response": "We didn\'t find a show called ' . $options->show . ' in the database." }'; } else { $row = $result->fetchRow(); $show_id = $row["asset_id"]; $sql = "SELECT a.`asset_id`, a.`asset_name` FROM `assets` a, `asset_types` at WHERE at.`type_name` = 'shot' AND at.`type_id` = a.`type_id` AND a.`parent_id` = $show_id"; $shot_result = $db->query( $sql ); if ( PEAR::isError( $result ) ) { $response = '{ "code": 1, "response" : "' . $result->getMessage() . '" }'; } else { $shots_list = array(); while ( $shot_row = $shot_result->fetchRow() ) { $shot_obj = array( "id" => $shot_row["asset_id"], "name" => $shot_row["asset_name"], "attrs" => array() ); $sql = "SELECT `attr_key`, `attr_val` FROM `attrs` WHERE `asset_id` = " . $shot_row["asset_id"]; $attr_result = $db->query( $sql ); while ( $attr_row = $attr_result->fetchRow() ) { $shot_obj["attrs"][$attr_row["attr_key"]] = $attr_row["attr_val"]; } $shots_list[] = $shot_obj; } $response = '{ "code": 0, "response" : ' . json_encode( $shots_list ) . ' }'; } } } ?>