/** * @dataProvider provider_match_all */ public function test_match_all($regexp, $string, $result) { $this->assertEquals(Core_Regexps::match_all($regexp, $string), $result); }
/** * Формирует общий список значений параметров с учетом значений параметров родительских мапперов * * @param string $expr * @param mixed $parms * * @return DB_ORM_SQLMapper */ protected function collect_binds($expr, $parms) { $adapter = $this->connection->adapter; if ($adapter->is_castable_parameter($parms)) { $parms = $adapter->cast_parameter($parms); } if ($match = Core_Regexps::match_all('{(?::([a-zA-Z_0-9]+))}', $expr)) { foreach ($match[1] as $no => $name) { if (Core_Types::is_array($parms) || $parms instanceof ArrayAccess) { $this->binds[$name] = $adapter->cast_parameter(isset($parms[$name]) ? $parms[$name] : $parms[$no]); } elseif (is_object($parms)) { $this->binds[$name] = $adapter->cast_parameter($parms->{$name}); } else { $this->binds[$name] = $adapter->cast_parameter($parms); } } } return $this; }
/** * Возвращает сформированный запрос SQL * * @uses DB::PLACEHOLDER_REGEXP * * @return string */ public function pure_sql() { $sql = $this->sql; if ($match = Core_Regexps::match_all('{(?:' . DB::PLACEHOLDER_REGEXP . ')}', $sql)) { foreach ($match[1] as $no => $name) { $sql = str_replace(":{$name}", "'" . $this->binds[$no] . "'", $sql); } } return $sql; }