ci4
1<?php
2
3declare(strict_types=1);
4
5/**
6* This file is part of CodeIgniter 4 framework.
7*
8* (c) CodeIgniter Foundation <admin@codeigniter.com>
9*
10* For the full copyright and license information, please view
11* the LICENSE file that was distributed with this source code.
12*/
13
14namespace CodeIgniter\Database;
15
16use Stringable;
17
18/**
19* @see \CodeIgniter\Database\RawSqlTest
20*/
21class RawSql implements Stringable
22{
23/**
24* @var string Raw SQL string
25*/
26private string $string;
27
28public function __construct(string $sqlString)
29{
30$this->string = $sqlString;
31}
32
33public function __toString(): string
34{
35return $this->string;
36}
37
38/**
39* Create new instance with new SQL string
40*/
41public function with(string $newSqlString): self
42{
43$new = clone $this;
44$new->string = $newSqlString;
45
46return $new;
47}
48
49/**
50* Returns unique id for binding key
51*/
52public function getBindingKey(): string
53{
54return 'RawSql' . spl_object_id($this);
55}
56}
57