继续获取Array到字符串转换通知,但代码工作正常

时间:2016-08-02 06:03:07

标签: php

我有以下脚本从表中删除所选项目。

<?php 
    class deleteNews extends Generic 
    {
        private $error;
        private $news_id_delete;

        function __construct() 
        {
            if (empty($_POST['deleteCheck'])) {
                echo '<div class="alert alert-danger" role="alert"> <strong>Erro!</strong> Nenhuma notícia foi selecionada! </div>';
            }

            if(isset($_POST['deleteCheck'])) {
                $this->news_id_delete = parent::secure($_POST['deleteCheck']);

                $params = array(
                    ':news_id_delete'       => $this->news_id_delete,
                );

                foreach($this->news_id_delete as $delete) {
                    $sql = "DELETE FROM `login_news` WHERE `news_id` = $delete;";
                    parent::query($sql, $params);
                }

                echo '<div class="alert alert-success" role="alert"> <strong>Sucesso!</strong> Sua notícia foi publicada! </div>';

           }
       }
    }

    if (isset($_POST['deleteBtn'])) {   
        $addUser = new deleteNews();                
    }    
?>

它工作正常,问题是每次执行时,都会返回以下注意事项:

  

注意:数组转换为字符串

我怎样才能摆脱这个通知?

1 个答案:

答案 0 :(得分:1)

中删除 -(void) receivedArray:(NSNotification*)notification { NSMutableArray* userInfo = notification.object; UIImage *image = [userInfo firstObject]; //[_imagearray addObject:[userInfo firstObject]]; if(image){ [_imagearray insertObject:image atIndex:0]; // it will insert element at 0 index and will show first place in collection view NSLog(@"%@",_imagearray); [self.collection reloadData]; _collection.delegate=self; _collection.dataSource=self; NSLog(@"%@",_imagearray); } }
$params

因为我认为您的查询已完成,并且不需要在sql语句中插入任何额外的参数,因为要删除的ID已在查询中传递。

parent::query($sql, $params);

同样$sql = "DELETE FROM `login_news` WHERE `news_id` = $delete;" 是一个数组数组,这就是你从查询函数

中得到这个错误的原因