Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试将日期插入MySQL时出现Flex服务调用问题_Php_Mysql_Apache Flex_Datetime_Flash Builder - Fatal编程技术网

Php 尝试将日期插入MySQL时出现Flex服务调用问题

Php 尝试将日期插入MySQL时出现Flex服务调用问题,php,mysql,apache-flex,datetime,flash-builder,Php,Mysql,Apache Flex,Datetime,Flash Builder,我正在尝试为录音室构建一个CRUD应用程序,使我们的客户能够在线预订会话。我有我的数据库设置,我正在使用flash builder 4.6创建一个服务调用,创建一个studio会话并将信息发布到数据库。我可以很好地将数据从MySQL拉到datagrid,但是当我使用CreateSessions服务时,我得到了一个错误,我似乎无法理解….>>>访问php脚本第123行中未定义的属性Session_Date。它还说,我正试图将一个非对象传递给我的Session_Date->toString('YYY

我正在尝试为录音室构建一个CRUD应用程序,使我们的客户能够在线预订会话。我有我的数据库设置,我正在使用flash builder 4.6创建一个服务调用,创建一个studio会话并将信息发布到数据库。我可以很好地将数据从MySQL拉到datagrid,但是当我使用CreateSessions服务时,我得到了一个错误,我似乎无法理解….>>>访问php脚本第123行中未定义的属性Session_Date。它还说,我正试图将一个非对象传递给我的Session_Date->toString('YYYY-MM-DD hh:MM:ss')。为什么会发生这种情况,请有人帮忙!!!!!我搜索了论坛,但找不到直接的答案

以下是我的PHP类:

class SessionsService {

var $username = "root";
var $password = "bossman1";
var $server = "localhost";
var $port = "3306";
var $databasename = "mydb";
var $tablename = "sessions";

var $connection;

/**
 * The constructor initializes the connection to database. Everytime a request is 
 * received by Zend AMF, an instance of the service class is created and then the
 * requested method is invoked.
 */
public function __construct() {
    $this->connection = mysqli_connect(
                            $this->server,  
                            $this->username,  
                            $this->password, 
                            $this->databasename,
                            $this->port
                        );

    $this->throwExceptionOnError($this->connection);
}

/**
 * Returns all the rows from the table.
 *
 * Add authroization or any logical checks for secure access to your data 
 *
 * @return array
 */
public function getAllSessions() {

    $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename");        
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    $rows = array();

    mysqli_stmt_bind_result($stmt, $row->Sessions_ID, $row->Session_Date, $row->Session_Time, $row->Requested_Engineer, $row->Time_In, $row->Time_Out);

    while (mysqli_stmt_fetch($stmt)) {
      $row->Session_Date = new DateTime($row->Session_Date);
      $rows[] = $row;
      $row = new stdClass();
      mysqli_stmt_bind_result($stmt, $row->Sessions_ID, $row->Session_Date, $row->Session_Time, $row->Requested_Engineer, $row->Time_In, $row->Time_Out);
    }

    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);

    return $rows;
}

/**
 * Returns the item corresponding to the value specified for the primary key.
 *
 * Add authorization or any logical checks for secure access to your data 
 *
 * 
 * @return stdClass
 */
public function getSessionsByID($itemID) {

    $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where Sessions_ID=?");
    $this->throwExceptionOnError();

    mysqli_stmt_bind_param($stmt, 'i', $itemID);        
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    mysqli_stmt_bind_result($stmt, $row->Sessions_ID, $row->Session_Date, $row->Session_Time, $row->Requested_Engineer, $row->Time_In, $row->Time_Out);

    if(mysqli_stmt_fetch($stmt)) {
      $row->Session_Date = new DateTime($row->Session_Date);
      return $row;
    } else {
      return null;
    }
}

/**
 * Returns the item corresponding to the value specified for the primary key.
 *
 * Add authorization or any logical checks for secure access to your data 
 *
 * 
 * @return stdClass
 */
public function createSessions($item) {

    $stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (Session_Date, Session_Time, Requested_Engineer, Time_In, Time_Out) VALUES (?, ?, ?, ?, ?)");
    $this->throwExceptionOnError();

    mysqli_stmt_bind_param($stmt, 'sssss', $item->Session_Date->toString('YYYY-MM-dd HH:mm:ss'), $item->Session_Time, $item->Requested_Engineer, $item->Time_In, $item->Time_Out);
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);     
    $this->throwExceptionOnError();

    $autoid = mysqli_stmt_insert_id($stmt);

    mysqli_stmt_free_result($stmt);     
    mysqli_close($this->connection);

    return $autoid;
}

/**
 * Updates the passed item in the table.
 *
 * Add authorization or any logical checks for secure access to your data 
 *
 * @param stdClass $item
 * @return void
 */
public function updateSessions($item) {

    $stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET Session_Date=?, Session_Time=?, Requested_Engineer=?, Time_In=?, Time_Out=? WHERE Sessions_ID=?");       
    $this->throwExceptionOnError();

    if ($item->Session_Date == null)
        $Session_Date = null;
    else
        $Session_Date = $item->Session_Date->toString('yyyy-MM-dd HH:mm:ss');



    mysqli_stmt_bind_param($stmt, 'sssssi', $item->Session_Date->toString('YYYY-MM-dd HH:mm:ss'), $item->Session_Time, $item->Requested_Engineer, $item->Time_In, $item->Time_Out, $item->Sessions_ID);     
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);     
    $this->throwExceptionOnError();

    mysqli_stmt_free_result($stmt);     
    mysqli_close($this->connection);
}

