2020-03-02 16:14:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ZM\DB;
|
|
|
|
|
|
|
|
|
|
|
2020-04-29 15:29:56 +08:00
|
|
|
use ZM\Exception\DbException;
|
|
|
|
|
|
2021-07-09 01:38:30 +08:00
|
|
|
/**
|
|
|
|
|
* Class InsertBody
|
|
|
|
|
* @package ZM\DB
|
|
|
|
|
* @deprecated This will delete in 2.6 or future version, use \ZM\MySQL\MySQLManager::getConnection() instead
|
|
|
|
|
*/
|
2020-03-02 16:14:20 +08:00
|
|
|
class InsertBody
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var Table
|
|
|
|
|
*/
|
|
|
|
|
private $table;
|
|
|
|
|
private $row;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* InsertBody constructor.
|
|
|
|
|
* @param Table $table
|
|
|
|
|
* @param $row
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(Table $table, $row) {
|
|
|
|
|
$this->table = $table;
|
|
|
|
|
$this->row = $row;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 15:29:56 +08:00
|
|
|
/**
|
|
|
|
|
* @throws DbException
|
|
|
|
|
*/
|
2020-03-02 16:14:20 +08:00
|
|
|
public function save() {
|
2021-02-09 17:09:09 +08:00
|
|
|
DB::rawQuery('INSERT INTO ' . $this->table->getTableName() . ' VALUES (' . implode(',', array_fill(0, count($this->row), '?')) . ')', $this->row);
|
2020-03-02 16:14:20 +08:00
|
|
|
}
|
2020-04-26 15:01:18 +08:00
|
|
|
}
|