NukeViet\Core\Database::insert_id PHP Метод

insert_id() публичный Метод

Insert a row into the database return primary key column
public insert_id ( $_sql, string $column = '', array $data = [] ) : integer | false
$column string The name of the primary key column
$data array
Результат integer | false
    public function insert_id($_sql, $column = '', $data = array())
    {
        try {
            if ($this->dbtype == 'oci') {
                $_sql .= ' RETURNING ' . $column . ' INTO :primary_key';
            }
            $stmt = $this->prepare($_sql);
            if (!empty($data)) {
                foreach (array_keys($data) as $key) {
                    $stmt->bindParam(':' . $key, $data[$key], PDO::PARAM_STR, strlen($data[$key]));
                }
            }
            if ($this->dbtype == 'oci') {
                $stmt->bindParam(':primary_key', $primary_key, PDO::PARAM_INT, 11);
            }
            $stmt->execute();
            if ($this->dbtype == 'oci') {
                return $primary_key;
            } else {
                return $this->lastInsertId();
            }
        } catch (PDOException $e) {
            trigger_error($e->getMessage());
        }
        return false;
    }