/**
 * Deletes the item corresponding to the passed primary key value from 
 * the table.
 *
 * Add authorization or any logical checks for secure access to your data 
 *
 * 
 * @return void
 */
public function deleteSessions($itemID) {

    $stmt = mysqli_prepare($this->connection, "DELETE FROM $this->tablename WHERE Sessions_ID = ?");
    $this->throwExceptionOnError();

    mysqli_stmt_bind_param($stmt, 'i', $itemID);
    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    mysqli_stmt_free_result($stmt);     
    mysqli_close($this->connection);
}


/**
 * Returns the number of rows in the table.
 *
 * Add authorization or any logical checks for secure access to your data 
 *
 * 
 */
public function count() {
    $stmt = mysqli_prepare($this->connection, "SELECT COUNT(*) AS COUNT FROM $this->tablename");
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    mysqli_stmt_bind_result($stmt, $rec_count);
    $this->throwExceptionOnError();

    mysqli_stmt_fetch($stmt);
    $this->throwExceptionOnError();

    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);

    return $rec_count;
}


/**
 * Returns $numItems rows starting from the $startIndex row from the 
 * table.
 *
 * Add authorization or any logical checks for secure access to your data 
 *
 * 
 * 
 * @return array
 */
public function getSessions_paged($startIndex, $numItems) {

    $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename LIMIT ?, ?");
    $this->throwExceptionOnError();

    mysqli_stmt_bind_param($stmt, 'ii', $startIndex, $numItems);
    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    $rows = array();

    mysqli_stmt_bind_result($stmt, $row->Sessions_ID, $row->Session_Date, $row->Session_Time, $row->Requested_Engineer, $row->Time_In, $row->Time_Out);

    while (mysqli_stmt_fetch($stmt)) {
      $row->Session_Date = new DateTime($row->Session_Date);
      $rows[] = $row;
      $row = new stdClass();
      mysqli_stmt_bind_result($stmt, $row->Sessions_ID, $row->Session_Date, $row->Session_Time, $row->Requested_Engineer, $row->Time_In, $row->Time_Out);
    }

    mysqli_stmt_free_result($stmt);     
    mysqli_close($this->connection);

    return $rows;
}


/**
 * Utility function to throw an exception if an error occurs 
 * while running a mysql command.
 */
private function throwExceptionOnError($link = null) {
    if($link == null) {
        $link = $this->connection;
    }
    if(mysqli_error($link)) {
        $msg = mysqli_errno($link) . ": " . mysqli_error($link);
        throw new Exception('MySQL Error - '. $msg);
    }       
}
}

?>
下面是错误消息:

Reason: ( ! ) SCREAM: Error suppression ignored for ( ! ) Notice: Trying to get property of non-object in C:\wamp\www\Server_Test_Project\services\SessionsService1.php on line 123 Call Stack
Time Memory Function Location

1 0.0008 699024 {main}( ) ..\gateway.php:0 2 0.0465 2709608 Zend_Amf_Server->handle( ) ..\gateway.php:69 3 0.0539 3053728 Zend_Amf_Server->_handle( ) ..\Server.php:629 4 0.0592 3247600 Zend_Amf_Server->_dispatch( ) ..\Server.php:553 5 0.0636 3411240 Zend_Server_Reflection_Method->invokeArgs( ) ..\Server.php:359 6 0.0636 3411656 Zend_Server_Reflection_Function_Abstract->__call( ) ..\Server.php:359 7 0.0636 3412072 call_user_func_array( ) ..\Abstract.php:380 8 0.0636 3412552 SessionsService1->createSessions( ) ..\Abstract.php:0

( ! ) SCREAM: Error suppression ignored for ( ! ) Fatal error: Call to a member function toString() on a non-object in C:\wamp\www\Server_Test_Project\services\SessionsService1.php on line 123 Call Stack
Time Memory Function Location

1 0.0008 699024 {main}( ) ..\gateway.php:0 2 0.0465 2709608 Zend_Amf_Server->handle( ) ..\gateway.php:69 3 0.0539 3053728 Zend_Amf_Server->_handle( ) ..\Server.php:629 4 0.0592 3247600 Zend_Amf_Server->_dispatch( ) ..\Server.php:553 5 0.0636 3411240 Zend_Server_Reflection_Method->invokeArgs( ) ..\Server.php:359 6 0.0636 3411656 Zend_Server_Reflection_Function_Abstract->__call( ) ..\Server.php:359 7 0.0636 3412072 call_user_func_array( ) ..\Abstract.php:380 8 0.0636 3412552 SessionsService1->createSessions( ) ..\Abstract.php:0 

要解决这个问题,请打开PHPINI并进行更改

error_reporting = E_ALL 
它可能会在声明中对E_严格要求。Zend没有严格遵守:)

祝你好运

刚刚发现在php 5.4中,默认情况下启用了e_strict,因此错误报告应如下所示:
error\u reporting=E\u ALL&~E\u STRICT

如果您可以编辑您的问题,添加一些您有问题的代码,那么每个人都可以更好地帮助您。我已经发布了我的代码,有人可以看一下并帮我一下吗!!!。。。。谢谢