1: <?php
2:
3: namespace Yajra\Oci8\Query;
4:
5: use Illuminate\Database\ConnectionInterface;
6: use Illuminate\Database\Query\Builder;
7: use Yajra\Oci8\Query\Grammars\OracleGrammar;
8: use Yajra\Oci8\Query\Processors\OracleProcessor;
9:
10: class OracleBuilder extends Builder
11: {
12: 13: 14: 15: 16:
17: protected $grammar;
18:
19: 20: 21: 22: 23:
24: protected $processor;
25:
26: 27: 28: 29: 30:
31: public function __construct(
32: ConnectionInterface $connection,
33: OracleGrammar $grammar,
34: OracleProcessor $processor
35: ) {
36: parent::__construct($connection, $grammar, $processor);
37: }
38:
39: 40: 41: 42: 43: 44: 45: 46:
47: public function insertLob(array $values, array $binaries, $sequence = 'id')
48: {
49: $sql = $this->grammar->compileInsertLob($this, $values, $binaries, $sequence);
50:
51: $values = $this->cleanBindings($values);
52: $binaries = $this->cleanBindings($binaries);
53:
54: return $this->processor->saveLob($this, $sql, $values, $binaries);
55: }
56:
57: 58: 59: 60: 61: 62: 63: 64:
65: public function updateLob(array $values, array $binaries, $sequence = 'id')
66: {
67: $bindings = array_values(array_merge($values, $this->getBindings()));
68:
69: $sql = $this->grammar->compileUpdateLob($this, $values, $binaries, $sequence);
70:
71: $values = $this->cleanBindings($bindings);
72: $binaries = $this->cleanBindings($binaries);
73:
74: return $this->processor->saveLob($this, $sql, $values, $binaries);
75: }
76:
77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87:
88: public function whereIn($column, $values, $boolean = 'and', $not = false)
89: {
90: $type = $not ? 'NotIn' : 'In';
91:
92: if (count($values) > 1000) {
93: $chunks = array_chunk($values, 1000);
94:
95: return $this->where(function ($query) use ($column, $chunks, $type) {
96: $firstIteration = true;
97: foreach ($chunks as $ch) {
98: $sqlClause = $firstIteration ? 'where' . $type : 'orWhere' . $type;
99: $query->$sqlClause($column, $ch);
100: $firstIteration = false;
101: }
102:
103: }, null, null, $boolean);
104: }
105:
106: return parent::whereIn($column, $values, $boolean, $not);
107: }
108:
109: 110: 111: 112: 113:
114: protected function runSelect()
115: {
116: if ($this->lock) {
117: $this->connection->beginTransaction();
118: $result = $this->connection->select($this->toSql(), $this->getBindings(), ! $this->useWritePdo);
119: $this->connection->commit();
120:
121: return $result;
122: }
123:
124: return $this->connection->select($this->toSql(), $this->getBindings(), ! $this->useWritePdo);
125: }
126: }
127: