sqlite – can't check if table is empty and insert data sqlite3 PHP-ThrowExceptions

Exception or error:

I have a problem with checking if the table has rows or not in sqlite3 and PHP

$pa = "dbs/".$id.".sqlite";
$sql = "SELECT `id`,`product_id`,`quantity` AS `quantity`  FROM basket  WHERE `product_id` ='".$storeid."'   GROUP BY product_id LIMIT 1 ";
        $version = $dbnn->query($sql);
if ($version->numColumns() && $version->columnType(0) != SQLITE3_NULL) {
                while ($row= $version->fetchArray(SQLITE3_ASSOC)) 
                    echo "<br>".$row['quantity']." ".$row['id'];

                $allquant = $quantityfromdb + $count;
                $sqlitedatabase->query('UPDATE `basket` SET `quantity`="'.$allquant.'" WHERE `id`="'.$ide.'"');


                $sqlitedatabase->query('INSERT INTO `basket`(`id`, `product_id`, `quantity`) VALUES (NULL,"'.$storeid.'","'.$count.'")');

I tried this but still inserting one by one not concatenated the quantity number

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *