Тема: PHP Service
Показать сообщение отдельно
Старый 18.08.2010, 13:55
Himan вне форума Посмотреть профиль Отправить личное сообщение для Himan Найти все сообщения от Himan
  № 1  
Ответить с цитированием
Himan

Регистрация: Aug 2010
Сообщений: 11
По умолчанию PHP Service

Здравствуйте!
Я хочу разобраться с передачей данных из PHP во Flash Builder 4 Premium, потому прошу не судить меня строго. Тем более что я ламер и в том и в другом. Передачу данных используя XML вроде освоил. В билдере есть пример как организовывается связь, но там пример работы с базой MySQL, а я использую ODBC. Соответственно функции немного другие. В общем, помогите разобраться. Выкладываю ошибку, которую выдаёт билдер при тестировании данных и собственно сам скрипт. Спасибо за помощь.
Код:
InvocationTargetException:There was an error while invoking the operation. Check your operation inputs or server code and try invoking the operation again. 

Reason: An error occured while reading response sent by server. Try encoding the response suitably before sending it. e.g. If a database column contains UTF-8 characters then use utf8_encode() to encode its value before returning it from the operation.
PHP код:
<?php

  
class PaysNew{
    var 
$connection;

    public function 
__construct(){
      
$this->connection odbc_connect('Data_Server''username''password');
      
$this->throwExceptionOnError($this->connection);
    }

    public function 
getAllItems() {
      
$sql="SELECT * from table1";
      
$result odbc_exec($connection$sql);
      
$this->throwExceptionOnError($this->connection);
      
$rows = array();
      
$x=1;
      while(
odbc_fetch_row($result)){
        
$rows[$x][1]=odbc_result($result'spos');
        
$rows[$x][2]=odbc_result($result'summa');
        
$x++;
      }
      
odbc_close($connection);
      return 
$rows;
    }

    private function 
throwExceptionOnError($link null) {
    if(
$link == null) {
      
$link $this->connection;
    }
        if(
odbc_error($link)) {
      
$msg odbc_error($link) . ": " odbc_errormsg($link);
            throw new 
Exception('DB Error - '$msg);
        }
    }
  }

?>