From 0a906cd4578667c92eaf06e98a7b943d8779487f Mon Sep 17 00:00:00 2001 From: Rudi Servo Date: Tue, 12 Sep 2023 17:26:51 +0000 Subject: [PATCH 01/57] Annotations emptyString was not working --- CHANGELOG-5.0.md | 7 ++++++- phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index 0951bdb9c5c..e3be7feee90 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -1,5 +1,11 @@ # Changelog +## [5.4.0](https://github.com/phalcon/cphalcon/releases/tag/v5.3.1) (xxxx-xx-xx) + +### Fixed +- Model Annotation strategy did not work with empty_string [#16426] (https://github.com/phalcon/cphalcon/issues/16426) + + ## [5.3.1](https://github.com/phalcon/cphalcon/releases/tag/v5.3.1) (2023-09-12) ### Fixed @@ -7,7 +13,6 @@ - Fixed undefined column with columnMap and model caching [#16420](https://github.com/phalcon/cphalcon/issues/16420) - Fixed memory leak in `Phalcon\Mvc\Router::handle()` [#16431](https://github.com/phalcon/cphalcon/pull/16431) - ## [5.3.0](https://github.com/phalcon/cphalcon/releases/tag/v5.3.0) (2023-08-15) ### Added diff --git a/phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep b/phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep index ea526fe7018..c8aca5ccd52 100644 --- a/phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep +++ b/phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep @@ -364,7 +364,7 @@ class Annotations implements StrategyInterface * Allow empty strings for column */ if columnAnnotation->getNamedParameter("allow_empty_string") { - let emptyStringValues[] = columnName; + let emptyStringValues[columnName] = columnName; } /** From b4b88aced258c944914cbe5adeae14898e9987d2 Mon Sep 17 00:00:00 2001 From: Rudi Servo Date: Mon, 25 Sep 2023 14:52:53 +0000 Subject: [PATCH 02/57] View::reset() sets content to null instead of emptry string --- CHANGELOG-5.0.md | 1 + phalcon/Mvc/View.zep | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index e3be7feee90..396b66383eb 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -4,6 +4,7 @@ ### Fixed - Model Annotation strategy did not work with empty_string [#16426] (https://github.com/phalcon/cphalcon/issues/16426) +- View::reset() sets content to null instead of default empty string [#16437] (https://github.com/phalcon/cphalcon/issues/16437) ## [5.3.1](https://github.com/phalcon/cphalcon/releases/tag/v5.3.1) (2023-09-12) diff --git a/phalcon/Mvc/View.zep b/phalcon/Mvc/View.zep index ca633b81e04..95b0e5fd3c7 100644 --- a/phalcon/Mvc/View.zep +++ b/phalcon/Mvc/View.zep @@ -768,7 +768,7 @@ class View extends Injectable implements ViewInterface, EventsAwareInterface let this->disabled = false, this->engines = false, this->renderLevel = self::LEVEL_MAIN_LAYOUT, - this->content = null, + this->content = "", this->templatesBefore = [], this->templatesAfter = []; From 48942c89094af15f73f56231f06c5b4c21f477a4 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Wed, 13 Sep 2023 07:42:59 -0500 Subject: [PATCH 03/57] minor cs --- phalcon/Mvc/View.zep | 1 + 1 file changed, 1 insertion(+) diff --git a/phalcon/Mvc/View.zep b/phalcon/Mvc/View.zep index 95b0e5fd3c7..ef882e87d2a 100644 --- a/phalcon/Mvc/View.zep +++ b/phalcon/Mvc/View.zep @@ -1127,6 +1127,7 @@ class View extends Injectable implements ViewInterface, EventsAwareInterface return strlen(path) >= 1 && path[0] == '/'; } + /** * Loads registered template engines, if none is registered it will use * Phalcon\Mvc\View\Engine\Php From 441af4eb6257747d227c7027e6ccc7641066b6db Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Wed, 13 Sep 2023 07:45:58 -0500 Subject: [PATCH 04/57] correcting docblock for isBetween --- phalcon/Support/HelperFactory.zep | 50 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/phalcon/Support/HelperFactory.zep b/phalcon/Support/HelperFactory.zep index 86b4b67414b..d50eca28db4 100644 --- a/phalcon/Support/HelperFactory.zep +++ b/phalcon/Support/HelperFactory.zep @@ -15,62 +15,62 @@ use Phalcon\Factory\AbstractFactory; /** * ServiceLocator implementation for helpers * - * @method array blacklist(array $collection, array $blackList) - * @method array chunk(array $collection, int $size, bool $preserveKeys = false) - * @method mixed first(array $collection, callable $method = null) - * @method mixed firstKey(array $collection, callable $method = null) - * @method array flatten(array $collection, bool $deep = false) - * @method mixed get(array $collection, $index, $defaultValue = null, string $cast = null) - * @method array group(array $collection, $method) - * @method bool has(array $collection, $index) - * @method bool isUnique(array $collection) - * @method mixed last(array $collection, callable $method = null) - * @method mixed lastKey(array $collection, callable $method = null) - * @method array order(array $collection, $attribute, string $order = 'asc') - * @method array pluck(array $collection, string $element) - * @method array set(array $collection, $value, $index = null) - * @method array sliceLeft(array $collection, int $elements = 1) - * @method array sliceRight(array $collection, int $elements = 1) - * @method array split(array $collection) - * @method object toObject(array $collection) - * @method bool validateAll(array $collection, callable $method) - * @method bool validateAny(array $collection, callable $method) - * @method array whitelist(array $collection, array $whiteList) * @method string basename(string $uri, string $suffix = null) - * @method string decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) - * @method string encode($data, int $options = 0, int $depth = 512) - * @method bool between(int $value, int $start, int $end) + * @method array blacklist(array $collection, array $blackList) * @method string camelize(string $text, string $delimiters = null, bool $lowerFirst = false) + * @method array chunk(array $collection, int $size, bool $preserveKeys = false) * @method string concat(string $delimiter, string $first, string $second, string ...$arguments) * @method int countVowels(string $text) * @method string decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8') + * @method string decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) * @method string decrement(string $text, string $separator = '_') * @method string dirFromFile(string $file) * @method string dirSeparator(string $directory) + * @method string encode($data, int $options = 0, int $depth = 512) * @method bool endsWith(string $haystack, string $needle, bool $ignoreCase = true) + * @method mixed first(array $collection, callable $method = null) * @method string firstBetween(string $text, string $start, string $end) + * @method mixed firstKey(array $collection, callable $method = null) * @method string friendly(string $text, string $separator = '-', bool $lowercase = true, $replace = null) + * @method array flatten(array $collection, bool $deep = false) + * @method mixed get(array $collection, $index, $defaultValue = null, string $cast = null) + * @method array group(array $collection, $method) + * @method bool has(array $collection, $index) * @method string humanize(string $text) * @method bool includes(string $haystack, string $needle) * @method string increment(string $text, string $separator = '_') * @method bool isAnagram(string $first, string $second) + * @method bool isBetween(int $value, int $start, int $end) * @method bool isLower(string $text, string $encoding = 'UTF-8') * @method bool isPalindrome(string $text) + * @method bool isUnique(array $collection) * @method bool isUpper(string $text, string $encoding = 'UTF-8') * @method string kebabCase(string $text, string $delimiters = null) + * @method mixed last(array $collection, callable $method = null) + * @method mixed lastKey(array $collection, callable $method = null) * @method int len(string $text, string $encoding = 'UTF-8') * @method string lower(string $text, string $encoding = 'UTF-8') + * @method array order(array $collection, $attribute, string $order = 'asc') * @method string pascalCase(string $text, string $delimiters = null) + * @method array pluck(array $collection, string $element) * @method string prefix($text, string $prefix) * @method string random(int $type = 0, int $length = 8) * @method string reduceSlashes(string $text) - * @method bool startsWith(string $haystack, string $needle, bool $ignoreCase = true) + * @method array set(array $collection, $value, $index = null) + * @method array sliceLeft(array $collection, int $elements = 1) + * @method array sliceRight(array $collection, int $elements = 1) * @method string snakeCase(string $text, string $delimiters = null) + * @method array split(array $collection) + * @method bool startsWith(string $haystack, string $needle, bool $ignoreCase = true) * @method string suffix($text, string $suffix) + * @method object toObject(array $collection) + * @method bool validateAll(array $collection, callable $method) + * @method bool validateAny(array $collection, callable $method) * @method string ucwords(string $text, string $encoding = 'UTF-8') * @method string uncamelize(string $text, string $delimiters = '_') * @method string underscore(string $text) * @method string upper(string $text, string $encoding = 'UTF-8') + * @method array whitelist(array $collection, array $whiteList) */ class HelperFactory extends AbstractFactory { From 509eb7fab1cd11a40a449fdcef1c19d9eb2deaff Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 28 Sep 2023 19:06:05 -0500 Subject: [PATCH 05/57] refactoring and corrections to the File validators --- .../Filter/Validation/AbstractValidator.zep | 280 +++++++++++------- .../Validator/File/AbstractFile.zep | 234 +++++++++------ .../Validation/Validator/File/Size/Equal.zep | 64 ++-- .../Validation/Validator/File/Size/Max.zep | 82 ++--- .../Validation/Validator/File/Size/Min.zep | 82 ++--- .../Filter/Validation/ValidatorInterface.zep | 52 ++-- 6 files changed, 418 insertions(+), 376 deletions(-) diff --git a/phalcon/Filter/Validation/AbstractValidator.zep b/phalcon/Filter/Validation/AbstractValidator.zep index 83990007af6..bba82e6b82c 100644 --- a/phalcon/Filter/Validation/AbstractValidator.zep +++ b/phalcon/Filter/Validation/AbstractValidator.zep @@ -10,9 +10,9 @@ namespace Phalcon\Filter\Validation; -use Phalcon\Support\Helper\Arr\Whitelist; use Phalcon\Messages\Message; use Phalcon\Filter\Validation; +use Phalcon\Support\Helper\Arr\Whitelist; /** * This is a base class for validators @@ -20,17 +20,17 @@ use Phalcon\Filter\Validation; abstract class AbstractValidator implements ValidatorInterface { /** - * Message template - * - * @var string|null - */ + * Message template + * + * @var string|null + */ protected template = null; /** - * Message templates - * - * @var array - */ + * Message templates + * + * @var array + */ protected templates = []; /** @@ -40,8 +40,10 @@ abstract class AbstractValidator implements ValidatorInterface /** * Phalcon\Filter\Validation\Validator constructor + * + * @param array $options */ - public function __construct(array! options = []) + public function __construct(array options = []) { var template, whitelist; @@ -65,13 +67,56 @@ abstract class AbstractValidator implements ValidatorInterface let this->options = options; } + /** + * Returns an option in the validator's options + * Returns null if the option hasn't set + * + * @param string $key + * @param mixed|null $defaultValue + * + * @return mixed + */ + public function getOption(string! key, var defaultValue = null) -> var + { + var value, fieldValue; + + if !fetch value, this->options[key] { + return defaultValue; + } + + /* + * If we have `attribute` as a key, it means it is a Uniqueness + * validator, we can have here multiple fields, so we need to check it + */ + if key == "attribute" && typeof value == "array" { + if fetch fieldValue, value[key] { + return fieldValue; + } + } + + return value; + } + + /** + * Checks if an option is defined + * + * @param string $key + * + * @return bool + */ + public function hasOption(string! key) -> bool + { + return isset this->options[key]; + } + /** * Get the template message * + * @param string|null $field + * * @return string - * @throw InvalidArgumentException When the field does not exists */ - public function getTemplate(string! field = null) -> string + public function getTemplate(string field = null) -> string { // there is a template in field if field !== null && isset this->templates[field] { @@ -98,31 +143,60 @@ abstract class AbstractValidator implements ValidatorInterface } /** - * Clear current templates and set new from an array, - * - * @return ValidatorInterface - */ - public function setTemplates(array! templates) -> + * Create a default message by factory + * + * @param Validation $validation + * @param array|string $field + * @param array $replacements + * + * @return Message + */ + public function messageFactory( validation, var field, array! replacements = []) -> { - var field, template; - - let this->templates = []; + var singleField; - for field, template in templates { - let field = (string) field, - template = (string) template, - this->templates[field] = template; + if typeof field == "array" { + let singleField = implode(", ", field); + } elseif typeof field == "string" { + let singleField = field; + } else { + throw new Exception("The field can not be printed"); } - return this; + let replacements = array_merge( + [ + ":field" : this->prepareLabel(validation, singleField) + ], + replacements + ); + + return new Message( + strtr(this->getTemplate(singleField), replacements), + field, + get_class(this), + this->prepareCode(singleField) + ); } /** - * Set a new template message - * - * @return ValidatorInterface - */ - public function setTemplate(string! template) -> + * Sets an option in the validator + * + * @param string $key + * @param mixed $value + * + * @return void + */ + public function setOption(string! key, value) -> void + { + let this->options[key] = value; + } + + /** + * Set a new template message + * + * @return ValidatorInterface + */ + public function setTemplate(string template) -> { let this->template = template; @@ -130,55 +204,87 @@ abstract class AbstractValidator implements ValidatorInterface } /** - * Returns an option in the validator's options - * Returns null if the option hasn't set + * Clear current templates and set new from an array, + * + * @return ValidatorInterface */ - public function getOption(string! key, var defaultValue = null) -> var + public function setTemplates(array templates) -> { - var value, fieldValue; + var field, template; - if !fetch value, this->options[key] { - return defaultValue; - } + let this->templates = []; - /* - * If we have attribute it means it's Uniqueness validator, we - * can have here multiple fields, so we need to check it - */ - if key == "attribute" && typeof value == "array" { - if fetch fieldValue, value[key] { - return fieldValue; - } + for field, template in templates { + let field = (string) field, + template = (string) template, + this->templates[field] = template; } - return value; + return this; } /** - * Checks if an option is defined + * Executes the validation + * + * @param Validation $validation + * @param string $field + * + * @return bool */ - public function hasOption(string! key) -> bool - { - return isset this->options[key]; - } + abstract public function validate( + validation, + var field + ) -> bool; /** - * Sets an option in the validator + * Checks if field can be empty. + * + * @param string $field + * @param mixed $value + * + * @return bool */ - public function setOption(string! key, value) -> void + protected function allowEmpty(var field, var value) -> bool { - let this->options[key] = value; + var allowEmpty; + + let allowEmpty = this->getOption("allowEmpty", false); + + if typeof allowEmpty === "array" { + let allowEmpty = isset allowEmpty[field] ? allowEmpty[field] : false; + } + + return allowEmpty && empty value; } /** - * Executes the validation + * Checks if a value is an array and returns the element based on the + * passed field name + * + * @param mixed $value + * @param string $field + * + * @return mixed */ - abstract public function validate( validation, var field) -> bool; + protected function checkArray(var value, string field) -> var + { + if ( + typeof value === "array" && isset value[field] + ) { + let value = value[field]; + } + + return value; + } /** * Prepares a validation code. + * + * @param string $field + * + * @return int */ - protected function prepareCode(string! field) -> int + protected function prepareCode(string field) -> int { var code; @@ -193,6 +299,11 @@ abstract class AbstractValidator implements ValidatorInterface /** * Prepares a label for the field. + * + * @param Validation $validation + * @param string $field + * + * @return mixed */ protected function prepareLabel( validation, string! field) -> var { @@ -210,59 +321,4 @@ abstract class AbstractValidator implements ValidatorInterface return label; } - - /** - * Checks if field can be empty. - * - * @param mixed field - * @param mixed value - * - * @return bool - */ - protected function allowEmpty(var field, var value) -> bool - { - var allowEmpty; - - let allowEmpty = this->getOption("allowEmpty", false); - - if typeof allowEmpty === "array" { - let allowEmpty = isset allowEmpty[field] ? allowEmpty[field] : false; - } - - return allowEmpty && empty value; - } - - /** - * Create a default message by factory - * - * @return Message - * - * @throw Exception - */ - public function messageFactory( validation, var field, array! replacements = []) -> - { - var singleField; - - if typeof field == "array" { - let singleField = implode(", ", field); - } elseif typeof field == "string" { - let singleField = field; - } else { - throw new Exception("The field can not be printed"); - } - - let replacements = array_merge( - [ - ":field" : this->prepareLabel(validation, singleField) - ], - replacements - ); - - return new Message( - strtr(this->getTemplate(singleField), replacements), - field, - get_class(this), - this->prepareCode(singleField) - ); - } } diff --git a/phalcon/Filter/Validation/Validator/File/AbstractFile.zep b/phalcon/Filter/Validation/Validator/File/AbstractFile.zep index ab0ba2dd5c5..65381c446ec 100644 --- a/phalcon/Filter/Validation/Validator/File/AbstractFile.zep +++ b/phalcon/Filter/Validation/Validator/File/AbstractFile.zep @@ -10,9 +10,9 @@ namespace Phalcon\Filter\Validation\Validator\File; -use Phalcon\Messages\Message; use Phalcon\Filter\Validation; use Phalcon\Filter\Validation\AbstractValidator; +use Phalcon\Messages\Message; /** * Checks if a value has a correct file @@ -77,42 +77,51 @@ abstract class AbstractFile extends AbstractValidator protected messageValid = "Field :field is not valid"; /** - * Check upload - * - * @param Validation $validation - * @param mixed $field - * @return bool - */ - public function checkUpload( validation, var field) -> bool + * Check upload + * + * @param Validation $validation + * @param string $field + * + * @return bool + * @throws Validation\Exception + */ + public function checkUpload( validation, string field) -> bool { return this->checkUploadMaxSize(validation, field) && - this->checkUploadIsEmpty(validation, field) && - this->checkUploadIsValid(validation, field); + this->checkUploadIsEmpty(validation, field) && + this->checkUploadIsValid(validation, field); } /** - * Check if upload is empty - * - * @param Validation $validation - * @param mixed $field - * @return boolean - */ - public function checkUploadIsEmpty( validation, var field) -> bool - { + * Check if upload is empty + * + * @param Validation $validation + * @param string $field + * + * @return bool + * @throws Validation\Exception + */ + public function checkUploadIsEmpty( + validation, + string field + ) -> bool { var label, replacePairs, value; let value = validation->getValue(field); if ( - !isset value["error"] || - !isset value["tmp_name"] || - value["error"] !== UPLOAD_ERR_OK || - !this->checkIsUploadedFile(value["tmp_name"]) + is_array(value) && + ( + true !== isset(value["error"]) || + true !== isset(value["tmp_name"]) || + value["error"] !== UPLOAD_ERR_OK || + true !== this->checkIsUploadedFile(value["tmp_name"]) + ) ) { - let label = this->prepareLabel(validation, field), - replacePairs = [ - ":field": label - ]; + let label = this->prepareLabel(validation, field); + let replacePairs = [ + ":field" : label + ]; validation->appendMessage( new Message( @@ -130,23 +139,34 @@ abstract class AbstractFile extends AbstractValidator } /** - * Check if upload is valid - * - * @param Validation $validation - * @param mixed $field - * @return boolean - */ - public function checkUploadIsValid( validation, var field) -> bool - { + * Check if upload is valid + * + * @param Validation $validation + * @param string $field + * + * @return bool + * @throws Validation\Exception + */ + public function checkUploadIsValid( + validation, + string field + ) -> bool { var label, replacePairs, value; let value = validation->getValue(field); - if !isset value["name"] || !isset value["type"] || !isset value["size"] { - let label = this->prepareLabel(validation, field), - replacePairs = [ - ":field": label - ]; + if ( + is_array(value) && + ( + true !== isset(value["name"]) || + true !== isset(value["type"]) || + true !== isset(value["size"]) + ) + ) { + let label = this->prepareLabel(validation, field); + let replacePairs = [ + ":field" : label + ]; validation->appendMessage( new Message( @@ -164,29 +184,57 @@ abstract class AbstractFile extends AbstractValidator } /** - * Check if uploaded file is larger than PHP allowed size - * - * @param Validation $validation - * @param mixed $field - * @return boolean - */ - public function checkUploadMaxSize( validation, var field) -> bool - { - var label, replacePairs, value; - - let value = validation->getValue(field); + * Check if uploaded file is larger than PHP allowed size + * + * @param Validation $validation + * @param string $field + * + * @return bool + * @throws Validation\Exception + */ + public function checkUploadMaxSize( + validation, + string field + ) -> bool { + var files, label, length, method, post, replacePairs, server, value; + + let value = validation->getValue(field); + let server = []; + let post = []; + let files = []; + let method = "GET"; + let length = 0; + + if _SERVER { + let server = _SERVER; + } + if _POST { + let post = _POST; + } + if _FILES { + let files = _FILES; + } + if isset(server["REQUEST_METHOD"]) { + let method = server["REQUEST_METHOD"]; + } + if isset(server["CONTENT_LENGTH"]) { + let length = server["CONTENT_LENGTH"]; + } // Upload is larger than PHP allowed size (post_max_size or upload_max_filesize) - if _SERVER["REQUEST_METHOD"] == "POST" && - empty _POST && - empty _FILES && - _SERVER["CONTENT_LENGTH"] > 0 || - isset value["error"] && value["error"] === UPLOAD_ERR_INI_SIZE - { - let label = this->prepareLabel(validation, field), - replacePairs = [ - ":field": label - ]; + if ( + "POST" === method && + true === empty(post) && + true === empty(files) && + (int)length > 0 || + is_array(value) && + true === isset(value["error"]) && + value["error"] === UPLOAD_ERR_INI_SIZE + ) { + let label = this->prepareLabel(validation, field); + let replacePairs = [ + ":field" : label + ]; validation->appendMessage( new Message( @@ -204,32 +252,39 @@ abstract class AbstractFile extends AbstractValidator } /** - * Convert a string like "2.5MB" in bytes - * - * @param string $size - * @return float - */ - public function getFileSizeInBytes(string! size) -> float + * Convert a string like "2.5MB" in bytes + * + * @param string $size + * + * @return float + */ + public function getFileSizeInBytes(string size) -> float { - var byteUnits = [ - "B": 0, - "K": 10, - "M": 20, - "G": 30, - "T": 40, - "KB": 10, - "MB": 20, - "GB": 30, - "TB": 40 - ], unit = "B", matches = null; + var byteUnits, matches, unit; + + let byteUnits = [ + "B" : 0, + "K" : 10, + "M" : 20, + "G" : 30, + "T" : 40, + "KB" : 10, + "MB" : 20, + "GB" : 30, + "TB" : 40 + ]; + let unit = "B"; + let matches = []; preg_match( - "/^([0-9]+(?:\\.[0-9]+)?)(" . implode("|", array_keys(byteUnits)) . ")?$/Di", + "/^([0-9]+(?:\\.[0-9]+)?)(" + . implode("|", array_keys(byteUnits)) + . ")?/Di", size, matches ); - if isset matches[2] { + if (true === isset(matches[2])) { let unit = matches[2]; } @@ -270,14 +325,21 @@ abstract class AbstractFile extends AbstractValidator * Check on empty * * @param Validation $validation - * @param string $field + * @param string $field + * * @return bool + * @throws Validation\Exception */ - public function isAllowEmpty( validation, string! field) -> bool + public function isAllowEmpty( validation, string field) -> bool { - var value = validation->getValue(field); + var value; - return empty value || isset value["error"] && value["error"] === UPLOAD_ERR_NO_FILE; + let value = validation->getValue(field); + + return true === empty(value) || + is_array(value) && + true === isset(value["error"]) && + value["error"] === UPLOAD_ERR_NO_FILE; } /** @@ -318,7 +380,11 @@ abstract class AbstractFile extends AbstractValidator /** * Checks if a file has been uploaded; Internal check that can be - * overriden in a subclass if you do not want to check uploaded files + * overridden in a subclass if you do not want to check uploaded files + * + * @param string $name + * + * @return bool */ protected function checkIsUploadedFile(string name) -> bool { diff --git a/phalcon/Filter/Validation/Validator/File/Size/Equal.zep b/phalcon/Filter/Validation/Validator/File/Size/Equal.zep index 47a8ed5685e..033630c5e5c 100644 --- a/phalcon/Filter/Validation/Validator/File/Size/Equal.zep +++ b/phalcon/Filter/Validation/Validator/File/Size/Equal.zep @@ -10,7 +10,6 @@ namespace Phalcon\Filter\Validation\Validator\File\Size; -use Phalcon\Messages\Message; use Phalcon\Filter\Validation; use Phalcon\Filter\Validation\Validator\File\AbstractFile; @@ -60,47 +59,43 @@ use Phalcon\Filter\Validation\Validator\File\AbstractFile; */ class Equal extends AbstractFile { - protected template = "File :field does not have the exact :size file size"; - /** - * Constructor - * - * @param array options = [ - * 'message' => '', - * 'template' => '', - * 'size' => '2.5MB' - * ] + * @var string|null */ - public function __construct(array! options = []) - { - parent::__construct(options); - } + protected template = "File :field does not have the exact :size file size"; /** * Executes the validation + * + * @param Validation $validation + * @param string $field + * + * @return bool + * @throws Validation\Exception */ - public function validate( validation, var field) -> bool + public function validate( validation, string field) -> bool { - var bytes, fileSize, replacePairs, size, value; + var bytes, included, fileSize, replacePairs, size, value; // Check file upload - if this->checkUpload(validation, field) === false { + if (true !== this->checkUpload(validation, field)) { return false; } - let value = validation->getValue(field), - size = this->getOption("size"); + let value = validation->getValue(field); + let size = this->checkArray(this->getOption("size"), field); - if typeof size == "array" { - let size = size[field]; - } + let bytes = round(this->getFileSizeInBytes(size), 6); + let fileSize = round(floatval(value["size"]), 6); - let bytes = round(this->getFileSizeInBytes(size), 6), - fileSize = round(floatval(value["size"]), 6); + let included = (bool)this->checkArray( + this->getOption("included", false), + field + ); - if bytes !== fileSize { + if (true === this->getConditional(bytes, fileSize, included)) { let replacePairs = [ - ":size" : size + ":size" : size ]; validation->appendMessage( @@ -112,4 +107,21 @@ class Equal extends AbstractFile return true; } + + /** + * Executes the conditional + * + * @param float $source + * @param float $target + * @param bool $included + * + * @return bool + */ + protected function getConditional( + float source, + float target, + bool included = false + ) { + return included === false && source !== target; + } } diff --git a/phalcon/Filter/Validation/Validator/File/Size/Max.zep b/phalcon/Filter/Validation/Validator/File/Size/Max.zep index 410184c3180..28983104df7 100644 --- a/phalcon/Filter/Validation/Validator/File/Size/Max.zep +++ b/phalcon/Filter/Validation/Validator/File/Size/Max.zep @@ -10,10 +10,6 @@ namespace Phalcon\Filter\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Filter\Validation; -use Phalcon\Filter\Validation\Validator\File\AbstractFile; - /** * Checks if a value has a correct file * @@ -58,73 +54,31 @@ use Phalcon\Filter\Validation\Validator\File\AbstractFile; * ); * ``` */ -class Max extends AbstractFile +class Max extends Equal { - protected template = "File :field exceeds the size of :size"; - /** - * Constructor - * - * @param array options = [ - * 'message' => '', - * 'template' => '', - * 'size' => '2.5MB', - * 'included' => false - * ] + * @var string|null */ - public function __construct(array! options = []) - { - parent::__construct(options); - } + protected template = "File :field exceeds the size of :size"; /** - * Executes the validation + * Executes the conditional + * + * @param float $source + * @param float $target + * @param bool $included + * + * @return bool */ - public function validate( validation, var field) -> bool - { - var bytes, fileSize, included = false, replacePairs, result, size, value; - - // Check file upload - if this->checkUpload(validation, field) === false { - return false; - } - - let value = validation->getValue(field), - size = this->getOption("size"); - - if typeof size == "array" { - let size = size[field]; - } - - let bytes = round(this->getFileSizeInBytes(size), 6), - fileSize = round(floatval(value["size"]), 6); - - let included = this->getOption("included"); - - if typeof included == "array" { - let included = (bool) included[field]; - } else { - let included = (bool) included; - } - - if included { - let result = fileSize >= bytes; - } else { - let result = fileSize > bytes; - } - - if result { - let replacePairs = [ - ":size" : size - ]; - - validation->appendMessage( - this->messageFactory(validation, field, replacePairs) - ); - - return false; + protected function getConditional( + float source, + float target, + bool included = false + ) { + if (included === true) { + return target >= source; } - return true; + return target > source; } } diff --git a/phalcon/Filter/Validation/Validator/File/Size/Min.zep b/phalcon/Filter/Validation/Validator/File/Size/Min.zep index ca3d33c50cc..48bb46d2a60 100644 --- a/phalcon/Filter/Validation/Validator/File/Size/Min.zep +++ b/phalcon/Filter/Validation/Validator/File/Size/Min.zep @@ -10,10 +10,6 @@ namespace Phalcon\Filter\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Filter\Validation; -use Phalcon\Filter\Validation\Validator\File\AbstractFile; - /** * Checks if a value has a correct file * @@ -58,73 +54,31 @@ use Phalcon\Filter\Validation\Validator\File\AbstractFile; * ); * ``` */ -class Min extends AbstractFile +class Min extends Equal { - protected template = "File :field can not have the minimum size of :size"; - /** - * Constructor - * - * @param array options = [ - * 'message' => '', - * 'template' => '', - * 'size' => '2.5MB', - * 'included' => false - * ] + * @var string|null */ - public function __construct(array! options = []) - { - parent::__construct(options); - } + protected template = "File :field can not have the minimum size of :size"; /** - * Executes the validation + * Executes the conditional + * + * @param float $source + * @param float $target + * @param bool $included + * + * @return bool */ - public function validate( validation, var field) -> bool - { - var bytes, fileSize, included = false, replacePairs, result, size, value; - - // Check file upload - if this->checkUpload(validation, field) === false { - return false; - } - - let value = validation->getValue(field), - size = this->getOption("size"); - - if typeof size == "array" { - let size = size[field]; - } - - let bytes = round(this->getFileSizeInBytes(size), 6), - fileSize = round(floatval(value["size"]), 6); - - let included = this->getOption("included"); - - if typeof included == "array" { - let included = (bool) included[field]; - } else { - let included = (bool) included; - } - - if included { - let result = fileSize >= bytes; - } else { - let result = fileSize > bytes; - } - - if result { - let replacePairs = [ - ":size" : size - ]; - - validation->appendMessage( - this->messageFactory(validation, field, replacePairs) - ); - - return false; + protected function getConditional( + float source, + float target, + bool included = false + ) { + if (included === true) { + return target <= source; } - return true; + return target < source; } } diff --git a/phalcon/Filter/Validation/ValidatorInterface.zep b/phalcon/Filter/Validation/ValidatorInterface.zep index 22c3a5431de..ab6cff7a64a 100644 --- a/phalcon/Filter/Validation/ValidatorInterface.zep +++ b/phalcon/Filter/Validation/ValidatorInterface.zep @@ -26,45 +26,45 @@ interface ValidatorInterface public function getOption(string! key, var defaultValue = null) -> var; /** - * Checks if an option is defined + * Get the template message * - * @return boolean + * @return string + * @throw InvalidArgumentException When the field does not exists */ - public function hasOption(string! key) -> bool; + public function getTemplate(string! field) -> string; /** - * Executes the validation + * Get message templates * - * @return boolean + * @return array */ - public function validate( validation, var field) -> bool; + public function getTemplates() -> array; /** - * Get the template message - * - * @return string - * @throw InvalidArgumentException When the field does not exists - */ - public function getTemplate(string! field) -> string; + * Checks if an option is defined + * + * @return boolean + */ + public function hasOption(string! key) -> bool; /** - * Get message templates - * - * @return array - */ - public function getTemplates() -> array; + * Set a new template message + * + * @return ValidatorInterface + */ + public function setTemplate(string! template) -> ; /** - * Clear current template and set new from an array, - * - * @return ValidatorInterface - */ + * Clear current template and set new from an array, + * + * @return ValidatorInterface + */ public function setTemplates(array! templates) -> ; /** - * Set a new template message - * - * @return ValidatorInterface - */ - public function setTemplate(string! template) -> ; + * Executes the validation + * + * @return boolean + */ + public function validate( validation, var field) -> bool; } From 9f16e4371dd3f7d67a817e10ceb10277cf55d645 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 28 Sep 2023 19:06:19 -0500 Subject: [PATCH 06/57] alignment with phalcon and more tests for validators --- .../Filter/Validation/AllowEmptyCest.php | 8 +- .../Filter/Validation/AppendMessageCest.php | 46 +++- .../Filter/Validation/GetLabelCest.php | 35 --- .../Filter/Validation/GetMessagesCest.php | 33 ++- .../Filter/Validation/GetSetLabelCest.php | 64 +++++ .../Filter/Validation/GetValueByDataCest.php | 4 +- .../Validation/GetValueByEntityCest.php | 6 +- .../Filter/Validation/SetLabelsCest.php | 35 --- .../Filter/Validation/ValidateCest.php | 13 - .../Validator/Alnum/ConstructCest.php | 38 --- .../Validator/Alnum/GetOptionCest.php | 41 --- .../Validator/Alnum/HasOptionCest.php | 42 ---- .../Validator/Alnum/SetOptionCest.php | 38 --- .../Validator/Alnum/ValidateCest.php | 2 +- .../Validator/Alpha/ConstructCest.php | 41 --- .../Validator/Alpha/GetOptionCest.php | 41 --- .../Validator/Alpha/HasOptionCest.php | 45 ---- .../Validator/Alpha/SetOptionCest.php | 41 --- .../Validator/Alpha/ValidateCest.php | 2 +- .../Validator/Between/ConstructCest.php | 41 --- .../Validator/Between/GetOptionCest.php | 41 --- .../Validator/Between/HasOptionCest.php | 42 ---- .../Validator/Between/SetOptionCest.php | 41 --- .../Validator/Between/ValidateCest.php | 2 +- .../Validator/Callback/ConstructCest.php | 41 --- .../Validator/Callback/GetOptionCest.php | 41 --- .../Validator/Callback/HasOptionCest.php | 42 ---- .../Validator/Callback/SetOptionCest.php | 41 --- .../Validator/Confirmation/ConstructCest.php | 41 --- .../Validator/Confirmation/GetOptionCest.php | 41 --- .../Validator/Confirmation/HasOptionCest.php | 42 ---- .../Validator/Confirmation/SetOptionCest.php | 41 --- .../Validation/Validator/ConstructCest.php | 52 ++-- .../Validator/CreditCard/ConstructCest.php | 41 --- .../Validator/CreditCard/GetOptionCest.php | 41 --- .../Validator/CreditCard/HasOptionCest.php | 45 ---- .../Validator/CreditCard/SetOptionCest.php | 41 --- .../Validator/CreditCard/ValidateCest.php | 2 +- .../Validator/Date/ConstructCest.php | 41 --- .../Validator/Date/GetOptionCest.php | 41 --- .../Validator/Date/HasOptionCest.php | 45 ---- .../Validator/Date/SetOptionCest.php | 41 --- .../Validator/Date/ValidateCest.php | 2 +- .../Validator/Digit/ConstructCest.php | 41 --- .../Validator/Digit/GetOptionCest.php | 41 --- .../Validator/Digit/HasOptionCest.php | 45 ---- .../Validator/Digit/SetOptionCest.php | 41 --- .../Validator/Digit/ValidateCest.php | 21 +- .../Validator/Email/ConstructCest.php | 41 --- .../Validator/Email/GetOptionCest.php | 41 --- .../Validator/Email/HasOptionCest.php | 45 ---- .../Validator/Email/SetOptionCest.php | 41 --- .../Validator/Email/ValidateCest.php | 2 +- .../Validator/ExclusionIn/ConstructCest.php | 41 --- .../Validator/ExclusionIn/GetOptionCest.php | 41 --- .../Validator/ExclusionIn/HasOptionCest.php | 45 ---- .../Validator/ExclusionIn/SetOptionCest.php | 41 --- .../Validator/ExclusionIn/ValidateCest.php | 7 +- .../Validator/File/ConstructCest.php | 41 --- .../Validator/File/CustomMessagesCest.php | 32 ++- .../Validator/File/GetOptionCest.php | 41 --- .../Validator/File/HasOptionCest.php | 45 ---- .../Validator/File/SetOptionCest.php | 41 --- .../Validator/File/Size/ValidateCest.php | 235 ++++++++++++++++++ .../Validator/GetSetHasOptionCest.php | 173 +++++++++++++ .../Validator/Identical/ConstructCest.php | 41 --- .../Validator/Identical/GetOptionCest.php | 41 --- .../Validator/Identical/HasOptionCest.php | 45 ---- .../Validator/Identical/SetOptionCest.php | 41 --- .../Validator/Identical/ValidateCest.php | 2 +- .../Validator/InclusionIn/ConstructCest.php | 41 --- .../Validator/InclusionIn/GetOptionCest.php | 41 --- .../Validator/InclusionIn/HasOptionCest.php | 45 ---- .../Validator/InclusionIn/SetOptionCest.php | 41 --- .../Validation/Validator/Ip/ConstructCest.php | 41 --- .../Validation/Validator/Ip/GetOptionCest.php | 41 --- .../Validation/Validator/Ip/HasOptionCest.php | 45 ---- .../Validation/Validator/Ip/SetOptionCest.php | 41 --- .../Validation/Validator/Ip/ValidateCest.php | 2 +- .../Validator/Numericality/ConstructCest.php | 41 --- .../Validator/Numericality/GetOptionCest.php | 41 --- .../Validator/Numericality/HasOptionCest.php | 45 ---- .../Validator/Numericality/SetOptionCest.php | 41 --- .../Validator/Numericality/ValidateCest.php | 2 +- .../Validator/PresenceOf/ConstructCest.php | 38 --- .../Validator/PresenceOf/GetOptionCest.php | 41 --- .../Validator/PresenceOf/HasOptionCest.php | 42 ---- .../Validator/PresenceOf/SetOptionCest.php | 41 --- .../Validator/PresenceOf/ValidateCest.php | 13 +- .../Validator/Regex/ConstructCest.php | 41 --- .../Validator/Regex/GetOptionCest.php | 41 --- .../Validator/Regex/HasOptionCest.php | 45 ---- .../Validator/Regex/SetOptionCest.php | 41 --- .../Validator/Regex/ValidateCest.php | 2 +- .../Validator/StringLength/ConstructCest.php | 48 ---- .../Validator/StringLength/GetOptionCest.php | 41 --- .../Validator/StringLength/HasOptionCest.php | 45 ---- .../StringLength/Max/ConstructCest.php | 38 --- .../StringLength/Max/GetOptionCest.php | 43 ---- .../StringLength/Max/HasOptionCest.php | 38 --- .../StringLength/Max/SetOptionCest.php | 38 --- .../StringLength/Max/ValidateCest.php | 2 +- .../StringLength/Min/ConstructCest.php | 38 --- .../StringLength/Min/GetOptionCest.php | 43 ---- .../StringLength/Min/HasOptionCest.php | 38 --- .../StringLength/Min/SetOptionCest.php | 38 --- .../StringLength/Min/ValidateCest.php | 2 +- .../Validator/StringLength/SetOptionCest.php | 41 --- .../Validator/Url/ConstructCest.php | 41 --- .../Validator/Url/GetOptionCest.php | 41 --- .../Validator/Url/HasOptionCest.php | 45 ---- .../Validator/Url/SetOptionCest.php | 41 --- .../Validation/Validator/Url/ValidateCest.php | 2 +- 113 files changed, 632 insertions(+), 3660 deletions(-) delete mode 100644 tests/integration/Filter/Validation/GetLabelCest.php create mode 100644 tests/integration/Filter/Validation/GetSetLabelCest.php delete mode 100644 tests/integration/Filter/Validation/SetLabelsCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alnum/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alnum/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alnum/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alnum/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alpha/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alpha/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alpha/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Alpha/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Between/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Between/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Between/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Between/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Callback/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Callback/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Callback/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Callback/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Confirmation/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Confirmation/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Confirmation/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Confirmation/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/CreditCard/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/CreditCard/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/CreditCard/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/CreditCard/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Date/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Date/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Date/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Date/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Digit/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Digit/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Digit/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Digit/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Email/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Email/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Email/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Email/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/ExclusionIn/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/ExclusionIn/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/ExclusionIn/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/ExclusionIn/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/File/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/File/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/File/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/File/SetOptionCest.php create mode 100644 tests/integration/Filter/Validation/Validator/File/Size/ValidateCest.php create mode 100644 tests/integration/Filter/Validation/Validator/GetSetHasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Identical/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Identical/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Identical/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Identical/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/InclusionIn/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/InclusionIn/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/InclusionIn/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/InclusionIn/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Ip/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Ip/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Ip/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Ip/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Numericality/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Numericality/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Numericality/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Numericality/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/PresenceOf/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/PresenceOf/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/PresenceOf/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/PresenceOf/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Regex/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Regex/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Regex/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Regex/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Max/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Max/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Max/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Max/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Min/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Min/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Min/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/Min/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/StringLength/SetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Url/ConstructCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Url/GetOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Url/HasOptionCest.php delete mode 100644 tests/integration/Filter/Validation/Validator/Url/SetOptionCest.php diff --git a/tests/integration/Filter/Validation/AllowEmptyCest.php b/tests/integration/Filter/Validation/AllowEmptyCest.php index 5dab0118724..17a373f3b97 100644 --- a/tests/integration/Filter/Validation/AllowEmptyCest.php +++ b/tests/integration/Filter/Validation/AllowEmptyCest.php @@ -29,9 +29,9 @@ public function filterValidationAllowEmptyFalse(IntegrationTester $I) { $I->wantToTest('Validation - allowEmpty() - false'); - $data = ['name' => '']; + $data = ['name' => '']; $validation = new Validation(); - $validator = new Alpha(['allowEmpty' => false]); + $validator = new Alpha(['allowEmpty' => false]); $validation->add('name', $validator); $messages = $validation->validate($data); @@ -42,9 +42,9 @@ public function filterValidationAllowEmptyTrue(IntegrationTester $I) { $I->wantToTest('Validation - allowEmpty() - true'); - $data = ['name' => '']; + $data = ['name' => '']; $validation = new Validation(); - $validator = new Alpha(['allowEmpty' => true]); + $validator = new Alpha(['allowEmpty' => true]); $validation->add('name', $validator); $messages = $validation->validate($data); diff --git a/tests/integration/Filter/Validation/AppendMessageCest.php b/tests/integration/Filter/Validation/AppendMessageCest.php index 5915b0773ba..f0b31690703 100644 --- a/tests/integration/Filter/Validation/AppendMessageCest.php +++ b/tests/integration/Filter/Validation/AppendMessageCest.php @@ -14,6 +14,11 @@ namespace Phalcon\Tests\Integration\Filter\Validation; use IntegrationTester; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\PresenceOf; +use Phalcon\Messages\Message; +use Phalcon\Messages\Messages; +use stdClass; /** * Class AppendMessageCest @@ -29,7 +34,46 @@ class AppendMessageCest public function filterValidationAppendMessage(IntegrationTester $I) { $I->wantToTest('Validation - appendMessage()'); + $validator = new PresenceOf(); + $validation = new Validation(); - $I->skipTest('Need implementation'); + $validation->bind( + new stdClass(), + [ + 'day' => date('d'), + 'month' => date('m'), + 'year' => (string)(intval(date('Y')) + 1), + ] + ); + + $validation->appendMessage( + new Message( + 'Field baz is required', + 'baz', + PresenceOf::class, + 0 + ) + ); + $validator->validate($validation, 'foo'); + + $expected = new Messages( + [ + new Message( + 'Field baz is required', + 'baz', + PresenceOf::class, + 0 + ), + new Message( + 'Field foo is required', + 'foo', + PresenceOf::class, + 0 + ), + ] + ); + + $actual = $validation->getMessages(); + $I->assertEquals($expected, $actual); } } diff --git a/tests/integration/Filter/Validation/GetLabelCest.php b/tests/integration/Filter/Validation/GetLabelCest.php deleted file mode 100644 index 60e3f59a2b0..00000000000 --- a/tests/integration/Filter/Validation/GetLabelCest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation; - -use IntegrationTester; - -/** - * Class GetLabelCest - */ -class GetLabelCest -{ - /** - * Tests Phalcon\Filter\Validation :: getLabel() - * - * @author Phalcon Team - * @since 2019-04-16 - */ - public function filterValidationGetLabel(IntegrationTester $I) - { - $I->wantToTest('Validation - getLabel()'); - - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Filter/Validation/GetMessagesCest.php b/tests/integration/Filter/Validation/GetMessagesCest.php index 48a2a298ff2..da599190721 100644 --- a/tests/integration/Filter/Validation/GetMessagesCest.php +++ b/tests/integration/Filter/Validation/GetMessagesCest.php @@ -14,6 +14,11 @@ namespace Phalcon\Tests\Integration\Filter\Validation; use IntegrationTester; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\PresenceOf; +use Phalcon\Messages\Message; +use Phalcon\Messages\Messages; +use stdClass; /** * Class GetMessagesCest @@ -30,6 +35,32 @@ public function filterValidationGetMessages(IntegrationTester $I) { $I->wantToTest('Validation - getMessages()'); - $I->skipTest('Need implementation'); + $validator = new PresenceOf(); + $validation = new Validation(); + + $validation->bind( + new stdClass(), + [ + 'day' => date('d'), + 'month' => date('m'), + 'year' => (string)(intval(date('Y')) + 1), + ] + ); + + $validator->validate($validation, 'foo'); + + $expected = new Messages( + [ + new Message( + 'Field foo is required', + 'foo', + PresenceOf::class, + 0 + ), + ] + ); + + $actual = $validation->getMessages(); + $I->assertEquals($expected, $actual); } } diff --git a/tests/integration/Filter/Validation/GetSetLabelCest.php b/tests/integration/Filter/Validation/GetSetLabelCest.php new file mode 100644 index 00000000000..5e09ca6dbd4 --- /dev/null +++ b/tests/integration/Filter/Validation/GetSetLabelCest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Integration\Filter\Validation; + +use IntegrationTester; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\PresenceOf; +use Phalcon\Messages\Message; +use Phalcon\Messages\Messages; +use stdClass; + +use function date; +use function intval; +use function uniqid; + +/** + */ +class GetSetLabelCest +{ + /** + * Tests Phalcon\Filter\Validation :: getLabel()/setLabels() + * + * @author Phalcon Team + * @since 2019-04-16 + */ + public function filterValidationGetLabel(IntegrationTester $I) + { + $I->wantToTest('Validation - getLabel()'); + $validator = new PresenceOf(); + $validation = new Validation(); + + $validation->bind( + new stdClass(), + [ + 'day' => date('d'), + 'month' => date('m'), + 'year' => (string)(intval(date('Y')) + 1), + ] + ); + + $label = uniqid('lbl-'); + $validation->setLabels( + [ + 'foo' => $label, + ] + ); + $validator->validate($validation, 'foo'); + + $expected = $label; + $actual = $validation->getLabel('foo'); + $I->assertSame($expected, $actual); + } +} diff --git a/tests/integration/Filter/Validation/GetValueByDataCest.php b/tests/integration/Filter/Validation/GetValueByDataCest.php index 6514033f8d5..c0915462acb 100644 --- a/tests/integration/Filter/Validation/GetValueByDataCest.php +++ b/tests/integration/Filter/Validation/GetValueByDataCest.php @@ -39,7 +39,7 @@ public function filterValidationGetValueByDataArray(IntegrationTester $I) ]; $validation = new Validation(); - $value = $validation->getValueByData($data, 'name'); + $value = $validation->getValueByData($data, 'name'); $I->assertSame($data['name'], $value); } @@ -51,7 +51,7 @@ public function filterValidationGetValueByDataObject(IntegrationTester $I) $data = new EntityWithPublic(self::NAME); $validation = new Validation(); - $value = $validation->getValueByData($data, 'name'); + $value = $validation->getValueByData($data, 'name'); $I->assertSame($data->name, $value); } diff --git a/tests/integration/Filter/Validation/GetValueByEntityCest.php b/tests/integration/Filter/Validation/GetValueByEntityCest.php index 9191fbc186e..146d314ff4f 100644 --- a/tests/integration/Filter/Validation/GetValueByEntityCest.php +++ b/tests/integration/Filter/Validation/GetValueByEntityCest.php @@ -39,7 +39,7 @@ public function filterValidationGetValueByEntityPublic(IntegrationTester $I): vo $entity = new EntityWithPublic(self::NAME); $validation = new Validation(); - $value = $validation->getValueByEntity($entity, 'name'); + $value = $validation->getValueByEntity($entity, 'name'); $I->assertSame($entity->name, $value); } @@ -51,7 +51,7 @@ public function filterValidationGetValueByEntityGetter(IntegrationTester $I): vo $entity = new EntityWithGetter(self::NAME); $validation = new Validation(); - $value = $validation->getValueByEntity($entity, 'name'); + $value = $validation->getValueByEntity($entity, 'name'); $I->assertSame($entity->getName(), $value); } @@ -63,7 +63,7 @@ public function filterValidationGetValueByEntityReadAttribute(IntegrationTester $entity = new EntityWithHook(self::NAME); $validation = new Validation(); - $value = $validation->getValueByEntity($entity, 'name'); + $value = $validation->getValueByEntity($entity, 'name'); $I->assertSame($entity->readAttribute('name'), $value); } diff --git a/tests/integration/Filter/Validation/SetLabelsCest.php b/tests/integration/Filter/Validation/SetLabelsCest.php deleted file mode 100644 index a34cba6fa8a..00000000000 --- a/tests/integration/Filter/Validation/SetLabelsCest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation; - -use IntegrationTester; - -/** - * Class SetLabelsCest - */ -class SetLabelsCest -{ - /** - * Tests Phalcon\Filter\Validation :: setLabels() - * - * @author Phalcon Team - * @since 2019-04-16 - */ - public function filterValidationSetLabels(IntegrationTester $I) - { - $I->wantToTest('Validation - setLabels()'); - - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Filter/Validation/ValidateCest.php b/tests/integration/Filter/Validation/ValidateCest.php index 6407178dd16..9bc43f7031a 100644 --- a/tests/integration/Filter/Validation/ValidateCest.php +++ b/tests/integration/Filter/Validation/ValidateCest.php @@ -27,19 +27,6 @@ */ class ValidateCest { - /** - * Tests Phalcon\Filter\Validation :: validate() - * - * @author Phalcon Team - * @since 2019-04-16 - */ - public function filterValidationValidate(IntegrationTester $I) - { - $I->wantToTest('Validation - validate()'); - - $I->skipTest('Need implementation'); - } - /** * Tests Phalcon\Filter\Validation :: validate() - message to non object * diff --git a/tests/integration/Filter/Validation/Validator/Alnum/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Alnum/ConstructCest.php deleted file mode 100644 index 22520b84bbf..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alnum/ConstructCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alnum; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alnum; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alnum :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlnumConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alnum - __construct()'); - - $validator = new Alnum(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alnum/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Alnum/GetOptionCest.php deleted file mode 100644 index 39b6afc743c..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alnum/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alnum; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alnum; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alnum :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlnumGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alnum - getOption()'); - - $validator = new Alnum(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alnum/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Alnum/HasOptionCest.php deleted file mode 100644 index 33c4972fac5..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alnum/HasOptionCest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alnum; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alnum; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alnum :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlnumHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alnum - hasOption()'); - - $validator = new Alnum( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alnum/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Alnum/SetOptionCest.php deleted file mode 100644 index 95e28e00843..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alnum/SetOptionCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alnum; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alnum; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alnum :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlnumSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alnum - setOption()'); - - $validator = new Alnum(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alnum/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Alnum/ValidateCest.php index 4afdad52254..1d5dd01e43f 100644 --- a/tests/integration/Filter/Validation/Validator/Alnum/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Alnum/ValidateCest.php @@ -39,7 +39,7 @@ public function filterValidationValidatorAlnumValidateEmpty(IntegrationTester $I $validation = new Validation(); $validator = new Alnum(['allowEmpty' => true,]); $validation->add('name', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->name = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/Alpha/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Alpha/ConstructCest.php deleted file mode 100644 index c52564e5cf2..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alpha/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alpha; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alpha; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alpha :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlphaConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alpha - __construct()'); - - $validator = new Alpha(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alpha/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Alpha/GetOptionCest.php deleted file mode 100644 index 18f3477eb12..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alpha/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alpha; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alpha; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alpha :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlphaGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alpha - getOption()'); - - $validator = new Alpha(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alpha/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Alpha/HasOptionCest.php deleted file mode 100644 index 6fe73bb3ba3..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alpha/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alpha; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alpha; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alpha :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlphaHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alpha - hasOption()'); - - $validator = new Alpha( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alpha/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Alpha/SetOptionCest.php deleted file mode 100644 index cf2dbdb5624..00000000000 --- a/tests/integration/Filter/Validation/Validator/Alpha/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Alpha; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Alpha; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Alpha :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorAlphaSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Alpha - setOption()'); - - $validator = new Alpha(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Alpha/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Alpha/ValidateCest.php index 96008fd937c..e3e70801adc 100644 --- a/tests/integration/Filter/Validation/Validator/Alpha/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Alpha/ValidateCest.php @@ -42,7 +42,7 @@ public function filterValidationValidatorAlphaValidateEmpty(IntegrationTester $I $validation = new Validation(); $validator = new Alpha(['allowEmpty' => true,]); $validation->add('name', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->name = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/Between/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Between/ConstructCest.php deleted file mode 100644 index f2a75c7a843..00000000000 --- a/tests/integration/Filter/Validation/Validator/Between/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Between; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Between; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Between :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorBetweenConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Between - __construct()'); - - $validator = new Between(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Between/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Between/GetOptionCest.php deleted file mode 100644 index 99b0e73f87e..00000000000 --- a/tests/integration/Filter/Validation/Validator/Between/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Between; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Between; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Between :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorBetweenGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Between - getOption()'); - - $validator = new Between(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Between/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Between/HasOptionCest.php deleted file mode 100644 index f6fbf8bfaa2..00000000000 --- a/tests/integration/Filter/Validation/Validator/Between/HasOptionCest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Between; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Between; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Between :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorBetweenHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Between - hasOption()'); - - $validator = new Between( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Between/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Between/SetOptionCest.php deleted file mode 100644 index c6e45bc6fc5..00000000000 --- a/tests/integration/Filter/Validation/Validator/Between/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Between; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Between; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Between :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorBetweenSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Between - setOption()'); - - $validator = new Between(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Between/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Between/ValidateCest.php index 0774243dfa8..89fddf58fa1 100644 --- a/tests/integration/Filter/Validation/Validator/Between/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Between/ValidateCest.php @@ -50,7 +50,7 @@ public function filterValidationValidatorBetweenValidateEmpty(IntegrationTester ] ); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/Callback/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Callback/ConstructCest.php deleted file mode 100644 index 7174ff9aea9..00000000000 --- a/tests/integration/Filter/Validation/Validator/Callback/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Callback; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Callback; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Callback :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCallbackConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Callback - __construct()'); - - $validator = new Callback(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Callback/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Callback/GetOptionCest.php deleted file mode 100644 index f5588e89433..00000000000 --- a/tests/integration/Filter/Validation/Validator/Callback/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Callback; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Callback; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Callback :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCallbackGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Callback - getOption()'); - - $validator = new Callback(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Callback/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Callback/HasOptionCest.php deleted file mode 100644 index bd36c9b959b..00000000000 --- a/tests/integration/Filter/Validation/Validator/Callback/HasOptionCest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Callback; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Callback; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Callback :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCallbackHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Callback - hasOption()'); - - $validator = new Callback( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Callback/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Callback/SetOptionCest.php deleted file mode 100644 index 07f59651604..00000000000 --- a/tests/integration/Filter/Validation/Validator/Callback/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Callback; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Callback; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Callback :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCallbackSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Callback - setOption()'); - - $validator = new Callback(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Confirmation/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Confirmation/ConstructCest.php deleted file mode 100644 index d8239d6ee63..00000000000 --- a/tests/integration/Filter/Validation/Validator/Confirmation/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Confirmation; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Confirmation; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Confirmation :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorConfirmationConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Confirmation - __construct()'); - - $validator = new Confirmation(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Confirmation/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Confirmation/GetOptionCest.php deleted file mode 100644 index 023ce1ef041..00000000000 --- a/tests/integration/Filter/Validation/Validator/Confirmation/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Confirmation; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Confirmation; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Confirmation :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorConfirmationGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Confirmation - getOption()'); - - $validator = new Confirmation(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Confirmation/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Confirmation/HasOptionCest.php deleted file mode 100644 index e7be604b831..00000000000 --- a/tests/integration/Filter/Validation/Validator/Confirmation/HasOptionCest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Confirmation; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Confirmation; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Confirmation :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorConfirmationHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Confirmation - hasOption()'); - - $validator = new Confirmation( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Confirmation/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Confirmation/SetOptionCest.php deleted file mode 100644 index f905146babc..00000000000 --- a/tests/integration/Filter/Validation/Validator/Confirmation/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Confirmation; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Confirmation; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Confirmation :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorConfirmationSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Confirmation - setOption()'); - - $validator = new Confirmation(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/ConstructCest.php b/tests/integration/Filter/Validation/Validator/ConstructCest.php index 7c11ddb54f6..5190c9c2e8f 100644 --- a/tests/integration/Filter/Validation/Validator/ConstructCest.php +++ b/tests/integration/Filter/Validation/Validator/ConstructCest.php @@ -23,46 +23,34 @@ class ConstructCest { /** * Tests Phalcon\Filter\Validation\Validator :: __construct() + * with message option * * @author Phalcon Team * @since 2018-11-13 */ public function filterValidationValidatorConstruct(IntegrationTester $I) { - $I->wantToTest('Validation\Validator - __construct()'); - $I->skipTest('Need implementation'); - } + $message = uniqid('mes-'); + $default = new PresenceOf(); // default message + $custom = new PresenceOf(['message' => $message]); // custom message - /** - * Tests Phalcon\Filter\Validation\Validator :: __construct() with message option - */ - public function filterValidationValidatorConstructWithMessage(IntegrationTester $I) - { - $validator_default = new PresenceOf(); // default message - $validator_custom = new PresenceOf(['message' => 'Custom message']); // custom message - - // expected: FALSE - empty message for default text (not set) - $I->assertEquals( - false, - $validator_default->getOption('message') - ); + // expected: null - empty message for default text (not set) + $actual = $default->getOption('message'); + $I->assertNull($actual); // expected: text message - has custom message (developer set this message) - $I->assertEquals( - 'Custom message', - $validator_custom->getOption('message') - ); - - $validator_custom = new PresenceOf(['template' => 'Custom message']); // custom message - $I->assertEquals( - 'Custom message', - $validator_custom->getOption('message') - ); - - $validator_custom = new PresenceOf(['Custom message']); // custom message - $I->assertEquals( - 'Custom message', - $validator_custom->getOption('message') - ); + $expected = $message; + $actual = $custom->getOption('message'); + $I->assertSame($expected, $actual); + + $custom = new PresenceOf(['template' => $message]); // custom message + $expected = $message; + $actual = $custom->getOption('message'); + $I->assertSame($expected, $actual); + + $custom = new PresenceOf([$message]); // custom message + $expected = $message; + $actual = $custom->getOption('message'); + $I->assertSame($expected, $actual); } } diff --git a/tests/integration/Filter/Validation/Validator/CreditCard/ConstructCest.php b/tests/integration/Filter/Validation/Validator/CreditCard/ConstructCest.php deleted file mode 100644 index 6452f8cfcb2..00000000000 --- a/tests/integration/Filter/Validation/Validator/CreditCard/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\CreditCard; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\CreditCard; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\CreditCard :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCreditCardConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\CreditCard - __construct()'); - - $validator = new CreditCard(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/CreditCard/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/CreditCard/GetOptionCest.php deleted file mode 100644 index be638812861..00000000000 --- a/tests/integration/Filter/Validation/Validator/CreditCard/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\CreditCard; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\CreditCard; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\CreditCard :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCreditCardGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\CreditCard - getOption()'); - - $validator = new CreditCard(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/CreditCard/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/CreditCard/HasOptionCest.php deleted file mode 100644 index 04184a1f570..00000000000 --- a/tests/integration/Filter/Validation/Validator/CreditCard/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\CreditCard; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\CreditCard; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\CreditCard :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCreditCardHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\CreditCard - hasOption()'); - - $validator = new CreditCard( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/CreditCard/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/CreditCard/SetOptionCest.php deleted file mode 100644 index bfe8a596806..00000000000 --- a/tests/integration/Filter/Validation/Validator/CreditCard/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\CreditCard; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\CreditCard; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\CreditCard :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorCreditCardSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\CreditCard - setOption()'); - - $validator = new CreditCard(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/CreditCard/ValidateCest.php b/tests/integration/Filter/Validation/Validator/CreditCard/ValidateCest.php index 8e547f96b4d..3bc4b422cad 100644 --- a/tests/integration/Filter/Validation/Validator/CreditCard/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/CreditCard/ValidateCest.php @@ -44,7 +44,7 @@ public function filterValidationValidatorCreditCardValidateEmpty(IntegrationTest $validation = new Validation(); $validator = new CreditCard(['allowEmpty' => true,]); $validation->add('creditCard', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->creditCard = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/Date/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Date/ConstructCest.php deleted file mode 100644 index 28539a75ecd..00000000000 --- a/tests/integration/Filter/Validation/Validator/Date/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Date; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Date; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Date :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDateConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Date - __construct()'); - - $validator = new Date(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Date/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Date/GetOptionCest.php deleted file mode 100644 index 3271f443d72..00000000000 --- a/tests/integration/Filter/Validation/Validator/Date/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Date; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Date; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Date :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDateGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Date - getOption()'); - - $validator = new Date(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Date/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Date/HasOptionCest.php deleted file mode 100644 index 6141d89f600..00000000000 --- a/tests/integration/Filter/Validation/Validator/Date/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Date; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Date; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Date :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDateHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Date - hasOption()'); - - $validator = new Date( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Date/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Date/SetOptionCest.php deleted file mode 100644 index dfa13fd44c1..00000000000 --- a/tests/integration/Filter/Validation/Validator/Date/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Date; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Date; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Date :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDateSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Date - setOption()'); - - $validator = new Date(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Date/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Date/ValidateCest.php index 380efc5c5d1..70c2517f70a 100644 --- a/tests/integration/Filter/Validation/Validator/Date/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Date/ValidateCest.php @@ -45,7 +45,7 @@ public function filterValidationValidatorDateValidateEmpty(IntegrationTester $I) $validation = new Validation(); $validator = new Date(['allowEmpty' => true,]); $validation->add('start_date', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->start_date = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/Digit/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Digit/ConstructCest.php deleted file mode 100644 index 48bd9b822b2..00000000000 --- a/tests/integration/Filter/Validation/Validator/Digit/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Digit; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Digit; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Digit :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDigitConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Digit - __construct()'); - - $validator = new Digit(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Digit/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Digit/GetOptionCest.php deleted file mode 100644 index e127d1ef633..00000000000 --- a/tests/integration/Filter/Validation/Validator/Digit/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Digit; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Digit; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Digit :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDigitGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Digit - getOption()'); - - $validator = new Digit(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Digit/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Digit/HasOptionCest.php deleted file mode 100644 index 145aec2935f..00000000000 --- a/tests/integration/Filter/Validation/Validator/Digit/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Digit; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Digit; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Digit :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDigitHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Digit - hasOption()'); - - $validator = new Digit( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Digit/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Digit/SetOptionCest.php deleted file mode 100644 index c22900f6f34..00000000000 --- a/tests/integration/Filter/Validation/Validator/Digit/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Digit; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Digit; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Digit :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorDigitSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Digit - setOption()'); - - $validator = new Digit(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Digit/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Digit/ValidateCest.php index 3fbb52e03ea..4413b3ca83b 100644 --- a/tests/integration/Filter/Validation/Validator/Digit/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Digit/ValidateCest.php @@ -45,7 +45,7 @@ public function filterValidationValidatorDigitValidateEmpty(IntegrationTester $I $validation = new Validation(); $validator = new Digit(['allowEmpty' => true,]); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); @@ -173,12 +173,16 @@ public function filterValidationValidatorDigitMultipleField(IntegrationTester $I } /** - * @dataProvider shouldValidateIntOrStringOfDigitsProvider + * @dataProvider getExamplesIntOrStringOfDigits + * + * @param IntegrationTester $I + * @param Example $example + * + * @return void + * @throws Exception */ - public function filterValidationValidatorDigitShouldValidateIntOrStringOfDigits( - IntegrationTester $I, - Example $example - ) { + public function filterValidationValidatorDigitIntOrStringOfDigits(IntegrationTester $I, Example $example) + { $digit = $example[0]; $validation = new Validation(); @@ -200,7 +204,10 @@ public function filterValidationValidatorDigitShouldValidateIntOrStringOfDigits( ); } - private function shouldValidateIntOrStringOfDigitsProvider() + /** + * @return array + */ + private function getExamplesIntOrStringOfDigits() { return [ ['123'], diff --git a/tests/integration/Filter/Validation/Validator/Email/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Email/ConstructCest.php deleted file mode 100644 index 4ac7d3e5d25..00000000000 --- a/tests/integration/Filter/Validation/Validator/Email/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Email; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Email; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Email :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorEmailConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Email - __construct()'); - - $validator = new Email(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Email/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Email/GetOptionCest.php deleted file mode 100644 index 2057926ede9..00000000000 --- a/tests/integration/Filter/Validation/Validator/Email/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Email; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Email; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Email :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorEmailGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Email - getOption()'); - - $validator = new Email(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Email/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Email/HasOptionCest.php deleted file mode 100644 index a25c490169b..00000000000 --- a/tests/integration/Filter/Validation/Validator/Email/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Email; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Email; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Email :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorEmailHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Email - hasOption()'); - - $validator = new Email( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Email/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Email/SetOptionCest.php deleted file mode 100644 index 278cc314e73..00000000000 --- a/tests/integration/Filter/Validation/Validator/Email/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Email; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Email; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Email :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorEmailSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Email - setOption()'); - - $validator = new Email(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Email/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Email/ValidateCest.php index 3e8ea3853b4..1d6cd9a38dc 100644 --- a/tests/integration/Filter/Validation/Validator/Email/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Email/ValidateCest.php @@ -44,7 +44,7 @@ public function filterValidationValidatorEmailValidateEmpty(IntegrationTester $I $validation = new Validation(); $validator = new Email(['allowEmpty' => true,]); $validation->add('email_one', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->email_one = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/ExclusionIn/ConstructCest.php b/tests/integration/Filter/Validation/Validator/ExclusionIn/ConstructCest.php deleted file mode 100644 index 8581256ec25..00000000000 --- a/tests/integration/Filter/Validation/Validator/ExclusionIn/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\ExclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\ExclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\ExclusionIn :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorExclusionInConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\ExclusionIn - __construct()'); - - $validator = new ExclusionIn(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/ExclusionIn/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/ExclusionIn/GetOptionCest.php deleted file mode 100644 index 166f8452b5c..00000000000 --- a/tests/integration/Filter/Validation/Validator/ExclusionIn/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\ExclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\ExclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\ExclusionIn :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorExclusionInGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\ExclusionIn - getOption()'); - - $validator = new ExclusionIn(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/ExclusionIn/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/ExclusionIn/HasOptionCest.php deleted file mode 100644 index 1257af87616..00000000000 --- a/tests/integration/Filter/Validation/Validator/ExclusionIn/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\ExclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\ExclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\ExclusionIn :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorExclusionInHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\ExclusionIn - hasOption()'); - - $validator = new ExclusionIn( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/ExclusionIn/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/ExclusionIn/SetOptionCest.php deleted file mode 100644 index 25abca42b89..00000000000 --- a/tests/integration/Filter/Validation/Validator/ExclusionIn/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\ExclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\ExclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\ExclusionIn :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorExclusionInSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\ExclusionIn - setOption()'); - - $validator = new ExclusionIn(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/ExclusionIn/ValidateCest.php b/tests/integration/Filter/Validation/Validator/ExclusionIn/ValidateCest.php index 56e8b75909d..d4b8e98d0a0 100644 --- a/tests/integration/Filter/Validation/Validator/ExclusionIn/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/ExclusionIn/ValidateCest.php @@ -44,7 +44,7 @@ public function filterValidationValidatorExclusionInValidateEmpty(IntegrationTes $validation = new Validation(); $validator = new ExclusionIn(['allowEmpty' => true,]); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); @@ -78,7 +78,7 @@ function () { ] ); $validation->add('status', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->status = ''; $validation->bind($entity, []); @@ -102,7 +102,7 @@ function () { ); $validation->add('status', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->status = ''; $validation->bind($entity, []); @@ -110,6 +110,7 @@ function () { } ); } + /** * Tests exclusion in validator with single field * diff --git a/tests/integration/Filter/Validation/Validator/File/ConstructCest.php b/tests/integration/Filter/Validation/Validator/File/ConstructCest.php deleted file mode 100644 index 9baec44c6f5..00000000000 --- a/tests/integration/Filter/Validation/Validator/File/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\File; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\File; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\File :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorFileConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\File - __construct()'); - - $validator = new File(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/File/CustomMessagesCest.php b/tests/integration/Filter/Validation/Validator/File/CustomMessagesCest.php index 51d1c86776b..6dc80208dd6 100644 --- a/tests/integration/Filter/Validation/Validator/File/CustomMessagesCest.php +++ b/tests/integration/Filter/Validation/Validator/File/CustomMessagesCest.php @@ -15,15 +15,9 @@ use IntegrationTester; use Phalcon\Filter\Validation\Validator\File; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; -/** - * Class CustomMessagesCest - */ class CustomMessagesCest { - use ValidationTrait; - /** * Tests Phalcon\Filter\Validation\Validator\File :: customMessages[] * @@ -34,24 +28,28 @@ public function filterValidationValidatorFileCustomMessages(IntegrationTester $I { $I->wantToTest('Validation\Validator\File - customMessages[]'); - $options = [ - 'maxSize' => '0.5M', + $options = [ + 'maxSize' => '0.5M', 'messageFileEmpty' => 'File is empty', - 'messageIniSize' => 'Ini size is not valid', - 'messageValid' => 'File is not valid', + 'messageIniSize' => 'Ini size is not valid', + 'messageValid' => 'File is not valid', ]; - $file = new File($options); + $file = new File($options); $validators = $file->getValidators(); /** @var File\AbstractFile $validator */ foreach ($validators as $validator) { - $messageFileEmpty = $validator->getMessageFileEmpty(); - $messageIniSize = $validator->getMessageIniSize(); - $messageValid = $validator->getMessageValid(); + $expected = $options['messageFileEmpty']; + $actual = $validator->getMessageFileEmpty(); + $I->assertSame($expected, $actual); + + $expected = $options['messageIniSize']; + $actual = $validator->getMessageIniSize(); + $I->assertSame($expected, $actual); - $I->assertSame($options['messageFileEmpty'], $messageFileEmpty); - $I->assertSame($options['messageIniSize'], $messageIniSize); - $I->assertSame($options['messageValid'], $messageValid); + $expected = $options['messageValid']; + $actual = $validator->getMessageValid(); + $I->assertSame($expected, $actual); } } } diff --git a/tests/integration/Filter/Validation/Validator/File/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/File/GetOptionCest.php deleted file mode 100644 index 11d116652b0..00000000000 --- a/tests/integration/Filter/Validation/Validator/File/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\File; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\File; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\File :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorFileGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\File - getOption()'); - - $validator = new File(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/File/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/File/HasOptionCest.php deleted file mode 100644 index ec959644641..00000000000 --- a/tests/integration/Filter/Validation/Validator/File/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\File; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\File; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\File :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorFileHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\File - hasOption()'); - - $validator = new File( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/File/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/File/SetOptionCest.php deleted file mode 100644 index 837f5d88811..00000000000 --- a/tests/integration/Filter/Validation/Validator/File/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\File; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\File; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\File :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorFileSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\File - setOption()'); - - $validator = new File(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/File/Size/ValidateCest.php b/tests/integration/Filter/Validation/Validator/File/Size/ValidateCest.php new file mode 100644 index 00000000000..ffa61715159 --- /dev/null +++ b/tests/integration/Filter/Validation/Validator/File/Size/ValidateCest.php @@ -0,0 +1,235 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Integration\Filter\Validation\Validator\File\Size; + +use Codeception\Example; +use Codeception\Stub; +use IntegrationTester; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\Size\Equal; +use Phalcon\Filter\Validation\Validator\File\Size\Max; +use Phalcon\Filter\Validation\Validator\File\Size\Min; + +class ValidateCest +{ + /** + * Tests Phalcon\Filter\Validation\Validator\File\Size :: validate + * + * @param IntegrationTester $I + * @param Example $example + * + * @return void + * @throws Validation\Exception + * @author Phalcon Team + * @since 2023-09-28 + * + * @dataProvider getExamples + * + */ + public function filterValidationValidatorFileSize( + IntegrationTester $I, + Example $example + ) { + $class = $example['class']; + $options = $example['options']; + + $I->wantToTest($class . ' - validate'); + + $files = $_FILES ?? []; + $server = $_SERVER ?? []; + $_SERVER = [ + 'REQUEST_METHOD' => 'POST', + ]; + + $_FILES = [ + 'thumbnail' => [ + 'name' => 'IMG-20180403-WA0000.jpg', + 'full_path' => 'IMG-20180403-WA0000.jpg', + 'type' => 'image/jpeg', + 'tmp_name' => '/tmp/phpsjLIQJ', + 'error' => 0, + 'size' => 11768, + ], + ]; + + $validator = Stub::construct( + $class, + [ + 'options' => $options, + ], + [ + 'checkIsUploadedFile' => function () { + return true; + }, + ] + ); + + $validation = new Validation(); + $validation->add('thumbnail', $validator); + + $messages = $validation->validate($_FILES); + + $I->assertCount(0, $messages); + + $_FILES = $files; + $_SERVER = $server; + } + + /** + * Tests Phalcon\Filter\Validation\Validator\File\Size :: errors + * + * @param IntegrationTester $I + * @param Example $example + * + * @return void + * @throws Validation\Exception + * @author Phalcon Team + * @since 2023-09-28 + * + * @dataProvider getExamplesErrors + * + */ + public function filterValidationValidatorFileSizeErrors( + IntegrationTester $I, + Example $example + ) { + $class = $example['class']; + $options = $example['options']; + + $I->wantToTest($class . ' - validate errors'); + + $files = $_FILES ?? []; + $server = $_SERVER ?? []; + $_SERVER = [ + 'REQUEST_METHOD' => 'POST', + ]; + $_FILES = [ + 'thumbnail' => [ + 'name' => 'IMG-20180403-WA0000.jpg', + 'full_path' => 'IMG-20180403-WA0000.jpg', + 'type' => 'image/jpeg', + 'tmp_name' => '/tmp/phpsjLIQJ', + 'error' => 0, + 'size' => 11768, + ], + ]; + + $validator = Stub::construct( + $class, + [ + 'options' => $options, + ], + [ + 'checkIsUploadedFile' => function () { + return true; + }, + ] + ); + + $validation = new Validation(); + $validation->add('thumbnail', $validator); + + $messages = $validation->validate($_FILES); + + $I->assertCount(1, $messages); + + $expected = $example['message']; + $actual = $messages[0]->getMessage(); + $I->assertSame($expected, $actual); + + $_FILES = $files; + $_SERVER = $server; + } + + /** + * @return array[] + */ + private function getExamples(): array + { + return [ + [ + 'class' => Min::class, + 'options' => [ + 'size' => '1K', + 'message' => ':field is smaller than file size (:size)', + ], + ], + [ + 'class' => Max::class, + 'options' => [ + 'size' => '20K', + 'message' => ':field is larger than file size (:size)', + ], + ], + [ + 'class' => Equal::class, + 'options' => [ + 'size' => '11768', + 'message' => ':field is not equal to file size (:size)', + ], + ], + ]; + } + + /** + * @return array[] + */ + private function getExamplesErrors(): array + { + return [ + [ + 'class' => Min::class, + 'message' => 'thumbnail is smaller than file size (20K)', + 'options' => [ + 'size' => '20K', + 'message' => ':field is smaller than file size (:size)', + ], + ], + [ + 'class' => Min::class, + 'message' => 'thumbnail is smaller or equal than file size (11768)', + 'options' => [ + 'included' => true, + 'size' => '11768', + 'message' => ':field is smaller or equal than file size (:size)', + ], + ], + [ + 'class' => Max::class, + 'message' => 'thumbnail is larger than file size (10K)', + 'options' => [ + 'size' => '10K', + 'message' => ':field is larger than file size (:size)', + ], + ], + [ + 'class' => Max::class, + 'message' => 'thumbnail is larger or equal than file size (11768)', + 'options' => [ + 'included' => true, + 'size' => '11768', + 'message' => ':field is larger or equal than file size (:size)', + ], + ], + [ + 'class' => Equal::class, + 'message' => 'thumbnail is not equal to file size (11700)', + 'options' => [ + 'size' => '11700', + 'message' => ':field is not equal to file size (:size)', + ], + ], + ]; + } +} diff --git a/tests/integration/Filter/Validation/Validator/GetSetHasOptionCest.php b/tests/integration/Filter/Validation/Validator/GetSetHasOptionCest.php new file mode 100644 index 00000000000..eae4fe9a211 --- /dev/null +++ b/tests/integration/Filter/Validation/Validator/GetSetHasOptionCest.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Integration\Filter\Validation\Validator; + +use Codeception\Example; +use IntegrationTester; +use Phalcon\Filter\Validation\Validator\Alnum; +use Phalcon\Filter\Validation\Validator\Alpha; +use Phalcon\Filter\Validation\Validator\Between; +use Phalcon\Filter\Validation\Validator\Callback; +use Phalcon\Filter\Validation\Validator\Confirmation; +use Phalcon\Filter\Validation\Validator\CreditCard; +use Phalcon\Filter\Validation\Validator\Date; +use Phalcon\Filter\Validation\Validator\Digit; +use Phalcon\Filter\Validation\Validator\Email; +use Phalcon\Filter\Validation\Validator\ExclusionIn; +use Phalcon\Filter\Validation\Validator\File; +use Phalcon\Filter\Validation\Validator\Identical; +use Phalcon\Filter\Validation\Validator\InclusionIn; +use Phalcon\Filter\Validation\Validator\Ip; +use Phalcon\Filter\Validation\Validator\Numericality; +use Phalcon\Filter\Validation\Validator\PresenceOf; +use Phalcon\Filter\Validation\Validator\Regex; +use Phalcon\Filter\Validation\Validator\StringLength; +use Phalcon\Filter\Validation\Validator\Uniqueness; +use Phalcon\Filter\Validation\Validator\Url; +use Phalcon\Filter\Validation\ValidatorInterface; + +use function uniqid; + +class GetSetHasOptionCest +{ + /** + * Tests Phalcon\Filter\Validation\Validator\Alnum :: getOption()/hasOption()/setOption() + * + * @dataProvider getExamples + * + * @author Phalcon Team + * @since 2023-09-20 + */ + public function filterValidationValidatorGetSetHasOption( + IntegrationTester $I, + Example $example + ) { + $class = $example['class']; + + $I->wantToTest( + $class . ' - getOption()/hasOption()/setOption()' + ); + + $name = uniqid('nam-'); + $value = uniqid('val-'); + $validator = new $class(); + + $I->assertInstanceOf( + ValidatorInterface::class, + $validator + ); + + $actual = $validator->hasOption($name); + $I->assertFalse($actual); + + $validator->setOption($name, $value); + + $actual = $validator->hasOption($name); + $I->assertTrue($actual); + + $expected = $value; + $actual = $validator->getOption($name); + $I->assertSame($expected, $actual); + } + + private function getExamples(): array + { + return [ + [ + 'class' => Alnum::class, + ], + [ + 'class' => Alpha::class, + ], + [ + 'class' => Between::class, + ], + [ + 'class' => Callback::class, + ], + [ + 'class' => Confirmation::class, + ], + [ + 'class' => CreditCard::class, + ], + [ + 'class' => Date::class, + ], + [ + 'class' => Digit::class, + ], + [ + 'class' => Email::class, + ], + [ + 'class' => ExclusionIn::class, + ], + [ + 'class' => File::class, + ], + [ + 'class' => File\Size\Equal::class, + ], + [ + 'class' => File\Size\Max::class, + ], + [ + 'class' => File\Size\Min::class, + ], + [ + 'class' => File\Resolution\Equal::class, + ], + [ + 'class' => File\Resolution\Max::class, + ], + [ + 'class' => File\Resolution\Min::class, + ], + [ + 'class' => Identical::class, + ], + [ + 'class' => InclusionIn::class, + ], + [ + 'class' => Ip::class, + ], + [ + 'class' => Numericality::class, + ], + [ + 'class' => PresenceOf::class, + ], + [ + 'class' => Regex::class, + ], + [ + 'class' => StringLength::class, + ], + [ + 'class' => StringLength\Min::class, + ], + [ + 'class' => StringLength\Max::class, + ], + [ + 'class' => Uniqueness::class, + ], + [ + 'class' => Url::class, + ], + ]; + } +} diff --git a/tests/integration/Filter/Validation/Validator/Identical/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Identical/ConstructCest.php deleted file mode 100644 index 42f912309e9..00000000000 --- a/tests/integration/Filter/Validation/Validator/Identical/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Identical; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Identical; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Identical :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIdenticalConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Identical - __construct()'); - - $validator = new Identical(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Identical/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Identical/GetOptionCest.php deleted file mode 100644 index 8c508906c91..00000000000 --- a/tests/integration/Filter/Validation/Validator/Identical/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Identical; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Identical; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Identical :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIdenticalGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Identical - getOption()'); - - $validator = new Identical(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Identical/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Identical/HasOptionCest.php deleted file mode 100644 index fd0dc4a8d93..00000000000 --- a/tests/integration/Filter/Validation/Validator/Identical/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Identical; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Identical; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Identical :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIdenticalHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Identical - hasOption()'); - - $validator = new Identical( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Identical/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Identical/SetOptionCest.php deleted file mode 100644 index 624ae07e52c..00000000000 --- a/tests/integration/Filter/Validation/Validator/Identical/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Identical; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Identical; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Identical :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIdenticalSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Identical - setOption()'); - - $validator = new Identical(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Identical/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Identical/ValidateCest.php index 99eae10f94c..0e79f05c0c2 100644 --- a/tests/integration/Filter/Validation/Validator/Identical/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Identical/ValidateCest.php @@ -44,7 +44,7 @@ public function filterValidationValidatorIdenticalValidateEmpty(IntegrationTeste $validation = new Validation(); $validator = new Identical(['allowEmpty' => true,]); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/InclusionIn/ConstructCest.php b/tests/integration/Filter/Validation/Validator/InclusionIn/ConstructCest.php deleted file mode 100644 index 8e2b9d15aaf..00000000000 --- a/tests/integration/Filter/Validation/Validator/InclusionIn/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\InclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\InclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\InclusionIn :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorInclusionInConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\InclusionIn - __construct()'); - - $validator = new InclusionIn(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/InclusionIn/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/InclusionIn/GetOptionCest.php deleted file mode 100644 index 39807269fb7..00000000000 --- a/tests/integration/Filter/Validation/Validator/InclusionIn/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\InclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\InclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\InclusionIn :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorInclusionInGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\InclusionIn - getOption()'); - - $validator = new InclusionIn(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/InclusionIn/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/InclusionIn/HasOptionCest.php deleted file mode 100644 index 4c9b30de612..00000000000 --- a/tests/integration/Filter/Validation/Validator/InclusionIn/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\InclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\InclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\InclusionIn :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorInclusionInHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\InclusionIn - hasOption()'); - - $validator = new InclusionIn( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/InclusionIn/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/InclusionIn/SetOptionCest.php deleted file mode 100644 index 7fb298095d5..00000000000 --- a/tests/integration/Filter/Validation/Validator/InclusionIn/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\InclusionIn; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\InclusionIn; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\InclusionIn :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorInclusionInSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\InclusionIn - setOption()'); - - $validator = new InclusionIn(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Ip/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Ip/ConstructCest.php deleted file mode 100644 index 0da947db9ec..00000000000 --- a/tests/integration/Filter/Validation/Validator/Ip/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Ip; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Ip; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Ip :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIpConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Ip - __construct()'); - - $validator = new Ip(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Ip/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Ip/GetOptionCest.php deleted file mode 100644 index 8b50d8c3caf..00000000000 --- a/tests/integration/Filter/Validation/Validator/Ip/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Ip; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Ip; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Ip :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIpGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Ip - getOption()'); - - $validator = new Ip(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Ip/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Ip/HasOptionCest.php deleted file mode 100644 index ff9b2c1ab9f..00000000000 --- a/tests/integration/Filter/Validation/Validator/Ip/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Ip; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Ip; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Ip :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIpHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Ip - hasOption()'); - - $validator = new Ip( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Ip/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Ip/SetOptionCest.php deleted file mode 100644 index bdc36d533e4..00000000000 --- a/tests/integration/Filter/Validation/Validator/Ip/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Ip; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Ip; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Ip :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorIpSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Ip - setOption()'); - - $validator = new Ip(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Ip/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Ip/ValidateCest.php index 75e08626149..9e38bad7ffa 100644 --- a/tests/integration/Filter/Validation/Validator/Ip/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Ip/ValidateCest.php @@ -82,7 +82,7 @@ public function filterValidationValidatorIpSingleField(IntegrationTester $I) $I->assertSame( 'This is a test message', - (string) $messages[0] + (string)$messages[0] ); diff --git a/tests/integration/Filter/Validation/Validator/Numericality/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Numericality/ConstructCest.php deleted file mode 100644 index e06786b7623..00000000000 --- a/tests/integration/Filter/Validation/Validator/Numericality/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Numericality; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Numericality; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Numericality :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorNumericalityConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Numericality - __construct()'); - - $validator = new Numericality(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Numericality/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Numericality/GetOptionCest.php deleted file mode 100644 index 0992d582a86..00000000000 --- a/tests/integration/Filter/Validation/Validator/Numericality/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Numericality; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Numericality; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Numericality :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorNumericalityGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Numericality - getOption()'); - - $validator = new Numericality(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Numericality/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Numericality/HasOptionCest.php deleted file mode 100644 index 5ccee07d236..00000000000 --- a/tests/integration/Filter/Validation/Validator/Numericality/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Numericality; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Numericality; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Numericality :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorNumericalityHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Numericality - hasOption()'); - - $validator = new Numericality( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Numericality/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Numericality/SetOptionCest.php deleted file mode 100644 index f79bf16e3eb..00000000000 --- a/tests/integration/Filter/Validation/Validator/Numericality/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Numericality; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Numericality; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Numericality :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorNumericalitySetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Numericality - setOption()'); - - $validator = new Numericality(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Numericality/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Numericality/ValidateCest.php index 72c3c4e9771..786b1982422 100644 --- a/tests/integration/Filter/Validation/Validator/Numericality/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Numericality/ValidateCest.php @@ -43,7 +43,7 @@ public function filterValidationValidatorNumericalityValidateEmpty(IntegrationTe $validation = new Validation(); $validator = new Numericality(['allowEmpty' => true,]); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/PresenceOf/ConstructCest.php b/tests/integration/Filter/Validation/Validator/PresenceOf/ConstructCest.php deleted file mode 100644 index 8a9e1092aec..00000000000 --- a/tests/integration/Filter/Validation/Validator/PresenceOf/ConstructCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\PresenceOf; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\PresenceOf; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\PresenceOf :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorPresenceOfConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\PresenceOf - __construct()'); - - $validator = new PresenceOf(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/PresenceOf/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/PresenceOf/GetOptionCest.php deleted file mode 100644 index 1f5bddc2ee9..00000000000 --- a/tests/integration/Filter/Validation/Validator/PresenceOf/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\PresenceOf; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\PresenceOf; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\PresenceOf :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorPresenceOfGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\PresenceOf - getOption()'); - - $validator = new PresenceOf(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/PresenceOf/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/PresenceOf/HasOptionCest.php deleted file mode 100644 index 7081a908288..00000000000 --- a/tests/integration/Filter/Validation/Validator/PresenceOf/HasOptionCest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\PresenceOf; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\PresenceOf; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\PresenceOf :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorPresenceOfHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\PresenceOf - hasOption()'); - - $validator = new PresenceOf( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/PresenceOf/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/PresenceOf/SetOptionCest.php deleted file mode 100644 index 82a1374c836..00000000000 --- a/tests/integration/Filter/Validation/Validator/PresenceOf/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\PresenceOf; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\PresenceOf; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\PresenceOf :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorPresenceOfSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\PresenceOf - setOption()'); - - $validator = new PresenceOf(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/PresenceOf/ValidateCest.php b/tests/integration/Filter/Validation/Validator/PresenceOf/ValidateCest.php index c0366d2990e..b3599045971 100644 --- a/tests/integration/Filter/Validation/Validator/PresenceOf/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/PresenceOf/ValidateCest.php @@ -45,7 +45,7 @@ public function filterValidationValidatorPresenceOfValidateEmpty(IntegrationTest $validation = new Validation(); $validator = new PresenceOf(['allowEmpty' => true,]); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); @@ -252,10 +252,13 @@ public function filterValidationValidatorPresenceOfCancelOnFail(IntegrationTeste $validation ->add('name', new PresenceOf(['message' => 'The name is required'])) - ->add('email', new PresenceOf([ - 'message' => 'The email is required', - 'cancelOnFail' => true, - ])) + ->add( + 'email', + new PresenceOf([ + 'message' => 'The email is required', + 'cancelOnFail' => true, + ]) + ) ->add('login', new PresenceOf(['message' => 'The login is required'])) ; diff --git a/tests/integration/Filter/Validation/Validator/Regex/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Regex/ConstructCest.php deleted file mode 100644 index 6a059dfacc0..00000000000 --- a/tests/integration/Filter/Validation/Validator/Regex/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Regex; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Regex; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Regex :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorRegexConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Regex - __construct()'); - - $validator = new Regex(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Regex/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Regex/GetOptionCest.php deleted file mode 100644 index 88e6085ced6..00000000000 --- a/tests/integration/Filter/Validation/Validator/Regex/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Regex; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Regex; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Regex :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorRegexGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Regex - getOption()'); - - $validator = new Regex(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Regex/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Regex/HasOptionCest.php deleted file mode 100644 index 7851432c13a..00000000000 --- a/tests/integration/Filter/Validation/Validator/Regex/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Regex; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Regex; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Regex :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorRegexHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Regex - hasOption()'); - - $validator = new Regex( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Regex/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Regex/SetOptionCest.php deleted file mode 100644 index 178ae63c930..00000000000 --- a/tests/integration/Filter/Validation/Validator/Regex/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Regex; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Regex; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Regex :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorRegexSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Regex - setOption()'); - - $validator = new Regex(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Regex/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Regex/ValidateCest.php index 29978b7716f..9b22743bab3 100644 --- a/tests/integration/Filter/Validation/Validator/Regex/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Regex/ValidateCest.php @@ -44,7 +44,7 @@ public function filterValidationValidatorRegexValidateEmpty(IntegrationTester $I $validation = new Validation(); $validator = new Regex(['allowEmpty' => true,]); $validation->add('price', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->price = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/StringLength/ConstructCest.php b/tests/integration/Filter/Validation/Validator/StringLength/ConstructCest.php deleted file mode 100644 index 71c222e20ae..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/ConstructCest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength; -use Phalcon\Filter\Validation\ValidatorCompositeInterface; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorStringLengthConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength - __construct()'); - - $validator = new StringLength(); - - $this->checkConstruct($I, $validator); - - $I->assertInstanceOf( - ValidatorCompositeInterface::class, - $validator, - 'StringLength implements ValidatorCompositeInterface' - ); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/GetOptionCest.php deleted file mode 100644 index 5f769d9f86c..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorStringLengthGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength - getOption()'); - - $validator = new StringLength(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/HasOptionCest.php deleted file mode 100644 index fbdcc5f16ae..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorStringLengthHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength - hasOption()'); - - $validator = new StringLength( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Max/ConstructCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Max/ConstructCest.php deleted file mode 100644 index 7aee9b1b06a..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Max/ConstructCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Max; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength\Max; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Max :: __construct() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMaxConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Max - __construct()'); - - $validator = new Max(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Max/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Max/GetOptionCest.php deleted file mode 100644 index 7140dd63ee7..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Max/GetOptionCest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Max; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength\Max; - -class GetOptionCest -{ - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Max :: getOption() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMaxGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Max - getOption()'); - - $validator = new Max(); - - $I->assertSame(null, $validator->getOption('max'), 'Max option is null by default'); - - $expected = 1234; - $validator->setOption('max', $expected); - $I->assertSame($expected, $validator->getOption('max'), 'Max option is 1234'); - - $expected = '1234'; - $validator->setOption('max', $expected); - $I->assertSame($expected, $validator->getOption('max'), 'Max option is "1234"'); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Max/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Max/HasOptionCest.php deleted file mode 100644 index 3a5b0699b99..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Max/HasOptionCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Max; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength\Max; - -class HasOptionCest -{ - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Max :: hasOption() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMaxHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Max - hasOption()'); - - $validator = new Max(); - - $I->assertFalse($validator->hasOption('max'), 'Max option does not exists'); - - $validator->setOption('max', 1234); - $I->assertTrue($validator->hasOption('max'), 'Max option does exists'); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Max/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Max/SetOptionCest.php deleted file mode 100644 index d91d5a14e5f..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Max/SetOptionCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Max; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Max :: setOption() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMaxSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Max - setOption()'); - - $validator = new StringLength(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Max/ValidateCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Max/ValidateCest.php index e3307168d55..922057d6ea8 100644 --- a/tests/integration/Filter/Validation/Validator/StringLength/Max/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/StringLength/Max/ValidateCest.php @@ -39,7 +39,7 @@ public function filterValidationValidatorMaxValidateEmpty(IntegrationTester $I) $validation = new Validation(); $validator = new Max(['allowEmpty' => true,]); $validation->add('name', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->name = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Min/ConstructCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Min/ConstructCest.php deleted file mode 100644 index 3c3572fb982..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Min/ConstructCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Min; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength\Min; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Min :: __construct() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMinConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Min - __construct()'); - - $validator = new Min(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Min/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Min/GetOptionCest.php deleted file mode 100644 index 344beaebfe0..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Min/GetOptionCest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Min; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength\Min; - -class GetOptionCest -{ - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Min :: getOption() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMinGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Min - getOption()'); - - $validator = new Min(); - - $I->assertSame(null, $validator->getOption('min'), 'Min option is null by default'); - - $expected = 1234; - $validator->setOption('min', $expected); - $I->assertSame($expected, $validator->getOption('min'), 'Min option is 1234'); - - $expected = '1234'; - $validator->setOption('min', $expected); - $I->assertSame($expected, $validator->getOption('min'), 'Min option is "1234"'); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Min/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Min/HasOptionCest.php deleted file mode 100644 index 098d0e8ba21..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Min/HasOptionCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Min; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength\Min; - -class HasOptionCest -{ - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Min :: hasOption() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMinHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Min - hasOption()'); - - $validator = new Min(); - - $I->assertFalse($validator->hasOption('min'), 'Min option does not exists'); - - $validator->setOption('min', 1234); - $I->assertTrue($validator->hasOption('min'), 'Min option does exists'); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Min/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Min/SetOptionCest.php deleted file mode 100644 index 9fb7e7df665..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/Min/SetOptionCest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength\Min; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength\Min :: setOption() - * - * @author Phalcon Team - * @since 2019-05-23 - */ - public function filterValidationValidatorStringLengthMinSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength\Min - setOption()'); - - $validator = new StringLength(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/StringLength/Min/ValidateCest.php b/tests/integration/Filter/Validation/Validator/StringLength/Min/ValidateCest.php index cfb14f475a3..4d2b7050820 100644 --- a/tests/integration/Filter/Validation/Validator/StringLength/Min/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/StringLength/Min/ValidateCest.php @@ -39,7 +39,7 @@ public function filterValidationValidatorMinValidateEmpty(IntegrationTester $I) $validation = new Validation(); $validator = new Min(['allowEmpty' => true,]); $validation->add('name', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->name = ''; $validation->bind($entity, []); diff --git a/tests/integration/Filter/Validation/Validator/StringLength/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/StringLength/SetOptionCest.php deleted file mode 100644 index 4bc6ecb7157..00000000000 --- a/tests/integration/Filter/Validation/Validator/StringLength/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\StringLength; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\StringLength; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\StringLength :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorStringLengthSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\StringLength - setOption()'); - - $validator = new StringLength(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Url/ConstructCest.php b/tests/integration/Filter/Validation/Validator/Url/ConstructCest.php deleted file mode 100644 index 41da1a8fe7a..00000000000 --- a/tests/integration/Filter/Validation/Validator/Url/ConstructCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Url; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Url; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Url :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorUrlConstruct(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Url - __construct()'); - - $validator = new Url(); - - $this->checkConstruct($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Url/GetOptionCest.php b/tests/integration/Filter/Validation/Validator/Url/GetOptionCest.php deleted file mode 100644 index 10debff5eeb..00000000000 --- a/tests/integration/Filter/Validation/Validator/Url/GetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Url; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Url; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class GetOptionCest - */ -class GetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Url :: getOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorUrlGetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Url - getOption()'); - - $validator = new Url(); - - $this->checkGetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Url/HasOptionCest.php b/tests/integration/Filter/Validation/Validator/Url/HasOptionCest.php deleted file mode 100644 index 29f290c4118..00000000000 --- a/tests/integration/Filter/Validation/Validator/Url/HasOptionCest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Url; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Url; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class HasOptionCest - */ -class HasOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Url :: hasOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorUrlHasOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Url - hasOption()'); - - $validator = new Url( - [ - 'message' => 'This is a message', - ] - ); - - $this->checkHasOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Url/SetOptionCest.php b/tests/integration/Filter/Validation/Validator/Url/SetOptionCest.php deleted file mode 100644 index 6a4f781e1da..00000000000 --- a/tests/integration/Filter/Validation/Validator/Url/SetOptionCest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Integration\Filter\Validation\Validator\Url; - -use IntegrationTester; -use Phalcon\Filter\Validation\Validator\Url; -use Phalcon\Tests\Fixtures\Traits\ValidationTrait; - -/** - * Class SetOptionCest - */ -class SetOptionCest -{ - use ValidationTrait; - - /** - * Tests Phalcon\Filter\Validation\Validator\Url :: setOption() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function filterValidationValidatorUrlSetOption(IntegrationTester $I) - { - $I->wantToTest('Validation\Validator\Url - setOption()'); - - $validator = new Url(); - - $this->checkSetOption($I, $validator); - } -} diff --git a/tests/integration/Filter/Validation/Validator/Url/ValidateCest.php b/tests/integration/Filter/Validation/Validator/Url/ValidateCest.php index 76d5b092ac4..e22e9fb7ad5 100644 --- a/tests/integration/Filter/Validation/Validator/Url/ValidateCest.php +++ b/tests/integration/Filter/Validation/Validator/Url/ValidateCest.php @@ -48,7 +48,7 @@ public function filterValidationValidatorUrlValidateEmpty(IntegrationTester $I) $validation = new Validation(); $validator = new Url(['allowEmpty' => true,]); $validation->add('url', $validator); - $entity = new stdClass(); + $entity = new stdClass(); $entity->url = ''; $validation->bind($entity, []); From e6dcc6dfa8374c9a37ca5b3ad4d7db0afeb3e383 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 28 Sep 2023 19:07:46 -0500 Subject: [PATCH 07/57] updating changelog --- CHANGELOG-5.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index 396b66383eb..82ada652bd5 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -5,6 +5,7 @@ ### Fixed - Model Annotation strategy did not work with empty_string [#16426] (https://github.com/phalcon/cphalcon/issues/16426) - View::reset() sets content to null instead of default empty string [#16437] (https://github.com/phalcon/cphalcon/issues/16437) +- Fixed `Phalcon\Filter\Validation\Validator\Size\*` validators to correctly detect the size of uploaded files [#16390](https://github.com/phalcon/cphalcon/issues/16390) ## [5.3.1](https://github.com/phalcon/cphalcon/releases/tag/v5.3.1) (2023-09-12) From 4ac24cbafcd44c9124082aa7428e53ef8e21a80d Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 28 Sep 2023 19:17:18 -0500 Subject: [PATCH 08/57] correcting type --- phalcon/Filter/Validation/Validator/File/Size/Equal.zep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phalcon/Filter/Validation/Validator/File/Size/Equal.zep b/phalcon/Filter/Validation/Validator/File/Size/Equal.zep index 033630c5e5c..6224c6e67f5 100644 --- a/phalcon/Filter/Validation/Validator/File/Size/Equal.zep +++ b/phalcon/Filter/Validation/Validator/File/Size/Equal.zep @@ -73,7 +73,7 @@ class Equal extends AbstractFile * @return bool * @throws Validation\Exception */ - public function validate( validation, string field) -> bool + public function validate( validation, var field) -> bool { var bytes, included, fileSize, replacePairs, size, value; From 028bafbbe3b44abfd93f34eb399889bd2ca297ba Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 28 Sep 2023 19:20:05 -0500 Subject: [PATCH 09/57] correcting docblock --- phalcon/Filter/Validation/Validator/File/Size/Equal.zep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phalcon/Filter/Validation/Validator/File/Size/Equal.zep b/phalcon/Filter/Validation/Validator/File/Size/Equal.zep index 6224c6e67f5..1ce12eb2f2a 100644 --- a/phalcon/Filter/Validation/Validator/File/Size/Equal.zep +++ b/phalcon/Filter/Validation/Validator/File/Size/Equal.zep @@ -68,7 +68,7 @@ class Equal extends AbstractFile * Executes the validation * * @param Validation $validation - * @param string $field + * @param mixed $field * * @return bool * @throws Validation\Exception From e8916818e1b3341defe69ac5a19f29de27896a8a Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 28 Sep 2023 19:23:04 -0500 Subject: [PATCH 10/57] correcting docblock --- phalcon/Filter/Validation/AbstractValidator.zep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phalcon/Filter/Validation/AbstractValidator.zep b/phalcon/Filter/Validation/AbstractValidator.zep index bba82e6b82c..13defcd3513 100644 --- a/phalcon/Filter/Validation/AbstractValidator.zep +++ b/phalcon/Filter/Validation/AbstractValidator.zep @@ -227,7 +227,7 @@ abstract class AbstractValidator implements ValidatorInterface * Executes the validation * * @param Validation $validation - * @param string $field + * @param mixed $field * * @return bool */ From 23c250aafd03b06a1bc37eb846322c5ffb940148 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Fri, 29 Sep 2023 04:45:03 -0500 Subject: [PATCH 11/57] updating composer --- composer.lock | 76 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/composer.lock b/composer.lock index a5a35eeda76..344d4f4edfe 100644 --- a/composer.lock +++ b/composer.lock @@ -1347,16 +1347,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -1388,9 +1388,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/instantiator", @@ -1565,16 +1565,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.26.1", + "version": "v3.30.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "d023ba6684055f6ea1da1352d8a02baca0426983" + "reference": "95c64693b2f149966a2bc05a7a4981b0343ea52f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d023ba6684055f6ea1da1352d8a02baca0426983", - "reference": "d023ba6684055f6ea1da1352d8a02baca0426983", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/95c64693b2f149966a2bc05a7a4981b0343ea52f", + "reference": "95c64693b2f149966a2bc05a7a4981b0343ea52f", "shasum": "" }, "require": { @@ -1648,7 +1648,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.26.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.30.0" }, "funding": [ { @@ -1656,7 +1656,7 @@ "type": "github" } ], - "time": "2023-09-08T19:09:07+00:00" + "time": "2023-09-26T22:10:43+00:00" }, { "name": "graham-campbell/result-type", @@ -2927,16 +2927,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.0", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { @@ -2968,22 +2968,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-09-07T20:46:32+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -3040,7 +3040,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" }, "funding": [ { @@ -3048,7 +3048,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3293,16 +3293,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.11", + "version": "9.6.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", "shasum": "" }, "require": { @@ -3317,7 +3317,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -3376,7 +3376,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" }, "funding": [ { @@ -3392,7 +3392,7 @@ "type": "tidelift" } ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2023-09-19T05:39:22+00:00" }, { "name": "predis/predis", @@ -3560,16 +3560,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -3606,9 +3606,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -6966,5 +6966,5 @@ "ext-sqlite3": "*", "ext-xml": "*" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } From 512c0353dda59ce09373ba8f6cf7480acebef0a1 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Fri, 29 Sep 2023 05:02:52 -0500 Subject: [PATCH 12/57] corrections for the PR --- .../Filter/Validation/AbstractValidator.zep | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/phalcon/Filter/Validation/AbstractValidator.zep b/phalcon/Filter/Validation/AbstractValidator.zep index 13defcd3513..4500e2bafb8 100644 --- a/phalcon/Filter/Validation/AbstractValidator.zep +++ b/phalcon/Filter/Validation/AbstractValidator.zep @@ -76,7 +76,7 @@ abstract class AbstractValidator implements ValidatorInterface * * @return mixed */ - public function getOption(string! key, var defaultValue = null) -> var + public function getOption(string key, var defaultValue = null) -> var { var value, fieldValue; @@ -88,7 +88,7 @@ abstract class AbstractValidator implements ValidatorInterface * If we have `attribute` as a key, it means it is a Uniqueness * validator, we can have here multiple fields, so we need to check it */ - if key == "attribute" && typeof value == "array" { + if key === "attribute" && typeof value === "array" { if fetch fieldValue, value[key] { return fieldValue; } @@ -97,18 +97,6 @@ abstract class AbstractValidator implements ValidatorInterface return value; } - /** - * Checks if an option is defined - * - * @param string $key - * - * @return bool - */ - public function hasOption(string! key) -> bool - { - return isset this->options[key]; - } - /** * Get the template message * @@ -142,6 +130,18 @@ abstract class AbstractValidator implements ValidatorInterface return this->templates; } + /** + * Checks if an option is defined + * + * @param string $key + * + * @return bool + */ + public function hasOption(string key) -> bool + { + return isset this->options[key]; + } + /** * Create a default message by factory * @@ -151,8 +151,11 @@ abstract class AbstractValidator implements ValidatorInterface * * @return Message */ - public function messageFactory( validation, var field, array! replacements = []) -> - { + public function messageFactory( + validation, + var field, + array replacements = [] + ) -> { var singleField; if typeof field == "array" { @@ -186,7 +189,7 @@ abstract class AbstractValidator implements ValidatorInterface * * @return void */ - public function setOption(string! key, value) -> void + public function setOption(string key, value) -> void { let this->options[key] = value; } @@ -239,8 +242,8 @@ abstract class AbstractValidator implements ValidatorInterface /** * Checks if field can be empty. * - * @param string $field - * @param mixed $value + * @param mixed $field + * @param mixed $value * * @return bool */ @@ -305,7 +308,7 @@ abstract class AbstractValidator implements ValidatorInterface * * @return mixed */ - protected function prepareLabel( validation, string! field) -> var + protected function prepareLabel( validation, string field) -> var { var label; From 7effe5b966ac399be4d862ededa8c4bc9dbbb584 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Fri, 29 Sep 2023 15:59:41 -0500 Subject: [PATCH 13/57] reorganizing cli tests --- tests/cli/Cli/Router/HandleCest.php | 307 +++++++----------- tests/cli/Cli/Task/UnderscoreGetCest.php | 6 +- .../Di/FactoryDefault/Cli/ConstructCest.php | 69 +--- tests/cli/Di/FactoryDefault/Cli/GetCest.php | 2 +- .../Cli/GetInternalEventsManagerCest.php | 2 +- ...ultCest.php => GetSetDefaultResetCest.php} | 25 +- .../Di/FactoryDefault/Cli/GetSharedCest.php | 2 +- .../Di/FactoryDefault/Cli/OffsetSetCest.php | 2 +- tests/cli/Di/FactoryDefault/Cli/ResetCest.php | 46 --- tests/cli/Di/FactoryDefault/Cli/SetCest.php | 2 +- .../Di/FactoryDefault/Cli/SetDefaultCest.php | 46 --- 11 files changed, 145 insertions(+), 364 deletions(-) rename tests/cli/Di/FactoryDefault/Cli/{GetDefaultCest.php => GetSetDefaultResetCest.php} (51%) delete mode 100644 tests/cli/Di/FactoryDefault/Cli/ResetCest.php delete mode 100644 tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php diff --git a/tests/cli/Cli/Router/HandleCest.php b/tests/cli/Cli/Router/HandleCest.php index b6a62c5fb14..2f97762dcce 100644 --- a/tests/cli/Cli/Router/HandleCest.php +++ b/tests/cli/Cli/Router/HandleCest.php @@ -64,101 +64,10 @@ public function cliRouterHandleRouter(CliTester $I, Example $example) Route::reset(); $router = new Router(); - - $router->add( - ' ', - [ - 'module' => 'devtools', - 'task' => 'main', - 'action' => 'hello', - ] - ); - - $router->add( - 'system :task a :action :params', - [ - 'task' => 1, - 'action' => 2, - 'params' => 3, - ] - ); - - $router->add( - '([a-z]{2}) :task', - [ - 'task' => 2, - 'action' => 'index', - 'language' => 1, - ] - ); - - $router->add( - 'admin :task :action :int', - [ - 'module' => 'admin', - 'task' => 1, - 'action' => 2, - 'id' => 3, - ] - ); - - $router->add( - 'posts ([0-9]{4}) ([0-9]{2}) ([0-9]{2}) :params', - [ - 'task' => 'posts', - 'action' => 'show', - 'year' => 1, - 'month' => 2, - 'day' => 3, - 'params' => 4, - ] - ); - - $router->add( - 'manual ([a-z]{2}) ([a-z\.]+)\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - 'language' => 1, - 'file' => 2, - ] - ); - - $router->add( - 'named-manual {language:([a-z]{2})} {file:[a-z\.]+}\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - ] - ); - - $router->add( - 'very static route', - [ - 'task' => 'static', - 'action' => 'route', - ] - ); - - $router->add( - "feed {lang:[a-z]+} blog {blog:[a-z\-]+}\.{type:[a-z\-]+}", - 'Feed::get' - ); - - $router->add( - "posts {year:[0-9]+} s {title:[a-z\-]+}", - 'Posts::show' - ); - - $router->add( - 'posts delete {id}', - 'Posts::delete' - ); - - $router->add( - "show {id:video([0-9]+)} {title:[a-z\-]+}", - 'Videos::show' - ); + $routes = $this->setupRoutes('router'); + foreach ($routes as $pattern => $parameters) { + $router->add($pattern, $parameters); + } $this->assertParameters($I, $router, $example); } @@ -186,107 +95,16 @@ public function cliRouterHandleRouterParams(CliTester $I, Example $example) * @return void * @throws Exception */ - public function testDelimiter(CliTester $I, Example $example) + public function cliRouterHandleRouterDelimiter(CliTester $I, Example $example) { Route::reset(); Route::delimiter('/'); $router = new Router(); - - $router->add( - '/', - [ - 'module' => 'devtools', - 'task' => 'main', - 'action' => 'hello', - ] - ); - - $router->add( - '/system/:task/a/:action/:params', - [ - 'task' => 1, - 'action' => 2, - 'params' => 3, - ] - ); - - $router->add( - '/([a-z]{2})/:task', - [ - 'task' => 2, - 'action' => 'index', - 'language' => 1, - ] - ); - - $router->add( - '/admin/:task/:action/:int', - [ - 'module' => 'admin', - 'task' => 1, - 'action' => 2, - 'id' => 3, - ] - ); - - $router->add( - '/posts/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params', - [ - 'task' => 'posts', - 'action' => 'show', - 'year' => 1, - 'month' => 2, - 'day' => 3, - 'params' => 4, - ] - ); - - $router->add( - '/manual/([a-z]{2})/([a-z\.]+)\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - 'language' => 1, - 'file' => 2, - ] - ); - - $router->add( - '/named-manual/{language:([a-z]{2})}/{file:[a-z\.]+}\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - ] - ); - - $router->add( - '/very/static/route', - [ - 'task' => 'static', - 'action' => 'route', - ] - ); - - $router->add( - "/feed/{lang:[a-z]+}/blog/{blog:[a-z\-]+}\.{type:[a-z\-]+}", - 'Feed::get' - ); - - $router->add( - "/posts/{year:[0-9]+}/s/{title:[a-z\-]+}", - 'Posts::show' - ); - - $router->add( - '/posts/delete/{id}', - 'Posts::delete' - ); - - $router->add( - "/show/{id:video([0-9]+)}/{title:[a-z\-]+}", - 'Videos::show' - ); + $routes = $this->setupRoutes('delimiter'); + foreach ($routes as $pattern => $parameters) { + $router->add($pattern, $parameters); + } $this->assertParameters($I, $router, $example); } @@ -743,4 +561,111 @@ private function getExamplesDelimiter(): array ], ]; } + + private function setupRoutes(string $test): array + { + $routes = [ + 'router' => [ + ' ' => [ + 'module' => 'devtools', + 'task' => 'main', + 'action' => 'hello', + ], + 'system :task a :action :params' => [ + 'task' => 1, + 'action' => 2, + 'params' => 3, + ], + '([a-z]{2}) :task' => [ + 'task' => 2, + 'action' => 'index', + 'language' => 1, + ], + 'admin :task :action :int' => [ + 'module' => 'admin', + 'task' => 1, + 'action' => 2, + 'id' => 3, + ], + 'posts ([0-9]{4}) ([0-9]{2}) ([0-9]{2}) :params' => [ + 'task' => 'posts', + 'action' => 'show', + 'year' => 1, + 'month' => 2, + 'day' => 3, + 'params' => 4, + ], + 'manual ([a-z]{2}) ([a-z\.]+)\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + 'language' => 1, + 'file' => 2, + ], + 'named-manual {language:([a-z]{2})} {file:[a-z\.]+}\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + ], + 'very static route' => [ + 'task' => 'static', + 'action' => 'route', + ], + "feed {lang:[a-z]+} blog {blog:[a-z\-]+}\.{type:[a-z\-]+}" => 'Feed::get', + "posts {year:[0-9]+} s {title:[a-z\-]+}" => 'Posts::show', + 'posts delete {id}' => 'Posts::delete', + "show {id:video([0-9]+)} {title:[a-z\-]+}" => 'Videos::show', + ], + 'delimiter' => [ + '/' => [ + 'module' => 'devtools', + 'task' => 'main', + 'action' => 'hello', + ], + '/system/:task/a/:action/:params' => [ + 'task' => 1, + 'action' => 2, + 'params' => 3, + ], + '/([a-z]{2})/:task' => [ + 'task' => 2, + 'action' => 'index', + 'language' => 1, + ], + '/admin/:task/:action/:int' => [ + 'module' => 'admin', + 'task' => 1, + 'action' => 2, + 'id' => 3, + ], + '/posts/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params' => [ + 'task' => 'posts', + 'action' => 'show', + 'year' => 1, + 'month' => 2, + 'day' => 3, + 'params' => 4, + ], + '/manual/([a-z]{2})/([a-z\.]+)\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + 'language' => 1, + 'file' => 2, + ], + '/named-manual/{language:([a-z]{2})}/{file:[a-z\.]+}\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + ], + '/very/static/route' => [ + 'task' => 'static', + 'action' => 'route', + ], + "/feed/{lang:[a-z]+}/blog/{blog:[a-z\-]+}\.{type:[a-z\-]+}" => 'Feed::get', + "/posts/{year:[0-9]+}/s/{title:[a-z\-]+}" => 'Posts::show', + '/posts/delete/{id}' => 'Posts::delete', + "/show/{id:video([0-9]+)}/{title:[a-z\-]+}" => 'Videos::show', + + ], + ]; + + return $routes[$test] ?? []; + } } diff --git a/tests/cli/Cli/Task/UnderscoreGetCest.php b/tests/cli/Cli/Task/UnderscoreGetCest.php index cf0d8d542b7..d4d517244d0 100644 --- a/tests/cli/Cli/Task/UnderscoreGetCest.php +++ b/tests/cli/Cli/Task/UnderscoreGetCest.php @@ -41,8 +41,8 @@ public function cliTaskUnderscoreGet(CliTester $I) $actual = $task->di; $I->assertSame($expected, $actual); - $class = Manager::class; - $actual = $task->eventsManager; - $I->assertInstanceOf($class, $actual); + $expected = $eventsManager; + $actual = $task->eventsManager; + $I->assertSame($expected, $actual); } } diff --git a/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php b/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php index 92feffbf263..19149a28edd 100644 --- a/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php @@ -15,22 +15,13 @@ use CliTester; use Codeception\Example; -use Phalcon\Annotations\Adapter\Memory as AnnotationsMemory; -use Phalcon\Cli\Dispatcher; -use Phalcon\Cli\Router; use Phalcon\Di\FactoryDefault\Cli; -use Phalcon\Html\Escaper; -use Phalcon\Events\Manager as EventsManager; -use Phalcon\Filter\Filter; -use Phalcon\Html\TagFactory; -use Phalcon\Mvc\Model\Manager as ModelsManager; -use Phalcon\Mvc\Model\MetaData\Memory; -use Phalcon\Mvc\Model\Transaction\Manager; -use Phalcon\Encryption\Security; -use Phalcon\Support\HelperFactory; +use Phalcon\Tests\Fixtures\Traits\CliTrait; class ConstructCest { + use CliTrait; + /** * Tests Phalcon\Di\FactoryDefault\Cli :: __construct() * @@ -73,58 +64,4 @@ public function diFactoryDefaultCliConstructServices(CliTester $I, Example $exam $actual = $container->get($example['service'], $params); $I->assertInstanceOf($class, $actual); } - - private function getServices(): array - { - return [ - [ - 'service' => 'annotations', - 'class' => AnnotationsMemory::class, - ], - [ - 'service' => 'dispatcher', - 'class' => Dispatcher::class, - ], - [ - 'service' => 'escaper', - 'class' => Escaper::class, - ], - [ - 'service' => 'eventsManager', - 'class' => EventsManager::class, - ], - [ - 'service' => 'filter', - 'class' => Filter::class, - ], - [ - 'service' => 'helper', - 'class' => HelperFactory::class, - ], - [ - 'service' => 'modelsManager', - 'class' => ModelsManager::class, - ], - [ - 'service' => 'modelsMetadata', - 'class' => Memory::class, - ], - [ - 'service' => 'router', - 'class' => Router::class, - ], - [ - 'service' => 'security', - 'class' => Security::class, - ], - [ - 'service' => 'tag', - 'class' => TagFactory::class, - ], - [ - 'service' => 'transactionManager', - 'class' => Manager::class, - ], - ]; - } } diff --git a/tests/cli/Di/FactoryDefault/Cli/GetCest.php b/tests/cli/Di/FactoryDefault/Cli/GetCest.php index b8385940012..eeecee331e3 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetCest.php @@ -41,7 +41,7 @@ public function diFactorydefaultCliGet(CliTester $I) $I->assertFalse($actual->isShared()); // get escaper service - $actual = $di->get('escaper'); + $actual = $di->get('escaper'); $expected = new Escaper(); $I->assertInstanceOf(Escaper::class, $actual); diff --git a/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php b/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php index dfaa3e3bd31..3607eb95e06 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php @@ -37,7 +37,7 @@ public function diFactorydefaultCliGetInternalEventsManager(CliTester $I) $di->setInternalEventsManager(new Manager()); - $class = ManagerInterface::class; + $class = ManagerInterface::class; $actual = $di->getInternalEventsManager(); $I->assertInstanceOf($class, $actual); } diff --git a/tests/cli/Di/FactoryDefault/Cli/GetDefaultCest.php b/tests/cli/Di/FactoryDefault/Cli/GetSetDefaultResetCest.php similarity index 51% rename from tests/cli/Di/FactoryDefault/Cli/GetDefaultCest.php rename to tests/cli/Di/FactoryDefault/Cli/GetSetDefaultResetCest.php index cac24e0da5a..a00324c5104 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetDefaultCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetSetDefaultResetCest.php @@ -16,31 +16,42 @@ use CliTester; use Phalcon\Di\FactoryDefault\Cli as Di; -class GetDefaultCest +use function spl_object_hash; + +class GetSetDefaultResetCest { /** - * Tests Phalcon\Di\FactoryDefault\Cli :: getDefault() + * Tests Phalcon\Di\FactoryDefault\Cli :: getDefault()/setDefault()/reset() * * @author Phalcon Team * @since 2018-11-13 */ public function diFactorydefaultCliGetDefault(CliTester $I) { - $I->wantToTest('Di\FactoryDefault\Cli - getDefault()'); + $I->wantToTest('Di\FactoryDefault\Cli - getDefault()/setDefault()/reset()'); // there is a DI container $I->assertInstanceOf(Di::class, Di::getDefault()); - $di = Di::getDefault(); + $container = Di::getDefault(); // delete it Di::reset(); - $I->assertNull(Di::getDefault()); + // Get a new container + $new = Di::getDefault(); + + $I->assertNull($new); // set it again - Di::setDefault($di); + Di::setDefault($container); - $I->assertInstanceOf(Di::class, Di::getDefault()); + $class = Di::class; + $actual = Di::getDefault(); + $I->assertInstanceOf($class, $actual); + + $containerHash = spl_object_hash($container); + $currentHash = spl_object_hash($actual); + $I->assertSame($containerHash, $currentHash); } } diff --git a/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php b/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php index 302117cf31f..18f0d4d81d9 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; use CliTester; -use Phalcon\Encryption\Crypt; use Phalcon\Di\FactoryDefault\Cli as Di; +use Phalcon\Encryption\Crypt; use Phalcon\Html\Escaper; class GetSharedCest diff --git a/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php b/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php index 9572b2cb7c2..acc00e93c15 100644 --- a/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; use CliTester; -use Phalcon\Encryption\Crypt; use Phalcon\Di\FactoryDefault\Cli as Di; +use Phalcon\Encryption\Crypt; use Phalcon\Html\Escaper; class OffsetSetCest diff --git a/tests/cli/Di/FactoryDefault/Cli/ResetCest.php b/tests/cli/Di/FactoryDefault/Cli/ResetCest.php deleted file mode 100644 index 8d58ed1523d..00000000000 --- a/tests/cli/Di/FactoryDefault/Cli/ResetCest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; - -use CliTester; -use Phalcon\Di\FactoryDefault\Cli as Di; - -class ResetCest -{ - /** - * Tests Phalcon\Di\FactoryDefault\Cli :: reset() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function diFactorydefaultCliReset(CliTester $I) - { - $I->wantToTest('Di\FactoryDefault\Cli - reset()'); - - // there is a DI container - $I->assertInstanceOf(Di::class, Di::getDefault()); - - $di = Di::getDefault(); - - // delete it - Di::reset(); - - $I->assertNull(Di::getDefault()); - - // set it again - Di::setDefault($di); - - $I->assertInstanceOf(Di::class, Di::getDefault()); - } -} diff --git a/tests/cli/Di/FactoryDefault/Cli/SetCest.php b/tests/cli/Di/FactoryDefault/Cli/SetCest.php index 3abe83a05a9..7f8804e63aa 100644 --- a/tests/cli/Di/FactoryDefault/Cli/SetCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/SetCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; use CliTester; -use Phalcon\Encryption\Crypt; use Phalcon\Di\FactoryDefault\Cli as Di; +use Phalcon\Encryption\Crypt; use Phalcon\Html\Escaper; class SetCest diff --git a/tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php b/tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php deleted file mode 100644 index a1f10e62279..00000000000 --- a/tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; - -use CliTester; -use Phalcon\Di\FactoryDefault\Cli as Di; - -class SetDefaultCest -{ - /** - * Tests Phalcon\Di\FactoryDefault\Cli :: setDefault() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function diFactorydefaultCliSetDefault(CliTester $I) - { - $I->wantToTest('Di\FactoryDefault\Cli - setDefault()'); - - // there is a DI container - $I->assertInstanceOf(Di::class, Di::getDefault()); - - $di = Di::getDefault(); - - // delete it - Di::reset(); - - $I->assertNull(Di::getDefault()); - - // set it again - Di::setDefault($di); - - $I->assertInstanceOf(Di::class, Di::getDefault()); - } -} From c00630b100e19671b7f844fe41136d21fae15415 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Fri, 29 Sep 2023 16:00:06 -0500 Subject: [PATCH 14/57] phpcs on tests --- tests/_data/fixtures/Http/PhpStream.php | 41 +++++++----- tests/_data/fixtures/Tasks/MainTask.php | 2 +- .../Acl/Adapter/Memory/AddInheritCest.php | 3 +- .../unit/Acl/Adapter/Memory/IsAllowedCest.php | 29 ++++++--- .../Security/JWT/Token/Parser/ParseCest.php | 63 +++++++++++++------ tests/unit/Flash/Direct/OutputCest.php | 1 - tests/unit/Flash/Session/OutputCest.php | 2 +- 7 files changed, 94 insertions(+), 47 deletions(-) diff --git a/tests/_data/fixtures/Http/PhpStream.php b/tests/_data/fixtures/Http/PhpStream.php index eb0a7741873..763f1ccee38 100644 --- a/tests/_data/fixtures/Http/PhpStream.php +++ b/tests/_data/fixtures/Http/PhpStream.php @@ -36,6 +36,9 @@ class PhpStream */ protected $data = ''; + /** + * Constructor + */ public function __construct() { if (file_exists($this->getBufferFilename())) { @@ -48,26 +51,21 @@ public function __construct() $this->length = strlen($this->data); } - protected function getBufferFilename(): string - { - return codecept_output_dir('tests/stream/php_input.txt'); - } - - public function stream_open($path, $mode, $options, &$opened_path) + public function stream_close() { - return true; } - public function stream_close() + public function stream_eof() { + return ($this->index >= $this->length); } - public function stream_stat() + public function stream_flush() { - return []; + return true; } - public function stream_flush() + public function stream_open($path, $mode, $options, &$opened_path) { return true; } @@ -89,11 +87,6 @@ public function stream_read($count) return $data; } - public function stream_eof() - { - return ($this->index >= $this->length); - } - public function stream_seek($offset, $whence) { if (null === $this->length) { @@ -133,6 +126,17 @@ public function stream_seek($offset, $whence) } } + public function stream_stat() + { + return []; + } + + public function stream_tell() + { + return $this->index; + } + + public function stream_write($data) { return file_put_contents( @@ -153,4 +157,9 @@ public function unlink() $this->index = 0; $this->length = 0; } + + protected function getBufferFilename(): string + { + return codecept_output_dir('tests/stream/php_input.txt'); + } } diff --git a/tests/_data/fixtures/Tasks/MainTask.php b/tests/_data/fixtures/Tasks/MainTask.php index cca2638d309..c3f2fd4d5df 100644 --- a/tests/_data/fixtures/Tasks/MainTask.php +++ b/tests/_data/fixtures/Tasks/MainTask.php @@ -45,7 +45,7 @@ public function argumentsAction( string $world, string $symbol, string $country, - $last + mixed $last ) { return '-' . $world . '-' . $symbol . '-' . $country . '-' . (string) $last . '-'; } diff --git a/tests/unit/Acl/Adapter/Memory/AddInheritCest.php b/tests/unit/Acl/Adapter/Memory/AddInheritCest.php index bc048ace411..b8989817d9d 100644 --- a/tests/unit/Acl/Adapter/Memory/AddInheritCest.php +++ b/tests/unit/Acl/Adapter/Memory/AddInheritCest.php @@ -150,7 +150,8 @@ function () { } /** - * Tests Phalcon\Acl\Adapter\Memory :: addInherit() - infinite loop exception + * Tests Phalcon\Acl\Adapter\Memory :: addInherit() - infinite loop + * exception * * @param UnitTester $I * diff --git a/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php b/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php index 521beb38771..b142b3ee06b 100644 --- a/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php +++ b/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php @@ -128,7 +128,10 @@ public function aclAdapterMemoryIsAllowedSameClass(UnitTester $I) 'Admin', 'User', ['update'], - function (TestRoleComponentAware $admin, TestRoleComponentAware $user) { + function ( + TestRoleComponentAware $admin, + TestRoleComponentAware $user + ) { return $admin->getUser() == $user->getUser(); } ); @@ -182,8 +185,9 @@ function () { * @author Phalcon Team * @since 2021-09-27 */ - public function aclAdapterMemoryIsAllowedFunctionMoreParameters(UnitTester $I) - { + public function aclAdapterMemoryIsAllowedFunctionMoreParameters( + UnitTester $I + ) { $I->wantToTest('Acl\Adapter\Memory - isAllowed() - more parameters'); $errorMessage = "Number of parameters in array is higher than the " @@ -239,16 +243,19 @@ function ($parameter) { * @author Phalcon Team * @since 2019-06-16 */ - public function aclAdapterMemoryIsAllowedFunctionNotEnoughParameters(UnitTester $I) - { - $I->wantToTest('Acl\Adapter\Memory - isAllowed() - not enough parameters'); + public function aclAdapterMemoryIsAllowedFunctionNotEnoughParameters( + UnitTester $I + ) { + $I->wantToTest( + 'Acl\Adapter\Memory - isAllowed() - not enough parameters' + ); $I->expectThrowable( new AclException( "You did not provide all necessary parameters for the " . "defined function when checking if 'Members' can 'update' for 'Post'." ), - function () use ($I) { + function () { $acl = new Memory(); $acl->setDefaultAction(Enum::ALLOW); @@ -335,7 +342,9 @@ function () { */ public function aclAdapterMemoryIsAllowedFireEventFalse(UnitTester $I) { - $I->wantToTest('Acl\Adapter\Memory - isAllowed() - fireEvent returns false'); + $I->wantToTest( + 'Acl\Adapter\Memory - isAllowed() - fireEvent returns false' + ); $acl = Stub::make( Memory::class, @@ -362,7 +371,9 @@ public function aclAdapterMemoryIsAllowedFireEventFalse(UnitTester $I) */ public function aclAdapterMemoryIsAllowedDocumentationExample(UnitTester $I) { - $I->wantToTest('Acl\Adapter\Memory - isAllowed() - documentation example'); + $I->wantToTest( + 'Acl\Adapter\Memory - isAllowed() - documentation example' + ); $acl = new Memory(); diff --git a/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php b/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php index ba2ce20ac64..2018ae720b5 100644 --- a/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php +++ b/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php @@ -66,14 +66,23 @@ public function encryptionSecurityJWTTokenParserParse(UnitTester $I) $I->assertTrue($claims->has('sub')); $I->assertSame(['my-audience'], $claims->get('aud')); - $I->assertSame($token->getClaims() - ->get('exp'), $claims->get('exp')); + $I->assertSame( + $token->getClaims() + ->get('exp'), + $claims->get('exp') + ); $I->assertSame('PH-JWT', $claims->get('jti')); - $I->assertSame($token->getClaims() - ->get('iat'), $claims->get('iat')); + $I->assertSame( + $token->getClaims() + ->get('iat'), + $claims->get('iat') + ); $I->assertSame('Phalcon JWT', $claims->get('iss')); - $I->assertSame($token->getClaims() - ->get('nbf'), $claims->get('nbf')); + $I->assertSame( + $token->getClaims() + ->get('nbf'), + $claims->get('nbf') + ); $I->assertSame('Mary had a little lamb', $claims->get('sub')); } @@ -116,14 +125,23 @@ public function encryptionSecurityJWTTokenParserParseNoSignature(UnitTester $I) $I->assertTrue($claims->has('sub')); $I->assertSame(['my-audience'], $claims->get('aud')); - $I->assertSame($token->getClaims() - ->get('exp'), $claims->get('exp')); + $I->assertSame( + $token->getClaims() + ->get('exp'), + $claims->get('exp') + ); $I->assertSame('PH-JWT', $claims->get('jti')); - $I->assertSame($token->getClaims() - ->get('iat'), $claims->get('iat')); + $I->assertSame( + $token->getClaims() + ->get('iat'), + $claims->get('iat') + ); $I->assertSame('Phalcon JWT', $claims->get('iss')); - $I->assertSame($token->getClaims() - ->get('nbf'), $claims->get('nbf')); + $I->assertSame( + $token->getClaims() + ->get('nbf'), + $claims->get('nbf') + ); $I->assertSame('Mary had a little lamb', $claims->get('sub')); $I->assertEmpty($signature->getEncoded()); @@ -175,14 +193,23 @@ public function encryptionSecurityJWTTokenParserParseAudNotAnArray(UnitTester $I $I->assertTrue($claims->has('sub')); $I->assertSame(['my-audience'], $claims->get('aud')); - $I->assertSame($token->getClaims() - ->get('exp'), $claims->get('exp')); + $I->assertSame( + $token->getClaims() + ->get('exp'), + $claims->get('exp') + ); $I->assertSame('PH-JWT', $claims->get('jti')); - $I->assertSame($token->getClaims() - ->get('iat'), $claims->get('iat')); + $I->assertSame( + $token->getClaims() + ->get('iat'), + $claims->get('iat') + ); $I->assertSame('Phalcon JWT', $claims->get('iss')); - $I->assertSame($token->getClaims() - ->get('nbf'), $claims->get('nbf')); + $I->assertSame( + $token->getClaims() + ->get('nbf'), + $claims->get('nbf') + ); $I->assertSame('Mary had a little lamb', $claims->get('sub')); } diff --git a/tests/unit/Flash/Direct/OutputCest.php b/tests/unit/Flash/Direct/OutputCest.php index 083353d8ae8..5863f260226 100644 --- a/tests/unit/Flash/Direct/OutputCest.php +++ b/tests/unit/Flash/Direct/OutputCest.php @@ -18,7 +18,6 @@ use Phalcon\Html\Escaper; use UnitTester; -use function MongoDB\BSON\toRelaxedExtendedJSON; use function ob_end_clean; use function ob_get_contents; use function ob_start; diff --git a/tests/unit/Flash/Session/OutputCest.php b/tests/unit/Flash/Session/OutputCest.php index c5e1db0d18a..b7c7b2f66a3 100644 --- a/tests/unit/Flash/Session/OutputCest.php +++ b/tests/unit/Flash/Session/OutputCest.php @@ -128,7 +128,7 @@ public function flashSessionOutputWithCustomTemplate(UnitTester $I) $flash = new Session(); $flash->setDI($this->container); - $message1 = uniqid('m-'); + $message1 = uniqid('m-'); $customTemplate = " ", &_0); + zephir_get_strval(&template, &_1); + ZEPHIR_INIT_VAR(&divString); + ZEPHIR_INIT_VAR(&iconString); + zephir_read_property(&_2, this_ptr, ZEND_STRL("customTemplate"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_IS_EMPTY(&_2))) { + RETURN_MM_MEMBER(getThis(), "customTemplate"); } - _1 = zephir_get_iterator(&messages); - _1->funcs->rewind(_1); - for (;_1->funcs->valid(_1) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1)) { - { - ZEPHIR_ITERATOR_COPY(&message, _1); + if (!(ZEPHIR_IS_EMPTY(&cssClassses))) { + ZEPHIR_INIT_NVAR(&divString); + ZVAL_STRING(&divString, " class=\"%cssClass%\""); + if (!(ZEPHIR_IS_EMPTY(&cssIconClasses))) { + ZEPHIR_INIT_NVAR(&iconString); + ZVAL_STRING(&iconString, " "); } - ZEPHIR_INIT_NVAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_messages_message_ce); - ZEPHIR_CALL_METHOD(&_3$$4, &message, "getmessage", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$4, &message, "getfield", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$4, &message, "gettype", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$4, &message, "getcode", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$4, &message, "getmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", &_8, 6, &_3$$4, &_4$$4, &_5$$4, &_6$$4, &_7$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_9, 0, &_2$$4); - zephir_check_call_status(); } - zend_iterator_dtor(_1); - RETURN_MM_BOOL(!(zephir_fast_count_int(&messages))); + zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4); + zephir_create_array(&_4, 2, 0); + zephir_array_update_string(&_4, SL("divString"), &divString, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_4, SL("iconString"), &iconString, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &template, &_4); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, validationHasFailed) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareEscapedMessage) { - zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, escaper, _0; + zval message; zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&escaper); ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_fast_count_int(&_0) > 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("autoescape"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_CTOR(&message); + } + ZEPHIR_CALL_METHOD(&escaper, this_ptr, "getescaperservice", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&escaper, "escapehtml", NULL, 0, &message); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, caseInsensitiveColumnMap) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareHtmlMessage) { + zval _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columnMap, columnMap_sub, *key, key_sub, cmKey, _0, *_1, _2, _3$$3, _4$$3, _5$$5, _6$$5; + zval *type_param = NULL, *message_param = NULL, cssClasses, cssIconClasses, _0, _1, _2, _3, _4; + zval type, message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columnMap_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&cmKey); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&cssClasses); + ZVAL_UNDEF(&cssIconClasses); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(columnMap) - Z_PARAM_ZVAL(key) + Z_PARAM_STR(type) + Z_PARAM_STR(message) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &columnMap, &key); + zephir_fetch_params(1, 2, 0, &type_param, &message_param); + zephir_get_strval(&type, type_param); + zephir_get_strval(&message, message_param); - ZEPHIR_INIT_VAR(&_0); - zephir_array_keys(&_0, columnMap); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model.zep", 5941); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&cmKey); - ZVAL_COPY(&cmKey, _1); - ZEPHIR_INIT_NVAR(&_3$$3); - zephir_fast_strtolower(&_3$$3, &cmKey); - ZEPHIR_INIT_NVAR(&_4$$3); - zephir_fast_strtolower(&_4$$3, key); - if (ZEPHIR_IS_EQUAL(&_3$$3, &_4$$3)) { - RETURN_CCTOR(&cmKey); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&cmKey, &_0, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$5); - zephir_fast_strtolower(&_5$$5, &cmKey); - ZEPHIR_INIT_NVAR(&_6$$5); - zephir_fast_strtolower(&_6$$5, key); - if (ZEPHIR_IS_EQUAL(&_5$$5, &_6$$5)) { - RETURN_CCTOR(&cmKey); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("automaticHtml"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_CTOR(&message); } - ZEPHIR_INIT_NVAR(&cmKey); - RETVAL_ZVAL(key, 1, 0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&cssClasses, this_ptr, "checkclasses", NULL, 83, &_1, &type); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&cssIconClasses, this_ptr, "checkclasses", NULL, 83, &_2, &type); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettemplate", NULL, 84, &cssClasses, &cssIconClasses); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_5); + zephir_create_array(&_5, 3, 0); + zephir_array_update_string(&_5, SL("cssClass"), &cssClasses, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5, SL("cssIconClass"), &cssIconClasses, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &_4, &_5); + zephir_check_call_status(); RETURN_MM(); } -/*** - * Append messages to this model from another Model. - */ -static PHP_METHOD(Phalcon_Mvc_Model, appendMessagesFrom) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, checkClasses) { - zval _2$$5, _4$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, messages, message, *_0$$3, _1$$3; + zval type; + zval *collection_param = NULL, *type_param = NULL, content, _0$$5, _1$$4; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&type); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(model) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 2, 0, &collection_param, &type_param); + zephir_get_arrval(&collection, collection_param); + zephir_get_strval(&type, type_param); - ZEPHIR_CALL_METHOD(&messages, model, "getmessages", NULL, 0); - zephir_check_call_status(); - if (0 == ZEPHIR_IS_EMPTY(&messages)) { - zephir_is_iterable(&messages, 0, "phalcon/Mvc/Model.zep", 5965); - if (Z_TYPE_P(&messages) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&messages), _0$$3) - { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _0$$3); - if (Z_TYPE_P(&message) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_2$$5); - zephir_create_array(&_2$$5, 1, 0); - zephir_array_update_string(&_2$$5, SL("model"), model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &message, "setmetadata", NULL, 0, &_2$$5); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &messages, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&message) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_4$$7); - zephir_create_array(&_4$$7, 1, 0); - zephir_array_update_string(&_4$$7, SL("model"), model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &message, "setmetadata", NULL, 0, &_4$$7); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&content); + ZVAL_STRING(&content, ""); + if (zephir_array_isset(&collection, &type)) { + ZEPHIR_OBS_NVAR(&content); + zephir_array_fetch(&content, &collection, &type, PH_NOISY, "phalcon/Flash/AbstractFlash.zep", 484); + } + if (1 != ZEPHIR_IS_EMPTY(&content)) { + if (Z_TYPE_P(&content) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$5); + zephir_create_array(&_0$$5, 1, 0); + zephir_array_fast_append(&_0$$5, &content); + ZEPHIR_CPY_WRT(&content, &_0$$5); } - ZEPHIR_INIT_NVAR(&message); + ZEPHIR_INIT_VAR(&_1$$4); + zephir_fast_join_str(&_1$$4, SL(" "), &content); + ZEPHIR_CPY_WRT(&content, &_1$$4); } - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&content); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Flash_AbstractFlash(zend_class_entry *class_type) { - zval _0, _2, _4, _6, _8, _10, _12, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9; + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); ZEPHIR_MM_GROW(); @@ -53434,47 +49628,23 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_ty { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("uniqueTypes"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("uniqueParams"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssIconClasses"), &_3$$4); } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_4) == IS_NULL) { ZEPHIR_INIT_VAR(&_5$$5); array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("snapshot"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("oldSnapshot"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("oldSnapshot"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("related"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errorMessages"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dirtyRelated"), &_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssClasses"), &_5$$5); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -53491,52 +49661,105 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_ty -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModelInterface) +ZEPHIR_INIT_CLASS(Phalcon_Flash_Direct) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModelInterface, phalcon, mvc_modelinterface, phalcon_mvc_modelinterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Direct, phalcon, flash_direct, phalcon_flash_abstractflash_ce, phalcon_flash_direct_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, appendMessage); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, assign); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, average); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResult); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMapHydrate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, count); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, create); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, find); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, findFirst); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEvent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEventCancel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getDirtyState); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getModelsMetaData); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getOperationMade); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getRelated); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSchema); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSource); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, maximum); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, minimum); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, query); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, refresh); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, save); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setDirtyState); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setSnapshotData); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setTransaction); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, skipOperation); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, sum); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, validationHasFailed); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, update); +static PHP_METHOD(Phalcon_Flash_Direct, message) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *message, message_sub; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&message_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_ZVAL(message) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &type_param, &message); + zephir_get_strval(&type, type_param); + + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputmessage", NULL, 0, &type, message); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Flash_Direct, output) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *remove_param = NULL, message, _0, *_1, _2; + zend_bool remove; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(remove) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &remove_param); + if (!remove_param) { + remove = 1; + } else { + remove = zephir_get_boolval(remove_param); + } + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Flash/Direct.zep", 45); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _1); + zend_print_zval(&message, 0); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&message, &_0, "current", NULL, 0); + zephir_check_call_status(); + zend_print_zval(&message, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&message); + if (remove) { + ZEPHIR_CALL_PARENT(NULL, phalcon_flash_direct_ce, getThis(), "clear", &_3, 0); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + @@ -53547,15 +49770,13 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, update); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModuleDefinitionInterface) +ZEPHIR_INIT_CLASS(Phalcon_Flash_Exception) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModuleDefinitionInterface, phalcon, mvc_moduledefinitioninterface, phalcon_mvc_moduledefinitioninterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Exception, phalcon, flash_exception, zend_ce_exception, NULL, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerAutoloaders); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerServices); @@ -53566,765 +49787,576 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerServices); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router) +ZEPHIR_INIT_CLASS(Phalcon_Flash_FlashInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Router, phalcon, mvc_router, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_router_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Flash, FlashInterface, phalcon, flash_flashinterface, phalcon_flash_flashinterface_method_entry); - zend_declare_property_string(phalcon_mvc_router_ce, SL("action"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("controller"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultController"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultModule"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultNamespace"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("defaultParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("keyRouteNames"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("keyRouteIds"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("matchedRoute"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("matches"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("module"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("namespaceName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("notFoundPaths"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("params"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_router_ce, SL("removeExtraSlashes"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("routes"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_router_ce, SL("wasMatched"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_router_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router; - zephir_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_FIRST"), 0); + return SUCCESS; +} - zephir_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_LAST"), 1); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, error); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, message); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, notice); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, success); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, warning); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Flash_Session) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Session, phalcon, flash_session, phalcon_flash_abstractflash_ce, phalcon_flash_session_method_entry, 0); + + zephir_declare_class_constant_string(phalcon_flash_session_ce, SL("SESSION_KEY"), "_flashMessages"); - zend_class_implements(phalcon_mvc_router_ce, 1, phalcon_mvc_routerinterface_ce); - zend_class_implements(phalcon_mvc_router_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router, __construct) +static PHP_METHOD(Phalcon_Flash_Session, clear) { - zval routes, _1$$3, _3$$3; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_1 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *defaultRoutes_param = NULL, _0$$3, _2$$3, _4$$3; - zend_bool defaultRoutes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&routes); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(defaultRoutes) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &defaultRoutes_param); - if (!defaultRoutes_param) { - defaultRoutes = 1; - } else { - if (UNEXPECTED(Z_TYPE_P(defaultRoutes_param) != IS_TRUE && Z_TYPE_P(defaultRoutes_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultRoutes' must be of the type bool")); - RETURN_MM_NULL(); - } - defaultRoutes = (Z_TYPE_P(defaultRoutes_param) == IS_TRUE); - } - - ZEPHIR_INIT_VAR(&routes); - array_init(&routes); - if (defaultRoutes) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_mvc_router_route_ce); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - add_assoc_long_ex(&_1$$3, SL("controller"), 1); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "#^/([\\w0-9\\_\\-]+)[/]{0,1}$#u"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 100, &_2$$3, &_1$$3); - zephir_check_call_status(); - zephir_array_append(&routes, &_0$$3, PH_SEPARATE, "phalcon/Mvc/Router.zep", 170); - ZEPHIR_INIT_NVAR(&_2$$3); - object_init_ex(&_2$$3, phalcon_mvc_router_route_ce); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 3, 0); - add_assoc_long_ex(&_3$$3, SL("controller"), 1); - add_assoc_long_ex(&_3$$3, SL("action"), 2); - add_assoc_long_ex(&_3$$3, SL("params"), 3); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "#^/([\\w0-9\\_\\-]+)/([\\w0-9\\.\\_]+)(/.*)*$#u"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 100, &_4$$3, &_3$$3); - zephir_check_call_status(); - zephir_array_append(&routes, &_2$$3, PH_SEPARATE, "phalcon/Mvc/Router.zep", 179); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &routes); + ZVAL_BOOL(&_0, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "getsessionmessages", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, getThis(), "clear", &_1, 0); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, add) +static PHP_METHOD(Phalcon_Flash_Session, getMessages) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, *position_param = NULL, __$null, route, _0; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool remove; + zval *type = NULL, type_sub, *remove_param = NULL, __$null, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); + ZVAL_UNDEF(&type_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) - Z_PARAM_LONG(position) + Z_PARAM_ZVAL_OR_NULL(type) + Z_PARAM_BOOL(remove) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 3, &pattern_param, &paths, &httpMethods, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; + zephir_fetch_params(1, 0, 2, &type, &remove_param); + if (!type) { + type = &type_sub; + type = &__$null; } - if (!position_param) { - position = 1; + if (!remove_param) { + remove = 1; } else { - position = zephir_get_intval(position_param); + remove = zephir_get_boolval(remove_param); } - ZEPHIR_INIT_VAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 100, &pattern, paths, httpMethods); - zephir_check_call_status(); - ZVAL_LONG(&_0, position); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "attach", NULL, 0, &route, &_0); + if (remove) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsessionmessages", NULL, 0, &_0, type); zephir_check_call_status(); - RETURN_CCTOR(&route); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, addConnect) +static PHP_METHOD(Phalcon_Flash_Session, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, messages, _0; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&messages); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + Z_PARAM_STR_OR_NULL(type) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; + zephir_fetch_params(1, 0, 1, &type_param); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); } else { - position = zephir_get_intval(position_param); + zephir_get_strval(&type, type_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "CONNECT"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + ZVAL_BOOL(&_0, 0); + ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM(); + if (!(!(ZEPHIR_IS_EMPTY(&type)))) { + RETURN_MM_BOOL((1 != ZEPHIR_IS_EMPTY(&messages))); + } + RETURN_MM_BOOL(zephir_array_isset(&messages, &type)); } -static PHP_METHOD(Phalcon_Mvc_Router, addDelete) +static PHP_METHOD(Phalcon_Flash_Session, message) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *message, message_sub, messages, _0, _1$$3; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&message_sub); + ZVAL_UNDEF(&messages); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_1$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_ZVAL(message) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } + zephir_fetch_params(1, 2, 0, &type_param, &message); + zephir_get_strval(&type, type_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DELETE"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + ZVAL_BOOL(&_0, 0); + ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM(); + if (1 != zephir_array_isset(&messages, &type)) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_array_update_zval(&messages, &type, &_1$$3, PH_COPY | PH_SEPARATE); + } + zephir_array_update_multi(&messages, message, SL("za"), 2, &type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsessionmessages", NULL, 0, &messages); + zephir_check_call_status(); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Router, addGet) +static PHP_METHOD(Phalcon_Flash_Session, output) { + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *remove_param = NULL, message, messages, type, _0, *_1, _2; + zend_bool remove; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&type); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + Z_PARAM_BOOL(remove) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 0, 1, &remove_param); + if (!remove_param) { + remove = 1; } else { - ZEPHIR_INIT_VAR(&pattern); + remove = zephir_get_boolval(remove_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + + + if (remove) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); } - if (!position_param) { - position = 1; + ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); + zephir_check_call_status(); + zephir_is_iterable(&messages, 0, "phalcon/Flash/Session.zep", 117); + if (Z_TYPE_P(&messages) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&messages), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&type); + if (_4 != NULL) { + ZVAL_STR_COPY(&type, _4); + } else { + ZVAL_LONG(&type, _3); + } + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_5, 0, &type, &message); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); } else { - position = zephir_get_intval(position_param); + ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &messages, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&type, &messages, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_5, 0, &type, &message); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); + zephir_check_call_status(); + } } - - - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GET"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + ZEPHIR_INIT_NVAR(&message); + ZEPHIR_INIT_NVAR(&type); + ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, getThis(), "clear", &_6, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, addHead) +static PHP_METHOD(Phalcon_Flash_Session, getSessionMessages) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval type; + zval *remove_param = NULL, *type_param = NULL, session, messages, returnMessages, _0, _1$$6, _2$$7; + zend_bool remove; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&returnMessages); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&type); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_BOOL(remove) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + Z_PARAM_STR_OR_NULL(type) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; + zephir_fetch_params(1, 1, 1, &remove_param, &type_param); + remove = zephir_get_boolval(remove_param); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); } else { - position = zephir_get_intval(position_param); + zephir_get_strval(&type, type_param); } + ZEPHIR_CALL_METHOD(&session, this_ptr, "getsessionservice", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HEAD"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + ZVAL_STRING(&_0, "_flashMessages"); + ZEPHIR_CALL_METHOD(&messages, &session, "get", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM(); + if (Z_TYPE_P(&messages) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&messages); + array_init(&messages); + } + if (1 != ZEPHIR_IS_EMPTY(&type)) { + ZEPHIR_OBS_VAR(&returnMessages); + if (zephir_array_isset_fetch(&returnMessages, &messages, &type, 0)) { + if (remove) { + zephir_array_unset(&messages, &type, PH_SEPARATE); + ZEPHIR_INIT_VAR(&_1$$6); + ZVAL_STRING(&_1$$6, "_flashMessages"); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_1$$6, &messages); + zephir_check_call_status(); + } + RETURN_CCTOR(&returnMessages); + } + array_init(return_value); + RETURN_MM(); + } + if (remove) { + ZEPHIR_INIT_VAR(&_2$$7); + ZVAL_STRING(&_2$$7, "_flashMessages"); + ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_2$$7); + zephir_check_call_status(); + } + RETURN_CCTOR(&messages); } -static PHP_METHOD(Phalcon_Mvc_Router, addOptions) +static PHP_METHOD(Phalcon_Flash_Session, setSessionMessages) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *messages_param = NULL, session, _0; + zval messages; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&session); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(messages) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } + zephir_fetch_params(1, 1, 0, &messages_param); + ZEPHIR_OBS_COPY_OR_DUP(&messages, messages_param); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getsessionservice", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OPTIONS"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + ZVAL_STRING(&_0, "_flashMessages"); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_0, &messages); zephir_check_call_status(); - RETURN_MM(); + RETURN_CTOR(&messages); } -static PHP_METHOD(Phalcon_Mvc_Router, addPatch) +static PHP_METHOD(Phalcon_Flash_Session, getSessionService) { + zend_bool _2; + zval _0, _1, _3, _4, _5, _6$$4, _7$$4, _8$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("sessionService"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) != IS_NULL) { + RETURN_MM_MEMBER(getThis(), "sessionService"); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + _2 = Z_TYPE_P(&_1) != IS_NULL; + if (_2) { + zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "session"); + ZEPHIR_CALL_METHOD(&_4, &_3, "has", NULL, 0, &_5); + zephir_check_call_status(); + _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_4); } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); + if (_2) { + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_8$$4); + ZVAL_STRING(&_8$$4, "session"); + ZEPHIR_CALL_METHOD(&_7$$4, &_6$$4, "getshared", NULL, 0, &_8$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("sessionService"), &_7$$4); + RETURN_MM_MEMBER(getThis(), "sessionService"); } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/Flash/Session.zep", 205); + return; +} - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PATCH"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Router, addPost) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "POST"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + +ZEPHIR_INIT_CLASS(Phalcon_Cache_AbstractCache) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Cache, AbstractCache, phalcon, cache_abstractcache, phalcon_cache_abstractcache_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_cache_abstractcache_ce, SL("adapter"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_cache_abstractcache_ce, 1, phalcon_cache_cacheinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router, addPurge) +static PHP_METHOD(Phalcon_Cache_AbstractCache, __construct) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zval *adapter, adapter_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&adapter_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(adapter, phalcon_cache_adapter_adapterinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } + zephir_fetch_params_without_memory_grow(1, 0, &adapter); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PURGE"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), adapter); } -static PHP_METHOD(Phalcon_Mvc_Router, addPut) +static PHP_METHOD(Phalcon_Cache_AbstractCache, getAdapter) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PUT"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "adapter"); } -static PHP_METHOD(Phalcon_Mvc_Router, addTrace) +static PHP_METHOD(Phalcon_Cache_AbstractCache, checkKey) { + zend_class_entry *_6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, exception, _0, _1, _2, _3, _4$$3, _5$$3, _7$$3; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&exception); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "TRACE"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/[^A-Za-z0-9-_.]/"); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "/[^A-Za-z0-9-_.]/"); + zephir_preg_match(&_2, &_3, &key, &_0, 0, 0 , 0 ); + if (zephir_is_true(&_2)) { + ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_fetch_safe_class(&_5$$3, &exception); + _6$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_5$$3), Z_STRLEN_P(&_5$$3), ZEND_FETCH_CLASS_AUTO); + if(!_6$$3) { + RETURN_MM_NULL(); + } + object_init_ex(&_4$$3, _6$$3); + ZEPHIR_INIT_VAR(&_7$$3); + ZVAL_STRING(&_7$$3, "The key contains invalid characters"); + ZEPHIR_CALL_METHOD(NULL, &_4$$3, "__construct", NULL, 0, &_7$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_4$$3, "phalcon/Cache/AbstractCache.zep", 65); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, attach) +static PHP_METHOD(Phalcon_Cache_AbstractCache, checkKeys) { - zval _1$$4; + zend_class_entry *_3$$3; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position; - zval *route, route_sub, *position_param = NULL, _0$$4, _2$$4; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *keys, keys_sub, exception, _1$$3, _2$$3, _4$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&route_sub); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&keys_sub); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(route, phalcon_mvc_router_routeinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(keys) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &route, &position_param); - if (!position_param) { - position = 1; - } else { - position = zephir_get_intval(position_param); - } + zephir_fetch_params(1, 1, 0, &keys); - do { - if (position == 1) { - zephir_update_property_array_append(this_ptr, SL("routes"), route); - break; - } - if (position == 0) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, route); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_0$$4, &_1$$4, &_2$$4); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0$$4); - break; + _0 = Z_TYPE_P(keys) == IS_ARRAY; + if (!(_0)) { + _0 = zephir_zval_is_traversable(keys); + } + if (!(_0)) { + ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_fetch_safe_class(&_2$$3, &exception); + _3$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_2$$3), Z_STRLEN_P(&_2$$3), ZEND_FETCH_CLASS_AUTO); + if(!_3$$3) { + RETURN_MM_NULL(); } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Invalid route position", "phalcon/Mvc/Router.zep", 494); + object_init_ex(&_1$$3, _3$$3); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "The keys need to be an array or instance of Traversable"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0, &_4$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Cache/AbstractCache.zep", 84); + ZEPHIR_MM_RESTORE(); return; - } while(0); - - RETURN_THIS(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, clear) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doClear) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); @@ -54332,2189 +50364,772 @@ static PHP_METHOD(Phalcon_Mvc_Router, clear) ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getEventsManager) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "eventsManager"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getActionName) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "action"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getControllerName) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "controller"); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "clear", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, getDefaults) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doDelete) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, _0; + zval key; zval *this_ptr = getThis(); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - zephir_create_array(return_value, 5, 0); - ZEPHIR_OBS_VAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("namespace"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("module"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultController"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("controller"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("action"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("params"), &_0, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getKeyRouteNames) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "keyRouteNames"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getKeyRouteIds) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "keyRouteIds"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getMatchedRoute) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "matchedRoute"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getMatches) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "matches"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getModuleName) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "module"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getNamespaceName) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "namespaceName"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getParams) -{ - zval *this_ptr = getThis(); - + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - RETURN_MEMBER(getThis(), "params"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "delete", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, getRouteById) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doDeleteMultiple) { - zend_string *_7; - zend_ulong _6; + zend_bool result = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id, id_sub, route, routeId, key, _0, _3, *_4, _5, _1$$3, _2$$3; + zval *keys, keys_sub, key, *_0, _1, _2$$3, _3$$3, _4$$5, _5$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&id_sub); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&routeId); + ZVAL_UNDEF(&keys_sub); ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(id) + Z_PARAM_ZVAL(keys) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &id); + zephir_fetch_params(1, 1, 0, &keys); - ZEPHIR_OBS_VAR(&key); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&key, &_0, id, 0)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router.zep", 614); - RETURN_CTOR(&_2$$3); - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3, 0, "phalcon/Mvc/Router.zep", 626); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, keys); + zephir_check_call_status(); + result = 1; + zephir_is_iterable(keys, 0, "phalcon/Cache/AbstractCache.zep", 132); + if (Z_TYPE_P(keys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _0) { ZEPHIR_INIT_NVAR(&key); - if (_7 != NULL) { - ZVAL_STR_COPY(&key, _7); - } else { - ZVAL_LONG(&key, _6); - } - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _4); - ZEPHIR_CALL_METHOD(&routeId, &route, "getrouteid", NULL, 0); + ZVAL_COPY(&key, _0); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "delete", NULL, 0, &key); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("keyRouteIds"), &routeId, &key); - if (ZEPHIR_IS_EQUAL(&routeId, id)) { - RETURN_CCTOR(&route); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3)) { + result = 0; } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, keys, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_5)) { + if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&key, &_3, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &_3, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, keys, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&routeId, &route, "getrouteid", NULL, 0); + zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5$$5, &_4$$5, "delete", NULL, 0, &key); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("keyRouteIds"), &routeId, &key); - if (ZEPHIR_IS_EQUAL(&routeId, id)) { - RETURN_CCTOR(&route); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5$$5)) { + result = 0; } - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&route); ZEPHIR_INIT_NVAR(&key); - RETURN_MM_BOOL(0); + RETURN_MM_BOOL(result); } -static PHP_METHOD(Phalcon_Mvc_Router, getRouteByName) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doGet) { - zend_string *_7; - zend_ulong _6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, route, routeName, key, _0, _3, *_4, _5, _1$$3, _2$$3; - zval name; + zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, _0; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&routeName); ZVAL_UNDEF(&key); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); + zephir_get_strval(&key, key_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - ZEPHIR_OBS_VAR(&key); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&key, &_0, &name, 0)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router.zep", 641); - RETURN_CTOR(&_2$$3); - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3, 0, "phalcon/Mvc/Router.zep", 656); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) - { - ZEPHIR_INIT_NVAR(&key); - if (_7 != NULL) { - ZVAL_STR_COPY(&key, _7); - } else { - ZVAL_LONG(&key, _6); - } - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _4); - ZEPHIR_CALL_METHOD(&routeName, &route, "getname", NULL, 0); - zephir_check_call_status(); - if (!(ZEPHIR_IS_EMPTY(&routeName))) { - zephir_update_property_array(this_ptr, SL("keyRouteNames"), &routeName, &key); - if (ZEPHIR_IS_EQUAL(&routeName, &name)) { - RETURN_CCTOR(&route); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &_3, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &_3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&routeName, &route, "getname", NULL, 0); - zephir_check_call_status(); - if (!(ZEPHIR_IS_EMPTY(&routeName))) { - zephir_update_property_array(this_ptr, SL("keyRouteNames"), &routeName, &key); - if (ZEPHIR_IS_EQUAL(&routeName, &name)) { - RETURN_CCTOR(&route); - } - } - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - ZEPHIR_INIT_NVAR(&key); - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getRoutes) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "routes"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &key, defaultValue); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, handle) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doGetMultiple) { - zend_string *_27$$33, *_62$$82; - zend_ulong _26$$33, _61$$82; - zval _21$$28, _33$$39, _35$$42, _40$$50, _42$$53, _56$$77, _67$$88, _69$$91, _74$$99, _76$$102; - zend_bool _2, _31$$34, _38$$45, _65$$83, _72$$94; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_18 = NULL, *_20 = NULL, *_23 = NULL, *_30 = NULL, *_53 = NULL, *_55 = NULL, *_58 = NULL, *_78 = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, __$true, __$false, __$null, request, currentHostName, routeFound, parts, params, matches, notFoundPaths, vnamespace, module, controller, action, paramsStr, strParams, route, methods, container, hostname, regexHostName, matched, pattern, handledUri, beforeMatch, paths, converters, part, position, matchPosition, converter, eventsManager, _0, _1, _4, *_6, _7, _79, _80, _81, _82, _83, _3$$3, _5$$6, _8$$9, _9$$9, _10$$9, _11$$8, _12$$8, _13$$13, _14$$13, _15$$13, _16$$17, _17$$23, _19$$27, _22$$31, *_24$$33, _25$$33, _28$$35, _29$$35, _32$$39, _34$$42, _36$$46, _37$$46, _39$$50, _41$$53, _43$$58, _44$$58, _45$$58, _46$$57, _47$$57, _48$$62, _49$$62, _50$$62, _51$$66, _52$$72, _54$$76, _57$$80, *_59$$82, _60$$82, _63$$84, _64$$84, _66$$88, _68$$91, _70$$95, _71$$95, _73$$99, _75$$102, _77$$107, _84$$115, _85$$117, _86$$119; - zval uri; + zval *keys, keys_sub, *defaultValue = NULL, defaultValue_sub, __$null, element, results, *_0, _1, _2$$3, _4$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&keys_sub); + ZVAL_UNDEF(&defaultValue_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&request); - ZVAL_UNDEF(¤tHostName); - ZVAL_UNDEF(&routeFound); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(¬FoundPaths); - ZVAL_UNDEF(&vnamespace); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(¶msStr); - ZVAL_UNDEF(&strParams); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&hostname); - ZVAL_UNDEF(®exHostName); - ZVAL_UNDEF(&matched); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&handledUri); - ZVAL_UNDEF(&beforeMatch); - ZVAL_UNDEF(&paths); - ZVAL_UNDEF(&converters); - ZVAL_UNDEF(&part); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&matchPosition); - ZVAL_UNDEF(&converter); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&results); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_79); - ZVAL_UNDEF(&_80); - ZVAL_UNDEF(&_81); - ZVAL_UNDEF(&_82); - ZVAL_UNDEF(&_83); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$9); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_13$$13); - ZVAL_UNDEF(&_14$$13); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_16$$17); - ZVAL_UNDEF(&_17$$23); - ZVAL_UNDEF(&_19$$27); - ZVAL_UNDEF(&_22$$31); - ZVAL_UNDEF(&_25$$33); - ZVAL_UNDEF(&_28$$35); - ZVAL_UNDEF(&_29$$35); - ZVAL_UNDEF(&_32$$39); - ZVAL_UNDEF(&_34$$42); - ZVAL_UNDEF(&_36$$46); - ZVAL_UNDEF(&_37$$46); - ZVAL_UNDEF(&_39$$50); - ZVAL_UNDEF(&_41$$53); - ZVAL_UNDEF(&_43$$58); - ZVAL_UNDEF(&_44$$58); - ZVAL_UNDEF(&_45$$58); - ZVAL_UNDEF(&_46$$57); - ZVAL_UNDEF(&_47$$57); - ZVAL_UNDEF(&_48$$62); - ZVAL_UNDEF(&_49$$62); - ZVAL_UNDEF(&_50$$62); - ZVAL_UNDEF(&_51$$66); - ZVAL_UNDEF(&_52$$72); - ZVAL_UNDEF(&_54$$76); - ZVAL_UNDEF(&_57$$80); - ZVAL_UNDEF(&_60$$82); - ZVAL_UNDEF(&_63$$84); - ZVAL_UNDEF(&_64$$84); - ZVAL_UNDEF(&_66$$88); - ZVAL_UNDEF(&_68$$91); - ZVAL_UNDEF(&_70$$95); - ZVAL_UNDEF(&_71$$95); - ZVAL_UNDEF(&_73$$99); - ZVAL_UNDEF(&_75$$102); - ZVAL_UNDEF(&_77$$107); - ZVAL_UNDEF(&_84$$115); - ZVAL_UNDEF(&_85$$117); - ZVAL_UNDEF(&_86$$119); - ZVAL_UNDEF(&_21$$28); - ZVAL_UNDEF(&_33$$39); - ZVAL_UNDEF(&_35$$42); - ZVAL_UNDEF(&_40$$50); - ZVAL_UNDEF(&_42$$53); - ZVAL_UNDEF(&_56$$77); - ZVAL_UNDEF(&_67$$88); - ZVAL_UNDEF(&_69$$91); - ZVAL_UNDEF(&_74$$99); - ZVAL_UNDEF(&_76$$102); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(keys) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); - } else { - ZEPHIR_INIT_VAR(&uri); + zephir_fetch_params(1, 1, 1, &keys, &defaultValue); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - ZVAL_LONG(&_0, 5); - ZEPHIR_CALL_FUNCTION(&_1, "parse_url", NULL, 101, &uri, &_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, keys); zephir_check_call_status(); - zephir_get_strval(&uri, &_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("removeExtraSlashes"), PH_NOISY_CC | PH_READONLY); - _2 = zephir_is_true(&_0); - if (_2) { - _2 = !ZEPHIR_IS_STRING_IDENTICAL(&uri, "/"); - } - if (_2) { - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "/"); - ZEPHIR_INIT_VAR(&handledUri); - zephir_fast_trim(&handledUri, &uri, &_3$$3, ZEPHIR_TRIM_RIGHT); - } else { - ZEPHIR_CPY_WRT(&handledUri, &uri); - } - if (ZEPHIR_IS_EMPTY(&handledUri)) { - ZEPHIR_INIT_NVAR(&handledUri); - ZVAL_STRING(&handledUri, "/"); - } - ZEPHIR_INIT_VAR(&request); - ZVAL_NULL(&request); - ZEPHIR_INIT_VAR(¤tHostName); - ZVAL_NULL(¤tHostName); - ZEPHIR_INIT_VAR(&routeFound); - ZVAL_BOOL(&routeFound, 0); - ZEPHIR_INIT_VAR(&parts); - array_init(&parts); - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_VAR(&matches); - ZVAL_NULL(&matches); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &__$null); - zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_4); - if (Z_TYPE_P(&eventsManager) != IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "router:beforeCheckRoutes"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_5$$6, this_ptr); - zephir_check_call_status(); - } - zephir_read_property(&_4, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_4, 0, "phalcon/Mvc/Router.zep", 948); - if (Z_TYPE_P(&_4) == IS_ARRAY) { - ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&_4), _6) + ZEPHIR_INIT_VAR(&results); + array_init(&results); + zephir_is_iterable(keys, 0, "phalcon/Cache/AbstractCache.zep", 168); + if (Z_TYPE_P(keys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _0) { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _6); - ZEPHIR_INIT_NVAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_NVAR(&matches); - ZVAL_NULL(&matches); - ZEPHIR_CALL_METHOD(&methods, &route, "gethttpmethods", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methods) != IS_NULL) { - if (Z_TYPE_P(&request) == IS_NULL) { - zephir_read_property(&_8$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_8$$9); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/Mvc/Router.zep", 739); - return; - } - ZEPHIR_INIT_NVAR(&_10$$9); - ZVAL_STRING(&_10$$9, "request"); - ZEPHIR_CALL_METHOD(&_9$$9, &container, "getshared", NULL, 0, &_10$$9); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&request, &_9$$9); - } - ZVAL_BOOL(&_12$$8, 1); - ZEPHIR_CALL_METHOD(&_11$$8, &request, "ismethod", NULL, 0, &methods, &_12$$8); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$8)) { - continue; - } - } - ZEPHIR_CALL_METHOD(&hostname, &route, "gethostname", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&hostname) != IS_NULL) { - if (Z_TYPE_P(&request) == IS_NULL) { - zephir_read_property(&_13$$13, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_13$$13); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/Mvc/Router.zep", 766); - return; - } - ZEPHIR_INIT_NVAR(&_15$$13); - ZVAL_STRING(&_15$$13, "request"); - ZEPHIR_CALL_METHOD(&_14$$13, &container, "getshared", NULL, 0, &_15$$13); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&request, &_14$$13); - } - if (Z_TYPE_P(¤tHostName) == IS_NULL) { - ZEPHIR_CALL_METHOD(¤tHostName, &request, "gethttphost", NULL, 0); - zephir_check_call_status(); - } - if (!(zephir_is_true(¤tHostName))) { - continue; - } - if (zephir_memnstr_str(&hostname, SL("("), "phalcon/Mvc/Router.zep", 790)) { - if (!(zephir_memnstr_str(&hostname, SL("#"), "phalcon/Mvc/Router.zep", 791))) { - ZEPHIR_INIT_NVAR(®exHostName); - ZEPHIR_CONCAT_SV(®exHostName, "#^", &hostname); - if (!(zephir_memnstr_str(&hostname, SL(":"), "phalcon/Mvc/Router.zep", 794))) { - zephir_concat_self_str(®exHostName, SL("(:[[:digit:]]+)?")); - } - zephir_concat_self_str(®exHostName, SL("$#i")); - } else { - ZEPHIR_CPY_WRT(®exHostName, &hostname); - } - ZEPHIR_INIT_NVAR(&_16$$17); - ZEPHIR_INIT_NVAR(&matched); - zephir_preg_match(&matched, ®exHostName, ¤tHostName, &_16$$17, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&matched); - ZVAL_BOOL(&matched, ZEPHIR_IS_EQUAL(¤tHostName, &hostname)); - } - if (!(zephir_is_true(&matched))) { - continue; - } - } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_17$$23); - ZVAL_STRING(&_17$$23, "router:beforeCheckRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_18, 0, &_17$$23, this_ptr, &route); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _0); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "get", &_3, 0, &element, defaultValue); zephir_check_call_status(); - if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Mvc/Router.zep", 822)) { - ZEPHIR_INIT_NVAR(&routeFound); - zephir_preg_match(&routeFound, &pattern, &handledUri, &matches, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, &handledUri)); - } - if (zephir_is_true(&routeFound)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_19$$27); - ZVAL_STRING(&_19$$27, "router:matchedRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_20, 0, &_19$$27, this_ptr, &route); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Mvc/Router.zep", 844); - return; - } - ZEPHIR_INIT_NVAR(&_21$$28); - zephir_create_array(&_21$$28, 3, 0); - zephir_array_fast_append(&_21$$28, &handledUri); - zephir_array_fast_append(&_21$$28, &route); - zephir_array_fast_append(&_21$$28, this_ptr); - ZEPHIR_INIT_NVAR(&routeFound); - ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_21$$28); - zephir_check_call_status(); - } - } else { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_22$$31); - ZVAL_STRING(&_22$$31, "router:notMatchedRoute"); - ZEPHIR_CALL_METHOD(&routeFound, &eventsManager, "fire", &_23, 0, &_22$$31, this_ptr, &route); - zephir_check_call_status(); - } - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&parts, &paths); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&paths, 0, "phalcon/Mvc/Router.zep", 936); - if (Z_TYPE_P(&paths) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _26$$33, _27$$33, _24$$33) - { - ZEPHIR_INIT_NVAR(&part); - if (_27$$33 != NULL) { - ZVAL_STR_COPY(&part, _27$$33); - } else { - ZVAL_LONG(&part, _26$$33); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _24$$33); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_28$$35); - object_init_ex(&_28$$35, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_29$$35); - ZEPHIR_CONCAT_SV(&_29$$35, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_28$$35, "__construct", &_30, 32, &_29$$35); - zephir_check_call_status(); - zephir_throw_exception_debug(&_28$$35, "phalcon/Mvc/Router.zep", 884); - ZEPHIR_MM_RESTORE(); - return; - } - _31$$34 = Z_TYPE_P(&position) != IS_STRING; - if (_31$$34) { - _31$$34 = Z_TYPE_P(&position) != IS_LONG; - } - if (_31$$34) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_32$$39); - ZEPHIR_INIT_NVAR(&_33$$39); - zephir_create_array(&_33$$39, 1, 0); - zephir_array_fast_append(&_33$$39, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_32$$39, &converter, &_33$$39); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_32$$39, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_34$$42); - ZEPHIR_INIT_NVAR(&_35$$42); - zephir_create_array(&_35$$42, 1, 0); - zephir_array_fast_append(&_35$$42, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_34$$42, &converter, &_35$$42); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_34$$42, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_25$$33, &paths, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_25$$33)) { - break; - } - ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_36$$46); - object_init_ex(&_36$$46, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_37$$46); - ZEPHIR_CONCAT_SV(&_37$$46, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_36$$46, "__construct", &_30, 32, &_37$$46); - zephir_check_call_status(); - zephir_throw_exception_debug(&_36$$46, "phalcon/Mvc/Router.zep", 884); - ZEPHIR_MM_RESTORE(); - return; - } - _38$$45 = Z_TYPE_P(&position) != IS_STRING; - if (_38$$45) { - _38$$45 = Z_TYPE_P(&position) != IS_LONG; - } - if (_38$$45) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_39$$50); - ZEPHIR_INIT_NVAR(&_40$$50); - zephir_create_array(&_40$$50, 1, 0); - zephir_array_fast_append(&_40$$50, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_39$$50, &converter, &_40$$50); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_39$$50, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_41$$53); - ZEPHIR_INIT_NVAR(&_42$$53); - zephir_create_array(&_42$$53, 1, 0); - zephir_array_fast_append(&_42$$53, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_41$$53, &converter, &_42$$53); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_41$$53, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } - ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&part); - zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); - break; - } + zephir_array_update_zval(&results, &element, &_2$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_4, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_7, &_4, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, keys, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_7)) { + if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&route, &_4, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&element, keys, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_NVAR(&matches); - ZVAL_NULL(&matches); - ZEPHIR_CALL_METHOD(&methods, &route, "gethttpmethods", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methods) != IS_NULL) { - if (Z_TYPE_P(&request) == IS_NULL) { - zephir_read_property(&_43$$58, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_43$$58); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/Mvc/Router.zep", 739); - return; - } - ZEPHIR_INIT_NVAR(&_45$$58); - ZVAL_STRING(&_45$$58, "request"); - ZEPHIR_CALL_METHOD(&_44$$58, &container, "getshared", NULL, 0, &_45$$58); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&request, &_44$$58); - } - ZVAL_BOOL(&_47$$57, 1); - ZEPHIR_CALL_METHOD(&_46$$57, &request, "ismethod", NULL, 0, &methods, &_47$$57); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_46$$57)) { - continue; - } - } - ZEPHIR_CALL_METHOD(&hostname, &route, "gethostname", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&hostname) != IS_NULL) { - if (Z_TYPE_P(&request) == IS_NULL) { - zephir_read_property(&_48$$62, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_48$$62); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/Mvc/Router.zep", 766); - return; - } - ZEPHIR_INIT_NVAR(&_50$$62); - ZVAL_STRING(&_50$$62, "request"); - ZEPHIR_CALL_METHOD(&_49$$62, &container, "getshared", NULL, 0, &_50$$62); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&request, &_49$$62); - } - if (Z_TYPE_P(¤tHostName) == IS_NULL) { - ZEPHIR_CALL_METHOD(¤tHostName, &request, "gethttphost", NULL, 0); - zephir_check_call_status(); - } - if (!(zephir_is_true(¤tHostName))) { - continue; - } - if (zephir_memnstr_str(&hostname, SL("("), "phalcon/Mvc/Router.zep", 790)) { - if (!(zephir_memnstr_str(&hostname, SL("#"), "phalcon/Mvc/Router.zep", 791))) { - ZEPHIR_INIT_NVAR(®exHostName); - ZEPHIR_CONCAT_SV(®exHostName, "#^", &hostname); - if (!(zephir_memnstr_str(&hostname, SL(":"), "phalcon/Mvc/Router.zep", 794))) { - zephir_concat_self_str(®exHostName, SL("(:[[:digit:]]+)?")); - } - zephir_concat_self_str(®exHostName, SL("$#i")); - } else { - ZEPHIR_CPY_WRT(®exHostName, &hostname); - } - ZEPHIR_INIT_NVAR(&_51$$66); - ZEPHIR_INIT_NVAR(&matched); - zephir_preg_match(&matched, ®exHostName, ¤tHostName, &_51$$66, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&matched); - ZVAL_BOOL(&matched, ZEPHIR_IS_EQUAL(¤tHostName, &hostname)); - } - if (!(zephir_is_true(&matched))) { - continue; - } - } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_52$$72); - ZVAL_STRING(&_52$$72, "router:beforeCheckRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_53, 0, &_52$$72, this_ptr, &route); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "get", &_5, 0, &element, defaultValue); zephir_check_call_status(); - if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Mvc/Router.zep", 822)) { - ZEPHIR_INIT_NVAR(&routeFound); - zephir_preg_match(&routeFound, &pattern, &handledUri, &matches, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, &handledUri)); - } - if (zephir_is_true(&routeFound)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_54$$76); - ZVAL_STRING(&_54$$76, "router:matchedRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_55, 0, &_54$$76, this_ptr, &route); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Mvc/Router.zep", 844); - return; - } - ZEPHIR_INIT_NVAR(&_56$$77); - zephir_create_array(&_56$$77, 3, 0); - zephir_array_fast_append(&_56$$77, &handledUri); - zephir_array_fast_append(&_56$$77, &route); - zephir_array_fast_append(&_56$$77, this_ptr); - ZEPHIR_INIT_NVAR(&routeFound); - ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_56$$77); - zephir_check_call_status(); - } - } else { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_57$$80); - ZVAL_STRING(&_57$$80, "router:notMatchedRoute"); - ZEPHIR_CALL_METHOD(&routeFound, &eventsManager, "fire", &_58, 0, &_57$$80, this_ptr, &route); - zephir_check_call_status(); - } - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&parts, &paths); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&paths, 0, "phalcon/Mvc/Router.zep", 936); - if (Z_TYPE_P(&paths) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _61$$82, _62$$82, _59$$82) - { - ZEPHIR_INIT_NVAR(&part); - if (_62$$82 != NULL) { - ZVAL_STR_COPY(&part, _62$$82); - } else { - ZVAL_LONG(&part, _61$$82); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _59$$82); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_63$$84); - object_init_ex(&_63$$84, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_64$$84); - ZEPHIR_CONCAT_SV(&_64$$84, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_63$$84, "__construct", &_30, 32, &_64$$84); - zephir_check_call_status(); - zephir_throw_exception_debug(&_63$$84, "phalcon/Mvc/Router.zep", 884); - ZEPHIR_MM_RESTORE(); - return; - } - _65$$83 = Z_TYPE_P(&position) != IS_STRING; - if (_65$$83) { - _65$$83 = Z_TYPE_P(&position) != IS_LONG; - } - if (_65$$83) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_66$$88); - ZEPHIR_INIT_NVAR(&_67$$88); - zephir_create_array(&_67$$88, 1, 0); - zephir_array_fast_append(&_67$$88, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_66$$88, &converter, &_67$$88); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_66$$88, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_68$$91); - ZEPHIR_INIT_NVAR(&_69$$91); - zephir_create_array(&_69$$91, 1, 0); - zephir_array_fast_append(&_69$$91, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_68$$91, &converter, &_69$$91); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_68$$91, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_60$$82, &paths, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_60$$82)) { - break; - } - ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_70$$95); - object_init_ex(&_70$$95, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_71$$95); - ZEPHIR_CONCAT_SV(&_71$$95, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_70$$95, "__construct", &_30, 32, &_71$$95); - zephir_check_call_status(); - zephir_throw_exception_debug(&_70$$95, "phalcon/Mvc/Router.zep", 884); - ZEPHIR_MM_RESTORE(); - return; - } - _72$$94 = Z_TYPE_P(&position) != IS_STRING; - if (_72$$94) { - _72$$94 = Z_TYPE_P(&position) != IS_LONG; - } - if (_72$$94) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_73$$99); - ZEPHIR_INIT_NVAR(&_74$$99); - zephir_create_array(&_74$$99, 1, 0); - zephir_array_fast_append(&_74$$99, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_73$$99, &converter, &_74$$99); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_73$$99, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_75$$102); - ZEPHIR_INIT_NVAR(&_76$$102); - zephir_create_array(&_76$$102, 1, 0); - zephir_array_fast_append(&_76$$102, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_75$$102, &converter, &_76$$102); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_75$$102, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } - ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&part); - zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); - break; - } - ZEPHIR_CALL_METHOD(NULL, &_4, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - if (zephir_is_true(&routeFound)) { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - } else { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - } - if (!(zephir_is_true(&routeFound))) { - zephir_read_property(&_77$$107, this_ptr, ZEND_STRL("notFoundPaths"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(¬FoundPaths, &_77$$107); - if (Z_TYPE_P(¬FoundPaths) != IS_NULL) { - ZEPHIR_CALL_CE_STATIC(&parts, phalcon_mvc_router_route_ce, "getroutepaths", &_78, 0, ¬FoundPaths); + zephir_array_update_zval(&results, &element, &_4$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, 1); - } - } - zephir_read_property(&_79, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &_79); - zephir_read_property(&_80, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &_80); - zephir_read_property(&_81, this_ptr, ZEND_STRL("defaultController"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("controller"), &_81); - zephir_read_property(&_82, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &_82); - zephir_read_property(&_83, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_83); - if (zephir_is_true(&routeFound)) { - ZEPHIR_OBS_VAR(&vnamespace); - if (zephir_array_isset_string_fetch(&vnamespace, &parts, SL("namespace"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &vnamespace); - zephir_array_unset_string(&parts, SL("namespace"), PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&module); - if (zephir_array_isset_string_fetch(&module, &parts, SL("module"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &module); - zephir_array_unset_string(&parts, SL("module"), PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&controller); - if (zephir_array_isset_string_fetch(&controller, &parts, SL("controller"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("controller"), &controller); - zephir_array_unset_string(&parts, SL("controller"), PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&action); - if (zephir_array_isset_string_fetch(&action, &parts, SL("action"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &action); - zephir_array_unset_string(&parts, SL("action"), PH_SEPARATE); - } - ZEPHIR_OBS_VAR(¶msStr); - if (zephir_array_isset_string_fetch(¶msStr, &parts, SL("params"), 0)) { - if (Z_TYPE_P(¶msStr) == IS_STRING) { - ZEPHIR_INIT_VAR(&_84$$115); - ZVAL_STRING(&_84$$115, "/"); - ZEPHIR_INIT_VAR(&strParams); - zephir_fast_trim(&strParams, ¶msStr, &_84$$115, ZEPHIR_TRIM_BOTH); - if (!ZEPHIR_IS_STRING_IDENTICAL(&strParams, "")) { - ZEPHIR_INIT_NVAR(¶ms); - zephir_fast_explode_str(¶ms, SL("/"), &strParams, LONG_MAX); - } - } - zephir_array_unset_string(&parts, SL("params"), PH_SEPARATE); - } - if (zephir_fast_count_int(¶ms)) { - ZEPHIR_INIT_VAR(&_85$$117); - zephir_fast_array_merge(&_85$$117, ¶ms, &parts); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_85$$117); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &parts); } } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_86$$119); - ZVAL_STRING(&_86$$119, "router:afterCheckRoutes"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_86$$119, this_ptr); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, isExactControllerName) -{ - zval *this_ptr = getThis(); - - - - RETURN_BOOL(1); + ZEPHIR_INIT_NVAR(&element); + RETURN_CCTOR(&results); } -static PHP_METHOD(Phalcon_Mvc_Router, mount) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doHas) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *group, group_sub, groupRoutes, beforeMatch, hostname, routes, route, eventsManager, _0, _6, _1$$3, *_2$$5, _3$$5, *_4$$8, _5$$8; + zval *key_param = NULL, _0; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&group_sub); - ZVAL_UNDEF(&groupRoutes); - ZVAL_UNDEF(&beforeMatch); - ZVAL_UNDEF(&hostname); - ZVAL_UNDEF(&routes); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_5$$8); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(group, phalcon_mvc_router_groupinterface_ce) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &group); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "router:beforeMount"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_1$$3, this_ptr, group); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&groupRoutes, group, "getroutes", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_fast_count_int(&groupRoutes)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The group of routes does not contain any routes", "phalcon/Mvc/Router.zep", 1069); - return; - } - ZEPHIR_CALL_METHOD(&beforeMatch, group, "getbeforematch", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - zephir_is_iterable(&groupRoutes, 0, "phalcon/Mvc/Router.zep", 1081); - if (Z_TYPE_P(&groupRoutes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&groupRoutes), _2$$5) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _2$$5); - ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, &groupRoutes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&route, &groupRoutes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - } - ZEPHIR_CALL_METHOD(&hostname, group, "gethostname", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "has", NULL, 0, &key); zephir_check_call_status(); - if (Z_TYPE_P(&hostname) != IS_NULL) { - zephir_is_iterable(&groupRoutes, 0, "phalcon/Mvc/Router.zep", 1090); - if (Z_TYPE_P(&groupRoutes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&groupRoutes), _4$$8) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _4$$8); - ZEPHIR_CALL_METHOD(NULL, &route, "sethostname", NULL, 0, &hostname); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$8, &groupRoutes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$8)) { - break; - } - ZEPHIR_CALL_METHOD(&route, &groupRoutes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "sethostname", NULL, 0, &hostname); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&routes, &_0); - ZEPHIR_INIT_VAR(&_6); - zephir_fast_array_merge(&_6, &routes, &groupRoutes); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_6); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, notFound) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doSet) { - zend_bool _0; - zval *paths, paths_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, _0; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(paths) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &paths); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); + zephir_get_strval(&key, key_param); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; + } - _0 = Z_TYPE_P(paths) != IS_ARRAY; - if (_0) { - _0 = Z_TYPE_P(paths) != IS_STRING; - } - if (UNEXPECTED(_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_router_exception_ce, "The not-found paths must be an array or string", "phalcon/Mvc/Router.zep", 1112); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("notFoundPaths"), paths); - RETURN_THISW(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "set", NULL, 0, &key, value, ttl); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, removeExtraSlashes) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doSetMultiple) { - zval *remove_param = NULL, __$true, __$false; - zend_bool remove; + zend_string *_3; + zend_ulong _2; + zend_bool result = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *values, values_sub, *ttl = NULL, ttl_sub, __$null, key, value, *_0, _1, _4$$3, _6$$5; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&values_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(remove) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(values) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &remove_param); - if (UNEXPECTED(Z_TYPE_P(remove_param) != IS_TRUE && Z_TYPE_P(remove_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'remove' must be of the type bool")); - RETURN_NULL(); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &values, &ttl); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - remove = (Z_TYPE_P(remove_param) == IS_TRUE); - if (remove) { - zephir_update_property_zval(this_ptr, ZEND_STRL("removeExtraSlashes"), &__$true); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, values); + zephir_check_call_status(); + result = 1; + zephir_is_iterable(values, 0, "phalcon/Cache/AbstractCache.zep", 229); + if (Z_TYPE_P(values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(values), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "set", &_5, 0, &key, &value, ttl); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { + result = 0; + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("removeExtraSlashes"), &__$false); + ZEPHIR_CALL_METHOD(NULL, values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, values, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&key, values, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, values, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$5, this_ptr, "set", &_7, 0, &key, &value, ttl); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_6$$5)) { + result = 0; + } + ZEPHIR_CALL_METHOD(NULL, values, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_THISW(); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + RETURN_MM_BOOL(result); } -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultAction) +static PHP_METHOD(Phalcon_Cache_AbstractCache, getExceptionClass) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionName_param = NULL; - zval actionName; - zval *this_ptr = getThis(); +} - ZVAL_UNDEF(&actionName); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionName) - ZEND_PARSE_PARAMETERS_END(); + + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &actionName_param); - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); - RETURN_THIS(); + +ZEPHIR_INIT_CLASS(Phalcon_Cache_AdapterFactory) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, AdapterFactory, phalcon, cache_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_cache_adapterfactory_method_entry, 0); + + zend_declare_property_null(phalcon_cache_adapterfactory_ce, SL("serializerFactory"), ZEND_ACC_PRIVATE); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultController) +static PHP_METHOD(Phalcon_Cache_AdapterFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerName_param = NULL; - zval controllerName; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval services; + zval *factory, factory_sub, *services_param = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&services); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerName) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &controllerName_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); + zephir_fetch_params(1, 1, 1, &factory, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); } else { - ZEPHIR_INIT_VAR(&controllerName); + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultController"), &controllerName); - RETURN_THIS(); + zephir_update_property_zval(this_ptr, ZEND_STRL("serializerFactory"), factory); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultModule) +static PHP_METHOD(Phalcon_Cache_AdapterFactory, newInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *moduleName_param = NULL; - zval moduleName; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, _0; + zval *name_param = NULL, *options_param = NULL, definition, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(moduleName) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &moduleName_param); - if (UNEXPECTED(Z_TYPE_P(moduleName_param) != IS_STRING && Z_TYPE_P(moduleName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'moduleName' must be of the type string")); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(moduleName_param) == IS_STRING)) { - zephir_get_strval(&moduleName, moduleName_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&moduleName); + ZEPHIR_INIT_VAR(&name); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &moduleName); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + ZEPHIR_OBS_VAR(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("serializerFactory"), PH_NOISY_CC); + zephir_array_fast_append(&_0, &_1); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultNamespace) +static PHP_METHOD(Phalcon_Cache_AdapterFactory, getExceptionClass) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *namespaceName_param = NULL; - zval namespaceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&namespaceName); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(namespaceName) - ZEND_PARSE_PARAMETERS_END(); -#endif - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &namespaceName_param); - if (UNEXPECTED(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(namespaceName_param) == IS_STRING)) { - zephir_get_strval(&namespaceName, namespaceName_param); - } else { - ZEPHIR_INIT_VAR(&namespaceName); - } + RETURN_STRING("Phalcon\\Cache\\Exception\\Exception"); +} - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &namespaceName); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setDefaults) +static PHP_METHOD(Phalcon_Cache_AdapterFactory, getServices) { - zval _0$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *defaults_param = NULL, namespaceName, module, controller, action, params; - zval defaults; zval *this_ptr = getThis(); - ZVAL_UNDEF(&defaults); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_0$$3); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(defaults) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &defaults_param); - ZEPHIR_OBS_COPY_OR_DUP(&defaults, defaults_param); + zephir_create_array(return_value, 6, 0); + add_assoc_stringl_ex(return_value, SL("apcu"), SL("Phalcon\\Cache\\Adapter\\Apcu")); + add_assoc_stringl_ex(return_value, SL("libmemcached"), SL("Phalcon\\Cache\\Adapter\\Libmemcached")); + add_assoc_stringl_ex(return_value, SL("memory"), SL("Phalcon\\Cache\\Adapter\\Memory")); + add_assoc_stringl_ex(return_value, SL("redis"), SL("Phalcon\\Cache\\Adapter\\Redis")); + add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Cache\\Adapter\\Stream")); + add_assoc_stringl_ex(return_value, SL("weak"), SL("Phalcon\\Cache\\Adapter\\Weak")); + return; +} - if (zephir_array_isset_string_fetch(&namespaceName, &defaults, SL("namespace"), 1)) { - zephir_cast_to_string(&_0$$3, &namespaceName); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &_0$$3); - } - if (zephir_array_isset_string_fetch(&module, &defaults, SL("module"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &module); - } - if (zephir_array_isset_string_fetch(&controller, &defaults, SL("controller"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultController"), &controller); - } - if (zephir_array_isset_string_fetch(&action, &defaults, SL("action"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &action); - } - if (zephir_array_isset_string_fetch(¶ms, &defaults, SL("params"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultParams"), ¶ms); - } - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Mvc_Router, setEventsManager) -{ - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); +#ifdef HAVE_CONFIG_H #endif - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + +ZEPHIR_INIT_CLASS(Phalcon_Cache_Cache) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, Cache, phalcon, cache_cache, phalcon_cache_abstractcache_ce, phalcon_cache_cache_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router, setKeyRouteNames) +static PHP_METHOD(Phalcon_Cache_Cache, clear) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *routeNames_param = NULL; - zval routeNames; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routeNames); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(routeNames) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &routeNames_param); - zephir_get_arrval(&routeNames, routeNames_param); - - zephir_update_property_zval(this_ptr, ZEND_STRL("keyRouteNames"), &routeNames); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doclear", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, setKeyRouteIds) +static PHP_METHOD(Phalcon_Cache_Cache, delete) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *routeIds_param = NULL; - zval routeIds; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routeIds); + ZVAL_UNDEF(&key); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(routeIds) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &routeIds_param); - zephir_get_arrval(&routeIds, routeIds_param); - - - zephir_update_property_zval(this_ptr, ZEND_STRL("keyRouteIds"), &routeIds); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, wasMatched) -{ - zval *this_ptr = getThis(); - + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - RETURN_MEMBER(getThis(), "wasMatched"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dodelete", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Cache_Cache, deleteMultiple) { - zval _0, _2, _4, _6, _8, _10, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteIds"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteNames"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_11$$8); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_RouterInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, RouterInterface, phalcon, mvc_routerinterface, phalcon_mvc_routerinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, add); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addConnect); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addDelete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addHead); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addGet); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPost); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPurge); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPut); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addTrace); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, attach); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getActionName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getControllerName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatchedRoute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatches); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getModuleName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getNamespaceName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRoutes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteById); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteByName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, handle); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, mount); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultAction); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultController); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultModule); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaults); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, wasMatched); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Url, phalcon, mvc_url, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_url_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_url_ce, SL("baseUri"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_url_ce, SL("basePath"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_url_ce, SL("router"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_url_ce, SL("staticBaseUri"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_url_ce, 1, phalcon_mvc_url_urlinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Url, __construct) -{ - zval *router = NULL, router_sub, __$null; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *keys, keys_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&router_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&keys_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(router, phalcon_mvc_routerinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(keys) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(0, 1, &router); - if (!router) { - router = &router_sub; - router = &__$null; - } + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &keys); - zephir_update_property_zval(this_ptr, ZEND_STRL("router"), router); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dodeletemultiple", NULL, 0, keys); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Url, get) +static PHP_METHOD(Phalcon_Cache_Cache, get) { - zval strUri, _16$$15; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool local, _0$$3, _1$$3, _20$$16; - zval *uri = NULL, uri_sub, *args = NULL, args_sub, *local_param = NULL, *baseUri = NULL, baseUri_sub, __$null, router, container, routeName, route, queryString, _2$$4, _3$$4, _4$$4, _5$$4, _6$$9, _11$$9, _14$$9, _15$$9, _7$$11, _8$$11, _9$$11, _10$$11, _12$$14, _13$$14, _17$$15, _18$$15, _19$$15, _21$$17, _22$$17, _23$$18, _24$$19; + zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri_sub); - ZVAL_UNDEF(&args_sub); - ZVAL_UNDEF(&baseUri_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&defaultValue_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&routeName); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&queryString); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_8$$11); - ZVAL_UNDEF(&_9$$11); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_12$$14); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&_17$$15); - ZVAL_UNDEF(&_18$$15); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_21$$17); - ZVAL_UNDEF(&_22$$17); - ZVAL_UNDEF(&_23$$18); - ZVAL_UNDEF(&_24$$19); - ZVAL_UNDEF(&strUri); - ZVAL_UNDEF(&_16$$15); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 4) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(key) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(uri) - Z_PARAM_ZVAL_OR_NULL(args) - Z_PARAM_BOOL_OR_NULL(local, is_null_true) - Z_PARAM_ZVAL_OR_NULL(baseUri) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 4, &uri, &args, &local_param, &baseUri); - if (!uri) { - uri = &uri_sub; - ZEPHIR_CPY_WRT(uri, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(uri); - } - if (!args) { - args = &args_sub; - args = &__$null; - } - if (!local_param) { - local = 0; - } else { - local = zephir_get_boolval(local_param); - } - if (!baseUri) { - baseUri = &baseUri_sub; - ZEPHIR_CPY_WRT(baseUri, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(baseUri); + zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); + zephir_get_strval(&key, key_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - if (local == 0) { - _0$$3 = Z_TYPE_P(uri) == IS_STRING; - if (_0$$3) { - _1$$3 = zephir_memnstr_str(uri, SL("//"), "phalcon/Mvc/Url.zep", 107); - if (!(_1$$3)) { - _1$$3 = zephir_memnstr_str(uri, SL(":"), "phalcon/Mvc/Url.zep", 107); - } - _0$$3 = _1$$3; - } - if (_0$$3) { - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); - ZEPHIR_INIT_VAR(&_4$$4); - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); - zephir_preg_match(&_4$$4, &_5$$4, uri, &_2$$4, 0, 0 , 0 ); - if (zephir_is_true(&_4$$4)) { - local = 0; - } else { - local = 1; - } - } else { - local = 1; - } - } - if (Z_TYPE_P(baseUri) != IS_STRING) { - ZEPHIR_CALL_METHOD(baseUri, this_ptr, "getbaseuri", NULL, 0); - zephir_check_call_status(); - } - if (Z_TYPE_P(uri) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&routeName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&routeName, uri, SL("for"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/Mvc/Url.zep", 126); - return; - } - zephir_read_property(&_6$$9, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&router, &_6$$9); - if (UNEXPECTED(!zephir_is_true(&router))) { - zephir_read_property(&_7$$11, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_7$$11); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injection container is required to access the 'router' service", "phalcon/Mvc/Url.zep", 140); - return; - } - ZEPHIR_INIT_VAR(&_9$$11); - ZVAL_STRING(&_9$$11, "router"); - ZEPHIR_CALL_METHOD(&_8$$11, &container, "has", NULL, 0, &_9$$11); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_8$$11))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injection container is required to access the 'router' service", "phalcon/Mvc/Url.zep", 146); - return; - } - ZEPHIR_INIT_NVAR(&_9$$11); - ZVAL_STRING(&_9$$11, "router"); - ZEPHIR_CALL_METHOD(&_10$$11, &container, "getshared", NULL, 0, &_9$$11); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&router, &_10$$11); - zephir_update_property_zval(this_ptr, ZEND_STRL("router"), &router); - } - ZEPHIR_CALL_METHOD(&_11$$9, &router, "getroutebyname", NULL, 0, &routeName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&route, &_11$$9); - if (UNEXPECTED(Z_TYPE_P(&route) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_12$$14); - object_init_ex(&_12$$14, phalcon_mvc_url_exception_ce); - ZEPHIR_INIT_VAR(&_13$$14); - ZEPHIR_CONCAT_SVS(&_13$$14, "Cannot obtain a route using the name '", &routeName, "'"); - ZEPHIR_CALL_METHOD(NULL, &_12$$14, "__construct", NULL, 32, &_13$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$14, "phalcon/Mvc/Url.zep", 161); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_14$$9); - ZEPHIR_CALL_METHOD(&_11$$9, &route, "getpattern", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_15$$9, &route, "getreversedpaths", NULL, 0); - zephir_check_call_status(); - phalcon_replace_paths(&_14$$9, &_11$$9, &_15$$9, uri); - ZEPHIR_CPY_WRT(uri, &_14$$9); - } - if (local) { - zephir_cast_to_string(&_16$$15, uri); - ZEPHIR_CPY_WRT(&strUri, &_16$$15); - ZEPHIR_INIT_VAR(&_17$$15); - ZEPHIR_CONCAT_VV(&_17$$15, baseUri, &strUri); - ZEPHIR_INIT_VAR(&_18$$15); - ZVAL_STRING(&_18$$15, "#(?= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(keys) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(uri) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &uri); - if (!uri) { - uri = &uri_sub; - uri = &__$null; + zephir_fetch_params(1, 1, 1, &keys, &defaultValue); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getstaticbaseuri", NULL, 0); - zephir_check_call_status(); - ZVAL_NULL(&_1); - ZVAL_NULL(&_2); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, uri, &_1, &_2, &_0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetmultiple", NULL, 0, keys, defaultValue); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Url, getStaticBaseUri) +static PHP_METHOD(Phalcon_Cache_Cache, has) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("staticBaseUri"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - RETURN_MM_MEMBER(getThis(), "staticBaseUri"); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getbaseuri", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Url, setBasePath) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *basePath_param = NULL; - zval basePath; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&key); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(basePath) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &basePath_param); - if (UNEXPECTED(Z_TYPE_P(basePath_param) != IS_STRING && Z_TYPE_P(basePath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'basePath' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(basePath_param) == IS_STRING)) { - zephir_get_strval(&basePath, basePath_param); - } else { - ZEPHIR_INIT_VAR(&basePath); - } + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("basePath"), &basePath); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dohas", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Url, setBaseUri) +static PHP_METHOD(Phalcon_Cache_Cache, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *baseUri_param = NULL, _0; - zval baseUri; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&baseUri); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(baseUri) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &baseUri_param); - if (UNEXPECTED(Z_TYPE_P(baseUri_param) != IS_STRING && Z_TYPE_P(baseUri_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'baseUri' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(baseUri_param) == IS_STRING)) { - zephir_get_strval(&baseUri, baseUri_param); - } else { - ZEPHIR_INIT_VAR(&baseUri); + zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); + zephir_get_strval(&key, key_param); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - zephir_update_property_zval(this_ptr, ZEND_STRL("baseUri"), &baseUri); - zephir_read_property(&_0, this_ptr, ZEND_STRL("staticBaseUri"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - zephir_update_property_zval(this_ptr, ZEND_STRL("staticBaseUri"), &baseUri); - } - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doset", NULL, 0, &key, value, ttl); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Url, setStaticBaseUri) +static PHP_METHOD(Phalcon_Cache_Cache, setMultiple) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *staticBaseUri_param = NULL; - zval staticBaseUri; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *values, values_sub, *ttl = NULL, ttl_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&staticBaseUri); + ZVAL_UNDEF(&values_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(staticBaseUri) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(values) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &staticBaseUri_param); - if (UNEXPECTED(Z_TYPE_P(staticBaseUri_param) != IS_STRING && Z_TYPE_P(staticBaseUri_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'staticBaseUri' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(staticBaseUri_param) == IS_STRING)) { - zephir_get_strval(&staticBaseUri, staticBaseUri_param); - } else { - ZEPHIR_INIT_VAR(&staticBaseUri); + zephir_fetch_params(1, 1, 1, &values, &ttl); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - zephir_update_property_zval(this_ptr, ZEND_STRL("staticBaseUri"), &staticBaseUri); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dosetmultiple", NULL, 0, values, ttl); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Url, path) +static PHP_METHOD(Phalcon_Cache_Cache, getExceptionClass) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *path_param = NULL, _0; - zval path; zval *this_ptr = getThis(); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(path) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &path_param); - if (!path_param) { - ZEPHIR_INIT_VAR(&path); - } else { - zephir_get_strval(&path, path_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_VV(return_value, &_0, &path); - RETURN_MM(); + RETURN_STRING("Phalcon\\Cache\\Exception\\InvalidArgumentException"); } @@ -56527,1422 +51142,1065 @@ static PHP_METHOD(Phalcon_Mvc_Url, path) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_View) +ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, View, phalcon, mvc_view, phalcon_di_injectable_ce, phalcon_mvc_view_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_view_ce, SL("actionName"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("activeRenderPaths"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_view_ce, SL("basePath"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_view_ce, SL("content"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("controllerName"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_view_ce, SL("currentRenderLevel"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_view_ce, SL("disabled"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("disabledLevels"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_view_ce, SL("engines"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("layout"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_view_ce, SL("layoutsDir"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_view_ce, SL("mainView"), "index", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("params"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("pickView"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_view_ce, SL("partialsDir"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("registeredEngines"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_view_ce, SL("renderLevel"), 5, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("templatesAfter"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("templatesBefore"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("viewsDirs"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_view_ce, SL("viewParams"), ZEND_ACC_PROTECTED); - phalcon_mvc_view_ce->create_object = zephir_init_properties_Phalcon_Mvc_View; - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_ACTION_VIEW"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_BEFORE_TEMPLATE"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_LAYOUT"), 3); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_MAIN_LAYOUT"), 5); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_NO_RENDER"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_AFTER_TEMPLATE"), 4); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, CacheFactory, phalcon, cache_cachefactory, phalcon_factory_abstractconfigfactory_ce, phalcon_cache_cachefactory_method_entry, 0); - zend_class_implements(phalcon_mvc_view_ce, 1, phalcon_mvc_viewinterface_ce); - zend_class_implements(phalcon_mvc_view_ce, 1, phalcon_events_eventsawareinterface_ce); + zend_declare_property_null(phalcon_cache_cachefactory_ce, SL("adapterFactory"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_View, __construct) +static PHP_METHOD(Phalcon_Cache_CacheFactory, __construct) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; - zval options; + zval *factory, factory_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&factory_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } + zephir_fetch_params_without_memory_grow(1, 0, &factory); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapterFactory"), factory); } -static PHP_METHOD(Phalcon_Mvc_View, __get) +static PHP_METHOD(Phalcon_Cache_CacheFactory, load) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL; - zval key; + zval *config = NULL, config_sub, name, options, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getvar", NULL, 0, &key); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "adapter"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_OBS_VAR(&name); + zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Cache/CacheFactory.zep", 73); + ZEPHIR_OBS_VAR(&options); + if (!(zephir_array_isset_string_fetch(&options, config, SL("options"), 0))) { + ZEPHIR_INIT_NVAR(&options); + array_init(&options); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, __isset) +static PHP_METHOD(Phalcon_Cache_CacheFactory, newInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, _0; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval *name_param = NULL, *options_param = NULL, adapter, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&adapter); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&name); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &key)); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&adapter, &_0, "newinstance", NULL, 0, &name, &options); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_cache_cache_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 188, &adapter); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, __set) +static PHP_METHOD(Phalcon_Cache_CacheFactory, getExceptionClass) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvar", NULL, 0, &key, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_STRING("Phalcon\\Cache\\Exception\\Exception"); } -static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateAfter) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_MM_GROW(); +#ifdef HAVE_CONFIG_H +#endif - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_0); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateBefore) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_MM_GROW(); +ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache, CacheInterface, phalcon, cache_cacheinterface, phalcon_cache_cacheinterface_method_entry); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_0); - RETURN_THIS(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_View, disableLevel) -{ - zval *level, level_sub, __$true; - zval *this_ptr = getThis(); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, clear); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, deleteMultiple); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, getMultiple); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, setMultiple); - ZVAL_UNDEF(&level_sub); - ZVAL_BOOL(&__$true, 1); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(level) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - zephir_fetch_params_without_memory_grow(1, 0, &level); - if (Z_TYPE_P(level) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabledLevels"), level); - } else { - zephir_update_property_array(this_ptr, SL("disabledLevels"), level, &__$true); - } - RETURN_THISW(); -} -static PHP_METHOD(Phalcon_Mvc_View, disable) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_AdapterInterface) { - zval __$true, __$false; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache\\Adapter, AdapterInterface, phalcon, cache_adapter_adapterinterface, NULL); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + zend_class_implements(phalcon_cache_adapter_adapterinterface_ce, 1, phalcon_storage_adapter_adapterinterface_ce); + return SUCCESS; +} - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); - } - RETURN_THISW(); -} -static PHP_METHOD(Phalcon_Mvc_View, enable) -{ - zval __$true, __$false; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); - } - RETURN_THISW(); -} -static PHP_METHOD(Phalcon_Mvc_View, exists) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Apcu) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *view_param = NULL; - zval view; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Apcu, phalcon, cache_adapter_apcu, phalcon_storage_adapter_apcu_ce, NULL, 0); - ZVAL_UNDEF(&view); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(view) - ZEND_PARSE_PARAMETERS_END(); + zend_class_implements(phalcon_cache_adapter_apcu_ce, 1, phalcon_cache_adapter_adapterinterface_ce); + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &view_param); - if (UNEXPECTED(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(view_param) == IS_STRING)) { - zephir_get_strval(&view, view_param); - } else { - ZEPHIR_INIT_VAR(&view); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &view); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_View, finish) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Libmemcached) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Libmemcached, phalcon, cache_adapter_libmemcached, phalcon_storage_adapter_libmemcached_ce, NULL, 0); + zend_class_implements(phalcon_cache_adapter_libmemcached_ce, 1, phalcon_cache_adapter_adapterinterface_ce); + return SUCCESS; +} - ZEPHIR_MM_GROW(); - ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 490); - zephir_check_call_status(); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Mvc_View, getActionName) -{ - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "actionName"); -} -static PHP_METHOD(Phalcon_Mvc_View, getActiveRenderPath) + +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Memory) { - zend_bool _1$$3; - zval activeRenderPath, _0, _2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, viewsDirsCount = 0; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Memory, phalcon, cache_adapter_memory, phalcon_storage_adapter_memory_ce, NULL, 0); - ZVAL_UNDEF(&activeRenderPath); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); + zend_class_implements(phalcon_cache_adapter_memory_ce, 1, phalcon_cache_adapter_adapterinterface_ce); + return SUCCESS; +} - ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getviewsdirs", NULL, 0); - zephir_check_call_status(); - viewsDirsCount = zephir_fast_count_int(&_0); - ZEPHIR_OBS_VAR(&activeRenderPath); - zephir_read_property(&activeRenderPath, this_ptr, ZEND_STRL("activeRenderPaths"), PH_NOISY_CC); - if (viewsDirsCount == 1) { - _1$$3 = Z_TYPE_P(&activeRenderPath) == IS_ARRAY; - if (_1$$3) { - _1$$3 = ((zephir_fast_count_int(&activeRenderPath)) ? 1 : 0); - } - if (_1$$3) { - zephir_array_fetch_long(&_2$$4, &activeRenderPath, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/View.zep", 339); - ZEPHIR_CPY_WRT(&activeRenderPath, &_2$$4); - } - } - if (Z_TYPE_P(&activeRenderPath) == IS_NULL) { - ZEPHIR_INIT_NVAR(&activeRenderPath); - ZVAL_STRING(&activeRenderPath, ""); - } - RETURN_CCTOR(&activeRenderPath); -} -static PHP_METHOD(Phalcon_Mvc_View, getBasePath) -{ - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "basePath"); -} -static PHP_METHOD(Phalcon_Mvc_View, getContent) + +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Redis) { - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Redis, phalcon, cache_adapter_redis, phalcon_storage_adapter_redis_ce, NULL, 0); + zend_class_implements(phalcon_cache_adapter_redis_ce, 1, phalcon_cache_adapter_adapterinterface_ce); + return SUCCESS; +} - RETURN_MEMBER(getThis(), "content"); -} -static PHP_METHOD(Phalcon_Mvc_View, getControllerName) -{ - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "controllerName"); -} -static PHP_METHOD(Phalcon_Mvc_View, getCurrentRenderLevel) -{ - zval *this_ptr = getThis(); +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Stream) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Stream, phalcon, cache_adapter_stream, phalcon_storage_adapter_stream_ce, NULL, 0); - RETURN_MEMBER(getThis(), "currentRenderLevel"); + zend_class_implements(phalcon_cache_adapter_stream_ce, 1, phalcon_cache_adapter_adapterinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_View, getRegisteredEngines) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "registeredEngines"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_View, getRenderLevel) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "renderLevel"); -} -static PHP_METHOD(Phalcon_Mvc_View, getEventsManager) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Weak) { - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Weak, phalcon, cache_adapter_weak, phalcon_storage_adapter_weak_ce, NULL, 0); + zend_class_implements(phalcon_cache_adapter_weak_ce, 1, phalcon_cache_adapter_adapterinterface_ce); + return SUCCESS; +} - RETURN_MEMBER(getThis(), "eventsManager"); -} -static PHP_METHOD(Phalcon_Mvc_View, getLayout) -{ - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "layout"); -} -static PHP_METHOD(Phalcon_Mvc_View, getLayoutsDir) -{ - zval *this_ptr = getThis(); +ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Exception, Exception, phalcon, cache_exception_exception, zend_ce_exception, NULL, 0); - RETURN_MEMBER(getThis(), "layoutsDir"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_View, getMainView) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "mainView"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_View, getParamsToView) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "viewParams"); -} -static PHP_METHOD(Phalcon_Mvc_View, getPartial) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception_InvalidArgumentException) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *partialPath_param = NULL, *params = NULL, params_sub, __$null; - zval partialPath; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Exception, InvalidArgumentException, phalcon, cache_exception_invalidargumentexception, zend_ce_exception, NULL, 0); - ZVAL_UNDEF(&partialPath); - ZVAL_UNDEF(¶ms_sub); - ZVAL_NULL(&__$null); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(partialPath) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) - ZEND_PARSE_PARAMETERS_END(); -#endif + return SUCCESS; +} - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); - if (UNEXPECTED(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(partialPath_param) == IS_STRING)) { - zephir_get_strval(&partialPath, partialPath_param); - } else { - ZEPHIR_INIT_VAR(&partialPath); - } - if (!params) { - params = ¶ms_sub; - params = &__$null; - } - ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 389); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "partial", NULL, 0, &partialPath, params); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 396); - zephir_check_call_status(); - RETURN_MM(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_View, getPartialsDir) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "partialsDir"); + +ZEPHIR_INIT_CLASS(Phalcon_Session_Bag) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session, Bag, phalcon, session_bag, phalcon_support_collection_ce, phalcon_session_bag_method_entry, 0); + + zend_declare_property_null(phalcon_session_bag_ce, SL("container"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_session_bag_ce, SL("name"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_session_bag_ce, SL("session"), ZEND_ACC_PRIVATE); + zend_class_implements(phalcon_session_bag_ce, 1, phalcon_session_baginterface_ce); + zend_class_implements(phalcon_session_bag_ce, 1, phalcon_di_injectionawareinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_View, getRender) +static PHP_METHOD(Phalcon_Session_Bag, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval params, _1$$3; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, *configCallback = NULL, configCallback_sub, __$null, view, _0$$3; - zval controllerName, actionName; + zval name; + zval *session, session_sub, *name_param = NULL, data, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&configCallback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&view); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&session_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&name); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - Z_PARAM_ZVAL_OR_NULL(configCallback) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(session, phalcon_session_managerinterface_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms_param, &configCallback); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - if (!configCallback) { - configCallback = &configCallback_sub; - configCallback = &__$null; - } + zephir_fetch_params(1, 2, 0, &session, &name_param); + zephir_get_strval(&name, name_param); - ZEPHIR_INIT_VAR(&view); - if (zephir_clone(&view, this_ptr) == FAILURE) { - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &view, "reset", NULL, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("session"), session); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + ZEPHIR_CALL_METHOD(&_0, session, "getdi", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "setvars", NULL, 0, ¶ms); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&data, session, "get", NULL, 0, &_1); zephir_check_call_status(); - if (Z_TYPE_P(configCallback) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - zephir_array_fast_append(&_1$$3, &view); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_0$$3, configCallback, &_1$$3); - zephir_check_call_status(); + if (Z_TYPE_P(&data) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&data); + array_init(&data); } - ZEPHIR_CALL_METHOD(NULL, &view, "start", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "render", NULL, 0, &controllerName, &actionName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "finish", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&view, "getcontent", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &data); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, getVar) +static PHP_METHOD(Phalcon_Session_Bag, clear) { + zval _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, value, _0; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&value, &_0, &key, 1))) { - RETURN_MM_NULL(); - } - RETURN_CTOR(&value); + ZEPHIR_CALL_PARENT(NULL, phalcon_session_bag_ce, getThis(), "clear", &_0, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("session"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_1, "remove", NULL, 0, &_2); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, getViewsDir) +static PHP_METHOD(Phalcon_Session_Bag, getDI) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "viewsDirs"); + RETURN_MEMBER(getThis(), "container"); } -static PHP_METHOD(Phalcon_Mvc_View, getViewsDirs) +static PHP_METHOD(Phalcon_Session_Bag, init) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval *data_param = NULL, _1, _2; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - ZEPHIR_OBS_VAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC); - if (Z_TYPE_P(&_0) == IS_STRING) { - zephir_create_array(return_value, 1, 0); - ZEPHIR_OBS_VAR(&_1$$3); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC); - zephir_array_fast_append(return_value, &_1$$3); - RETURN_MM(); + zephir_fetch_params(1, 0, 1, &data_param); + if (!data_param) { + ZEPHIR_INIT_VAR(&data); + array_init(&data); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); } - RETURN_MM_MEMBER(getThis(), "viewsDirs"); + + + ZEPHIR_CALL_PARENT(NULL, phalcon_session_bag_ce, getThis(), "init", &_0, 0, &data); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("session"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_1, "set", NULL, 0, &_2, &data); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, has) +static PHP_METHOD(Phalcon_Session_Bag, remove) { - zend_string *_9$$4, *_16$$9; - zend_ulong _8$$4, _15$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *view_param = NULL, basePath, viewsDir, engines, extension, _0, _2, *_3, _4, _1$$3, _5$$4, *_6$$4, _7$$4, _10$$5, _11$$7, _12$$9, *_13$$9, _14$$9, _17$$10, _18$$12; - zval view; + zephir_fcall_cache_entry *_0 = NULL; + zval *element_param = NULL, _1, _2, _3; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&view); - ZVAL_UNDEF(&basePath); - ZVAL_UNDEF(&viewsDir); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_17$$10); - ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(view) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &view_param); - if (UNEXPECTED(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be of the type string")); + zephir_fetch_params(1, 1, 0, &element_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(view_param) == IS_STRING)) { - zephir_get_strval(&view, view_param); + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); } else { - ZEPHIR_INIT_VAR(&view); + ZEPHIR_INIT_VAR(&element); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&basePath, &_0); - ZEPHIR_OBS_VAR(&engines); - zephir_read_property(&engines, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC); - if (ZEPHIR_IS_EMPTY(&engines)) { - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - add_assoc_stringl_ex(&_1$$3, SL(".phtml"), SL("Phalcon\\Mvc\\View\\Engine\\Php")); - ZEPHIR_CPY_WRT(&engines, &_1$$3); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "registerengines", NULL, 0, &engines); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getviewsdirs", NULL, 0); + ZEPHIR_CALL_PARENT(NULL, phalcon_session_bag_ce, getThis(), "remove", &_0, 0, &element); zephir_check_call_status(); - zephir_is_iterable(&_2, 0, "phalcon/Mvc/View.zep", 599); - if (Z_TYPE_P(&_2) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) - { - ZEPHIR_INIT_NVAR(&viewsDir); - ZVAL_COPY(&viewsDir, _3); - ZEPHIR_INIT_NVAR(&_5$$4); - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 597); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _8$$4, _9$$4, _6$$4) - { - ZEPHIR_INIT_NVAR(&extension); - if (_9$$4 != NULL) { - ZVAL_STR_COPY(&extension, _9$$4); - } else { - ZVAL_LONG(&extension, _8$$4); - } - ZEPHIR_INIT_NVAR(&_5$$4); - ZVAL_COPY(&_5$$4, _6$$4); - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_VVVV(&_10$$5, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_10$$5) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$4, &engines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$4, &engines, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$7); - ZEPHIR_CONCAT_VVVV(&_11$$7, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_11$$7) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&_5$$4); - ZEPHIR_INIT_NVAR(&extension); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4)) { - break; - } - ZEPHIR_CALL_METHOD(&viewsDir, &_2, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$9); - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 597); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _15$$9, _16$$9, _13$$9) - { - ZEPHIR_INIT_NVAR(&extension); - if (_16$$9 != NULL) { - ZVAL_STR_COPY(&extension, _16$$9); - } else { - ZVAL_LONG(&extension, _15$$9); - } - ZEPHIR_INIT_NVAR(&_12$$9); - ZVAL_COPY(&_12$$9, _13$$9); - ZEPHIR_INIT_NVAR(&_17$$10); - ZEPHIR_CONCAT_VVVV(&_17$$10, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_17$$10) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_14$$9, &engines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_14$$9)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_12$$9, &engines, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_18$$12); - ZEPHIR_CONCAT_VVVV(&_18$$12, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_18$$12) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&_12$$9); - ZEPHIR_INIT_NVAR(&extension); - ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&viewsDir); - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_View, isDisabled) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "disabled"); + zephir_read_property(&_1, this_ptr, ZEND_STRL("session"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_1, "set", NULL, 0, &_2, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, partial) +static PHP_METHOD(Phalcon_Session_Bag, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *partialPath_param = NULL, *params = NULL, params_sub, __$null, viewParams, _3, _4, _5, _6, _7, _0$$3, _1$$3, _2$$3; - zval partialPath; + zephir_fcall_cache_entry *_0 = NULL; + zval *element_param = NULL, *value, value_sub, _1, _2, _3; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&partialPath); - ZVAL_UNDEF(¶ms_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&viewParams); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(partialPath) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(element) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); - if (UNEXPECTED(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be of the type string")); + zephir_fetch_params(1, 2, 0, &element_param, &value); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(partialPath_param) == IS_STRING)) { - zephir_get_strval(&partialPath, partialPath_param); + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); } else { - ZEPHIR_INIT_VAR(&partialPath); - } - if (!params) { - params = ¶ms_sub; - params = &__$null; + ZEPHIR_INIT_VAR(&element); } - if (Z_TYPE_P(params) == IS_ARRAY) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&viewParams, &_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_fast_array_merge(&_1$$3, &viewParams, params); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CREATE_SYMBOL_TABLE(); - - } - ZEPHIR_CALL_METHOD(&_3, this_ptr, "loadtemplateengines", NULL, 0); + ZEPHIR_CALL_PARENT(NULL, phalcon_session_bag_ce, getThis(), "set", &_0, 0, &element, value); zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("partialsDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_VV(&_5, &_4, &partialPath); - ZVAL_BOOL(&_6, 0); - ZVAL_BOOL(&_7, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &_3, &_5, &_6, &_7); + zephir_read_property(&_1, this_ptr, ZEND_STRL("session"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_1, "set", NULL, 0, &_2, &_3); zephir_check_call_status(); - if (Z_TYPE_P(params) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &viewParams); - } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, pick) +static PHP_METHOD(Phalcon_Session_Bag, setDI) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *renderView, renderView_sub, pickView, layout, parts, _0$$4; + zval *container, container_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&renderView_sub); - ZVAL_UNDEF(&pickView); - ZVAL_UNDEF(&layout); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&container_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(renderView) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &renderView); + zephir_fetch_params_without_memory_grow(1, 0, &container); - if (Z_TYPE_P(renderView) == IS_ARRAY) { - ZEPHIR_CPY_WRT(&pickView, renderView); - } else { - ZEPHIR_INIT_VAR(&layout); - ZVAL_NULL(&layout); - if (zephir_memnstr_str(renderView, SL("/"), "phalcon/Mvc/View.zep", 701)) { - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("/"), renderView, LONG_MAX); - ZEPHIR_OBS_NVAR(&layout); - zephir_array_fetch_long(&layout, &parts, 0, PH_NOISY, "phalcon/Mvc/View.zep", 703); - } - ZEPHIR_INIT_VAR(&_0$$4); - zephir_create_array(&_0$$4, 1, 0); - zephir_array_fast_append(&_0$$4, renderView); - ZEPHIR_CPY_WRT(&pickView, &_0$$4); - if (Z_TYPE_P(&layout) != IS_NULL) { - zephir_array_append(&pickView, &layout, PH_SEPARATE, "phalcon/Mvc/View.zep", 709); - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("pickView"), &pickView); - RETURN_THIS(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); } -static PHP_METHOD(Phalcon_Mvc_View, registerEngines) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *engines_param = NULL; - zval engines; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&engines); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(engines) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &engines_param); - ZEPHIR_OBS_COPY_OR_DUP(&engines, engines_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("registeredEngines"), &engines); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Mvc_View, render) +ZEPHIR_INIT_CLASS(Phalcon_Session_BagInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval params; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, result; - zval controllerName, actionName; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Session, BagInterface, phalcon, session_baginterface, phalcon_session_baginterface_method_entry); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(¶ms); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - ZEND_PARSE_PARAMETERS_END(); + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __get); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __isset); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __set); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __unset); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, init); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, remove); +ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, clear); + + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - ZEPHIR_CALL_METHOD(&result, this_ptr, "processrender", NULL, 0, &controllerName, &actionName, ¶ms); - zephir_check_call_status(); - if (!(zephir_is_true(&result))) { - RETURN_MM_BOOL(0); - } - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Mvc_View, reset) +ZEPHIR_INIT_CLASS(Phalcon_Session_Exception) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, __$null, _0, _1, _2; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session, Exception, phalcon, session_exception, zend_ce_exception, NULL, 0); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + return SUCCESS; +} - ZEPHIR_MM_GROW(); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); - } - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &__$false); - } - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, 5); - zephir_update_property_zval(this_ptr, ZEND_STRL("renderLevel"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &__$null); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_2); - RETURN_THIS(); + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Session_Manager) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session, Manager, phalcon, session_manager, phalcon_di_abstractinjectionaware_ce, phalcon_session_manager_method_entry, 0); + + zend_declare_property_null(phalcon_session_manager_ce, SL("adapter"), ZEND_ACC_PRIVATE); + zend_declare_property_string(phalcon_session_manager_ce, SL("name"), "", ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_session_manager_ce, SL("options"), ZEND_ACC_PRIVATE); + zend_declare_property_string(phalcon_session_manager_ce, SL("uniqueId"), "", ZEND_ACC_PRIVATE); + phalcon_session_manager_ce->create_object = zephir_init_properties_Phalcon_Session_Manager; + + zend_class_implements(phalcon_session_manager_ce, 1, phalcon_session_managerinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_View, setBasePath) +static PHP_METHOD(Phalcon_Session_Manager, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *basePath_param = NULL; - zval basePath; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(basePath) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &basePath_param); - zephir_get_strval(&basePath, basePath_param); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("basePath"), &basePath); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setoptions", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, setContent) +static PHP_METHOD(Phalcon_Session_Manager, __get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *content_param = NULL; - zval content; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content); + ZVAL_UNDEF(&key); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(content) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &content_param); - zephir_get_strval(&content, content_param); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &content); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, setEventsManager) +static PHP_METHOD(Phalcon_Session_Manager, __isset) { - zval *eventsManager, eventsManager_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); + ZVAL_UNDEF(&key); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, setLayout) +static PHP_METHOD(Phalcon_Session_Manager, __set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *layout_param = NULL; - zval layout; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&layout); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(layout) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &layout_param); - zephir_get_strval(&layout, layout_param); + zephir_fetch_params(1, 2, 0, &key_param, &value); + zephir_get_strval(&key, key_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("layout"), &layout); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, &key, value); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, setLayoutsDir) +static PHP_METHOD(Phalcon_Session_Manager, __unset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *layoutsDir_param = NULL; - zval layoutsDir; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&layoutsDir); + ZVAL_UNDEF(&key); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(layoutsDir) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &layoutsDir_param); - zephir_get_strval(&layoutsDir, layoutsDir_param); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("layoutsDir"), &layoutsDir); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, &key); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, setMainView) +static PHP_METHOD(Phalcon_Session_Manager, destroy) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *viewPath_param = NULL; - zval viewPath; + zval _SESSION, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&viewPath); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(viewPath) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_SESSION); + ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &viewPath_param); - zephir_get_strval(&viewPath, viewPath_param); - + zephir_get_global(&_SESSION, SL("_SESSION")); - zephir_update_property_zval(this_ptr, ZEND_STRL("mainView"), &viewPath); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_FUNCTION(NULL, "session_destroy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_SESSION); + array_init(&_SESSION); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, setPartialsDir) +static PHP_METHOD(Phalcon_Session_Manager, exists) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *partialsDir_param = NULL; - zval partialsDir; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&partialsDir); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(partialsDir) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &partialsDir_param); - zephir_get_strval(&partialsDir, partialsDir_param); - - zephir_update_property_zval(this_ptr, ZEND_STRL("partialsDir"), &partialsDir); - RETURN_THIS(); + ZEPHIR_CALL_FUNCTION(&_0, "session_status", NULL, 0); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_LONG_IDENTICAL(&_0, 2)); } -static PHP_METHOD(Phalcon_Mvc_View, setParamToView) +static PHP_METHOD(Phalcon_Session_Manager, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, *value, value_sub; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool remove; + zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, *remove_param = NULL, _SESSION, __$null, value, uniqueKey, _0; zval key; zval *this_ptr = getThis(); ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&_SESSION); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) + ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_BOOL(remove) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_global(&_SESSION, SL("_SESSION")); + zephir_fetch_params(1, 1, 2, &key_param, &defaultValue, &remove_param); + zephir_get_strval(&key, key_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (!remove_param) { + remove = 0; } else { - ZEPHIR_INIT_VAR(&key); + remove = zephir_get_boolval(remove_param); } - zephir_update_property_array(this_ptr, SL("viewParams"), &key, value); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&value); + ZVAL_NULL(&value); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_CCTOR(&value); + } + ZEPHIR_CALL_METHOD(&uniqueKey, this_ptr, "getuniquekey", NULL, 0, &key); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, this_ptr, "getarrval", NULL, 0, &_SESSION, &uniqueKey, defaultValue); + zephir_check_call_status(); + if (remove) { + zephir_array_unset(&_SESSION, &uniqueKey, PH_SEPARATE); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Mvc_View, setRenderLevel) +static PHP_METHOD(Phalcon_Session_Manager, getAdapter) { - zval *level_param = NULL, _0; - zend_long level; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(level) - ZEND_PARSE_PARAMETERS_END(); -#endif - zephir_fetch_params_without_memory_grow(1, 0, &level_param); - level = zephir_get_intval(level_param); + RETURN_MEMBER(getThis(), "adapter"); +} +static PHP_METHOD(Phalcon_Session_Manager, getId) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, level); - zephir_update_property_zval(this_ptr, ZEND_STRL("renderLevel"), &_0); - RETURN_THISW(); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_RETURN_CALL_FUNCTION("session_id", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, setTemplateAfter) +static PHP_METHOD(Phalcon_Session_Manager, getName) { - zval _0$$3; + zval _0, _1, _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *templateAfter, templateAfter_sub; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&templateAfter_sub); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + if (ZEPHIR_IS_IDENTICAL(&_1, &_0)) { + ZEPHIR_CALL_FUNCTION(&_2$$3, "session_name", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &_2$$3); + } + RETURN_MM_MEMBER(getThis(), "name"); +} + +static PHP_METHOD(Phalcon_Session_Manager, has) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, _SESSION, uniqueKey, _0; + zval key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_SESSION); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(templateAfter) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &templateAfter); + zephir_get_global(&_SESSION, SL("_SESSION")); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - if (Z_TYPE_P(templateAfter) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_fast_append(&_0$$3, templateAfter); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_0$$3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&uniqueKey, this_ptr, "getuniquekey", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_array_isset(&_SESSION, &uniqueKey)); +} + +static PHP_METHOD(Phalcon_Session_Manager, getOptions) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "options"); +} + +static PHP_METHOD(Phalcon_Session_Manager, regenerateId) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *deleteOldSession_param = NULL, _0, _1$$3; + zend_bool deleteOldSession; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(deleteOldSession) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &deleteOldSession_param); + if (!deleteOldSession_param) { + deleteOldSession = 1; } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), templateAfter); + deleteOldSession = zephir_get_boolval(deleteOldSession_param); + } + + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZVAL_BOOL(&_1$$3, (deleteOldSession ? 1 : 0)); + ZEPHIR_CALL_FUNCTION(NULL, "session_regenerate_id", NULL, 0, &_1$$3); + zephir_check_call_status(); } RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_View, setTemplateBefore) +static PHP_METHOD(Phalcon_Session_Manager, remove) { - zval _0$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *templateBefore, templateBefore_sub; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, _SESSION, uniqueKey, _0; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&templateBefore_sub); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_SESSION); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(templateBefore) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &templateBefore); + zephir_get_global(&_SESSION, SL("_SESSION")); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - if (Z_TYPE_P(templateBefore) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_fast_append(&_0$$3, templateBefore); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), templateBefore); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_METHOD(&uniqueKey, this_ptr, "getuniquekey", NULL, 0, &key); + zephir_check_call_status(); + zephir_array_unset(&_SESSION, &uniqueKey, PH_SEPARATE); } - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, setVar) +static PHP_METHOD(Phalcon_Session_Manager, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, *value, value_sub; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub, _SESSION, uniqueKey, _0; zval key; zval *this_ptr = getThis(); ZVAL_UNDEF(&key); ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_SESSION); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) @@ -57953,1330 +52211,616 @@ static PHP_METHOD(Phalcon_Mvc_View, setVar) ZEPHIR_MM_GROW(); + zephir_get_global(&_SESSION, SL("_SESSION")); zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); + zephir_get_strval(&key, key_param); + + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_METHOD(&uniqueKey, this_ptr, "getuniquekey", NULL, 0, &key); + zephir_check_call_status(); + zephir_array_update_zval(&_SESSION, &uniqueKey, value, PH_COPY | PH_SEPARATE); } + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Session_Manager, setAdapter) +{ + zval *adapter, adapter_sub; + zval *this_ptr = getThis(); - zephir_update_property_array(this_ptr, SL("viewParams"), &key, value); - RETURN_THIS(); + ZVAL_UNDEF(&adapter_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(adapter, php_session_iface_entry) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &adapter); + + + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), adapter); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_View, setVars) +static PHP_METHOD(Phalcon_Session_Manager, setId) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *params_param = NULL, *merge_param = NULL, _0$$3, _1$$3; - zval params; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sessionId_param = NULL, _0, _1$$3; + zval sessionId, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&sessionId); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(params) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sessionId) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, ¶ms_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); - if (!merge_param) { - merge = 1; - } else { - merge = zephir_get_boolval(merge_param); - } + zephir_fetch_params(1, 1, 0, &sessionId_param); + zephir_get_strval(&sessionId, sessionId_param); - if (merge) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_0$$3, &_1$$3, ¶ms); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), ¶ms); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_session_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SS(&_2$$3, "The session has already been started. ", "To change the id, use regenerateId()"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 32, &_2$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Session/Manager.zep", 271); + ZEPHIR_MM_RESTORE(); + return; } + ZEPHIR_CALL_FUNCTION(NULL, "session_id", NULL, 0, &sessionId); + zephir_check_call_status(); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_View, setViewsDir) +static PHP_METHOD(Phalcon_Session_Manager, setName) { - zend_string *_5$$5; - zend_ulong _4$$5; - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *viewsDir, viewsDir_sub, position, directory, newViewsDir, _1$$4, *_2$$5, _3$$5, _6$$6, _7$$8; + zval *name_param = NULL, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&viewsDir_sub); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&newViewsDir); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(viewsDir) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &viewsDir); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); - _0 = Z_TYPE_P(viewsDir) != IS_STRING; - if (_0) { - _0 = Z_TYPE_P(viewsDir) != IS_ARRAY; - } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory must be a string or an array", "phalcon/Mvc/View.zep", 982); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_session_exception_ce, "Cannot set session name after a session has started", "phalcon/Session/Manager.zep", 294); return; } - if (Z_TYPE_P(viewsDir) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "getdirseparator", NULL, 491, viewsDir); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewsDirs"), &_1$$4); - } else { - ZEPHIR_INIT_VAR(&newViewsDir); - array_init(&newViewsDir); - zephir_is_iterable(viewsDir, 0, "phalcon/Mvc/View.zep", 1000); - if (Z_TYPE_P(viewsDir) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(viewsDir), _4$$5, _5$$5, _2$$5) - { - ZEPHIR_INIT_NVAR(&position); - if (_5$$5 != NULL) { - ZVAL_STR_COPY(&position, _5$$5); - } else { - ZVAL_LONG(&position, _4$$5); - } - ZEPHIR_INIT_NVAR(&directory); - ZVAL_COPY(&directory, _2$$5); - if (Z_TYPE_P(&directory) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory item must be a string", "phalcon/Mvc/View.zep", 994); - return; - } - ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getdirseparator", NULL, 491, &directory); - zephir_check_call_status(); - zephir_array_update_zval(&newViewsDir, &position, &_6$$6, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, viewsDir, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, viewsDir, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&position, viewsDir, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&directory, viewsDir, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&directory) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory item must be a string", "phalcon/Mvc/View.zep", 994); - return; - } - ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "getdirseparator", NULL, 491, &directory); - zephir_check_call_status(); - zephir_array_update_zval(&newViewsDir, &position, &_7$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, viewsDir, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&directory); - ZEPHIR_INIT_NVAR(&position); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewsDirs"), &newViewsDir); - } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + ZEPHIR_CALL_FUNCTION(NULL, "session_name", NULL, 0, &name); + zephir_check_call_status(); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_View, start) +static PHP_METHOD(Phalcon_Session_Manager, setOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL, _0, _1, _2; + zval options; zval *this_ptr = getThis(); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); - ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 389); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "uniqueId"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, ""); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &__$null); - RETURN_THIS(); + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueId"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_View, toString) +static PHP_METHOD(Phalcon_Session_Manager, start) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval _COOKIE, name, value, _0, _1, _2, _7, _3$$6, _4$$6, _5$$6, _6$$6; zend_long ZEPHIR_LAST_CALL_STATUS; - zval params; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, result, _0; - zval controllerName, actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_COOKIE); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(¶ms); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$6); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); + zephir_get_global(&_COOKIE, SL("_COOKIE")); + + ZEPHIR_CALL_METHOD(&name, this_ptr, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(1); } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "phpheaderssent", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { + RETURN_MM_BOOL(0); } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); + ZEPHIR_OBS_VAR(&_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC); + if (UNEXPECTED(!(zephir_is_instance_of(&_2, SL("SessionHandlerInterface"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_session_exception_ce, "The session adapter is not valid", "phalcon/Session/Manager.zep", 338); + return; } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); + ZEPHIR_OBS_VAR(&value); + if (zephir_array_isset_fetch(&value, &_COOKIE, &name, 0)) { + ZEPHIR_INIT_VAR(&_3$$6); + ZEPHIR_INIT_VAR(&_4$$6); + ZVAL_STRING(&_4$$6, "/^[a-z0-9]+$/iD"); + ZEPHIR_INIT_VAR(&_5$$6); + ZEPHIR_INIT_VAR(&_6$$6); + ZVAL_STRING(&_6$$6, "/^[a-z0-9]+$/iD"); + zephir_preg_match(&_5$$6, &_6$$6, &value, &_3$$6, 0, 0 , 0 ); + if (!(zephir_is_true(&_5$$6))) { + zephir_array_unset(&_COOKIE, &name, PH_SEPARATE); + } } - - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "start", NULL, 0); + zephir_read_property(&_7, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "session_set_save_handler", NULL, 0, &_7); zephir_check_call_status(); - ZVAL_BOOL(&_0, 0); - ZEPHIR_CALL_METHOD(&result, this_ptr, "processrender", NULL, 0, &controllerName, &actionName, ¶ms, &_0); + ZEPHIR_RETURN_CALL_FUNCTION("session_start", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "finish", NULL, 0); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Session_Manager, status) +{ + zval status; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&status); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_FUNCTION(&status, "session_status", NULL, 0); zephir_check_call_status(); - if (!(zephir_is_true(&result))) { - RETURN_MM_STRING(""); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcontent", NULL, 0); + do { + if (ZEPHIR_IS_LONG(&status, 0)) { + RETURN_MM_LONG(0); + } + if (ZEPHIR_IS_LONG(&status, 2)) { + RETURN_MM_LONG(2); + } + } while(0); + + RETURN_MM_LONG(1); +} + +static PHP_METHOD(Phalcon_Session_Manager, phpHeadersSent) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + + + ZEPHIR_MM_GROW(); + + ZEPHIR_RETURN_CALL_FUNCTION("headers_sent", NULL, 358); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, engineRender) +static PHP_METHOD(Phalcon_Session_Manager, getUniqueKey) { - zend_string *_9$$3, *_28$$16; - zend_ulong _8$$3, _27$$16; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_13 = NULL, *_16 = NULL, *_20 = NULL, *_23 = NULL, *_32 = NULL, *_35 = NULL, *_39 = NULL, *_42 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool silence, mustClean; - zval viewPath, _45$$30; - zval *engines_param = NULL, *viewPath_param = NULL, *silence_param = NULL, *mustClean_param = NULL, basePath, engine, eventsManager, extension, viewsDir, viewsDirPath, viewEnginePath, viewEnginePaths, viewParams, _0, _1, *_2, _3, _4$$3, *_6$$3, _7$$3, _11$$8, _12$$8, _14$$7, _15$$10, _18$$13, _19$$13, _21$$12, _22$$15, _24$$16, *_25$$16, _26$$16, _30$$21, _31$$21, _33$$20, _34$$23, _37$$26, _38$$26, _40$$25, _41$$28, _43$$29, _44$$30; - zval engines, _10$$8, _17$$13, _29$$21, _36$$26; + zval *key_param = NULL, prefix, _0, _1; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_17$$13); - ZVAL_UNDEF(&_29$$21); - ZVAL_UNDEF(&_36$$26); - ZVAL_UNDEF(&basePath); - ZVAL_UNDEF(&engine); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&viewsDir); - ZVAL_UNDEF(&viewsDirPath); - ZVAL_UNDEF(&viewEnginePath); - ZVAL_UNDEF(&viewEnginePaths); - ZVAL_UNDEF(&viewParams); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&prefix); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_18$$13); - ZVAL_UNDEF(&_19$$13); - ZVAL_UNDEF(&_21$$12); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_24$$16); - ZVAL_UNDEF(&_26$$16); - ZVAL_UNDEF(&_30$$21); - ZVAL_UNDEF(&_31$$21); - ZVAL_UNDEF(&_33$$20); - ZVAL_UNDEF(&_34$$23); - ZVAL_UNDEF(&_37$$26); - ZVAL_UNDEF(&_38$$26); - ZVAL_UNDEF(&_40$$25); - ZVAL_UNDEF(&_41$$28); - ZVAL_UNDEF(&_43$$29); - ZVAL_UNDEF(&_44$$30); - ZVAL_UNDEF(&viewPath); - ZVAL_UNDEF(&_45$$30); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ARRAY(engines) - Z_PARAM_STR(viewPath) - Z_PARAM_BOOL(silence) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(mustClean) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &engines_param, &viewPath_param, &silence_param, &mustClean_param); - zephir_get_arrval(&engines, engines_param); - zephir_get_strval(&viewPath, viewPath_param); - silence = zephir_get_boolval(silence_param); - if (!mustClean_param) { - mustClean = 1; - } else { - mustClean = zephir_get_boolval(mustClean_param); - } + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&basePath, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&viewParams, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - ZEPHIR_INIT_VAR(&viewEnginePaths); - array_init(&viewEnginePaths); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getviewsdirs", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_1, 0, "phalcon/Mvc/View.zep", 1106); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_1), _2) - { - ZEPHIR_INIT_NVAR(&viewsDir); - ZVAL_COPY(&viewsDir, _2); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "isabsolutepath", &_5, 492, &viewPath); - zephir_check_call_status(); - if (!(zephir_is_true(&_4$$3))) { - ZEPHIR_INIT_NVAR(&viewsDirPath); - ZEPHIR_CONCAT_VVV(&viewsDirPath, &basePath, &viewsDir, &viewPath); - } else { - ZEPHIR_CPY_WRT(&viewsDirPath, &viewPath); - } - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 1101); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _8$$3, _9$$3, _6$$3) - { - ZEPHIR_INIT_NVAR(&extension); - if (_9$$3 != NULL) { - ZVAL_STR_COPY(&extension, _9$$3); - } else { - ZVAL_LONG(&extension, _8$$3); - } - ZEPHIR_INIT_NVAR(&engine); - ZVAL_COPY(&engine, _6$$3); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_10$$8); - zephir_create_array(&_10$$8, 1, 0); - zephir_array_fast_append(&_10$$8, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_10$$8); - ZEPHIR_INIT_NVAR(&_12$$8); - ZVAL_STRING(&_12$$8, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_11$$8, &eventsManager, "fire", &_13, 0, &_12$$8, this_ptr, &viewEnginePath); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$8)) { - continue; - } - } - if (mustClean) { - ZVAL_BOOL(&_14$$7, 1); - } else { - ZVAL_BOOL(&_14$$7, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_14$$7); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_15$$10); - ZVAL_STRING(&_15$$10, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_16, 0, &_15$$10, this_ptr); - zephir_check_call_status(); - } - RETURN_MM_NULL(); - } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$3, &engines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&engine, &engines, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_17$$13); - zephir_create_array(&_17$$13, 1, 0); - zephir_array_fast_append(&_17$$13, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_17$$13); - ZEPHIR_INIT_NVAR(&_19$$13); - ZVAL_STRING(&_19$$13, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_18$$13, &eventsManager, "fire", &_20, 0, &_19$$13, this_ptr, &viewEnginePath); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_18$$13)) { - continue; - } - } - if (mustClean) { - ZVAL_BOOL(&_21$$12, 1); - } else { - ZVAL_BOOL(&_21$$12, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_21$$12); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_22$$15); - ZVAL_STRING(&_22$$15, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_23, 0, &_22$$15, this_ptr); - zephir_check_call_status(); - } - RETURN_MM_NULL(); - } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&engine); - ZEPHIR_INIT_NVAR(&extension); - } ZEND_HASH_FOREACH_END(); + ZEPHIR_OBS_VAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueId"), PH_NOISY_CC); + if (1 != ZEPHIR_IS_EMPTY(&_0)) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("uniqueId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&prefix); + ZEPHIR_CONCAT_VS(&prefix, &_1, "#"); } else { - ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&viewsDir, &_1, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_24$$16, this_ptr, "isabsolutepath", &_5, 492, &viewPath); - zephir_check_call_status(); - if (!(zephir_is_true(&_24$$16))) { - ZEPHIR_INIT_NVAR(&viewsDirPath); - ZEPHIR_CONCAT_VVV(&viewsDirPath, &basePath, &viewsDir, &viewPath); - } else { - ZEPHIR_CPY_WRT(&viewsDirPath, &viewPath); - } - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 1101); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _27$$16, _28$$16, _25$$16) - { - ZEPHIR_INIT_NVAR(&extension); - if (_28$$16 != NULL) { - ZVAL_STR_COPY(&extension, _28$$16); - } else { - ZVAL_LONG(&extension, _27$$16); - } - ZEPHIR_INIT_NVAR(&engine); - ZVAL_COPY(&engine, _25$$16); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_29$$21); - zephir_create_array(&_29$$21, 1, 0); - zephir_array_fast_append(&_29$$21, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_29$$21); - ZEPHIR_INIT_NVAR(&_31$$21); - ZVAL_STRING(&_31$$21, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_30$$21, &eventsManager, "fire", &_32, 0, &_31$$21, this_ptr, &viewEnginePath); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_30$$21)) { - continue; - } - } - if (mustClean) { - ZVAL_BOOL(&_33$$20, 1); - } else { - ZVAL_BOOL(&_33$$20, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_33$$20); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_34$$23); - ZVAL_STRING(&_34$$23, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_35, 0, &_34$$23, this_ptr); - zephir_check_call_status(); - } - RETURN_MM_NULL(); - } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_26$$16, &engines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_26$$16)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&engine, &engines, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_36$$26); - zephir_create_array(&_36$$26, 1, 0); - zephir_array_fast_append(&_36$$26, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_36$$26); - ZEPHIR_INIT_NVAR(&_38$$26); - ZVAL_STRING(&_38$$26, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_37$$26, &eventsManager, "fire", &_39, 0, &_38$$26, this_ptr, &viewEnginePath); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_37$$26)) { - continue; - } - } - if (mustClean) { - ZVAL_BOOL(&_40$$25, 1); - } else { - ZVAL_BOOL(&_40$$25, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_40$$25); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_41$$28); - ZVAL_STRING(&_41$$28, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_42, 0, &_41$$28, this_ptr); - zephir_check_call_status(); - } - RETURN_MM_NULL(); - } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&engine); - ZEPHIR_INIT_NVAR(&extension); - ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&viewsDir); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &viewEnginePaths); - ZEPHIR_INIT_VAR(&_43$$29); - ZVAL_STRING(&_43$$29, "view:notFoundView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_43$$29, this_ptr, &viewEnginePath); - zephir_check_call_status(); - } - if (!(silence)) { - ZEPHIR_INIT_VAR(&_44$$30); - object_init_ex(&_44$$30, phalcon_mvc_view_exception_ce); - ZEPHIR_INIT_VAR(&_45$$30); - ZEPHIR_CONCAT_SVS(&_45$$30, "View '", &viewPath, "' was not found in any of the views directory"); - ZEPHIR_CALL_METHOD(NULL, &_44$$30, "__construct", NULL, 32, &_45$$30); - zephir_check_call_status(); - zephir_throw_exception_debug(&_44$$30, "phalcon/Mvc/View.zep", 1115); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, ""); } - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_VV(return_value, &prefix, &key); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, isAbsolutePath) +static PHP_METHOD(Phalcon_Session_Manager, getArrVal) { - unsigned char _6, _2$$3, _4$$3; - zend_bool _5, _1$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *path_param = NULL, _0; - zval path; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(path) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &path_param); - zephir_get_strval(&path, path_param); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_OS"); - if (ZEPHIR_IS_STRING_IDENTICAL(&_0, "WINNT")) { - _1$$3 = zephir_fast_strlen_ev(&path) >= 3; - if (_1$$3) { - _2$$3 = ZEPHIR_STRING_OFFSET(&path, 1); - _1$$3 = _2$$3 == ':'; - } - _3$$3 = _1$$3; - if (_3$$3) { - _4$$3 = ZEPHIR_STRING_OFFSET(&path, 2); - _3$$3 = _4$$3 == '\\'; - } - RETURN_MM_BOOL(_3$$3); - } - _5 = zephir_fast_strlen_ev(&path) >= 1; - if (_5) { - _6 = ZEPHIR_STRING_OFFSET(&path, 0); - _5 = _6 == '/'; + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 1)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); } - RETURN_MM_BOOL(_5); + RETURN_CTOR(&value); } -static PHP_METHOD(Phalcon_Mvc_View, loadTemplateEngines) +zend_object *zephir_init_properties_Phalcon_Session_Manager(zend_class_entry *class_type) { - zval _15$$11, _21$$17; - zend_class_entry *_8$$9, *_17$$15; - zend_string *_6$$5; - zend_ulong _5$$5; - zval engines, di, registeredEngines, engineService, extension, _0, _1$$3, _2$$4, *_3$$5, _4$$5, _7$$9, _11$$12, _12$$12, _14$$11, _16$$15, _18$$18, _19$$18, _20$$17; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_10 = NULL, *_13 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Session_ManagerInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Session, ManagerInterface, phalcon, session_managerinterface, phalcon_session_managerinterface_method_entry); + + zephir_declare_class_constant_long(phalcon_session_managerinterface_ce, SL("SESSION_ACTIVE"), 2); + + zephir_declare_class_constant_long(phalcon_session_managerinterface_ce, SL("SESSION_DISABLED"), 0); + + zephir_declare_class_constant_long(phalcon_session_managerinterface_ce, SL("SESSION_NONE"), 1); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, __get); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, __isset); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, __set); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, __unset); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, exists); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, destroy); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, getId); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, getAdapter); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, getOptions); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, remove); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, setAdapter); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, setId); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, setName); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, setOptions); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, status); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, start); +ZEPHIR_DOC_METHOD(Phalcon_Session_ManagerInterface, regenerateId); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_AbstractAdapter) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Session\\Adapter, AbstractAdapter, phalcon, session_adapter_abstractadapter, phalcon_session_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_session_adapter_abstractadapter_ce, SL("adapter"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_session_adapter_abstractadapter_ce, 1, php_session_iface_entry); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, close) +{ zval *this_ptr = getThis(); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&di); - ZVAL_UNDEF(®isteredEngines); - ZVAL_UNDEF(&engineService); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_11$$12); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_14$$11); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_18$$18); - ZVAL_UNDEF(&_19$$18); - ZVAL_UNDEF(&_20$$17); - ZVAL_UNDEF(&_15$$11); - ZVAL_UNDEF(&_21$$17); - ZEPHIR_MM_GROW(); + RETURN_BOOL(1); +} - zephir_read_property(&_0, this_ptr, ZEND_STRL("engines"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&engines, &_0); - if (ZEPHIR_IS_FALSE_IDENTICAL(&engines)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&di, &_1$$3); - ZEPHIR_INIT_NVAR(&engines); - array_init(&engines); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(®isteredEngines, &_1$$3); - if (ZEPHIR_IS_EMPTY(®isteredEngines)) { - ZEPHIR_INIT_VAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_mvc_view_engine_php_ce); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 493, this_ptr, &di); - zephir_check_call_status(); - zephir_array_update_string(&engines, SL(".phtml"), &_2$$4, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&di) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injection container is required to access application services", "phalcon/Mvc/View.zep", 1158); - return; - } - zephir_is_iterable(®isteredEngines, 0, "phalcon/Mvc/View.zep", 1195); - if (Z_TYPE_P(®isteredEngines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(®isteredEngines), _5$$5, _6$$5, _3$$5) - { - ZEPHIR_INIT_NVAR(&extension); - if (_6$$5 != NULL) { - ZVAL_STR_COPY(&extension, _6$$5); - } else { - ZVAL_LONG(&extension, _5$$5); - } - ZEPHIR_INIT_NVAR(&engineService); - ZVAL_COPY(&engineService, _3$$5); - if (Z_TYPE_P(&engineService) == IS_OBJECT) { - if (zephir_is_instance_of(&engineService, SL("Closure"))) { - _8$$9 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_7$$9, _8$$9, "bind", &_9, 0, &engineService, &di); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&engineService, &_7$$9); - ZEPHIR_CALL_FUNCTION(&_7$$9, "call_user_func", &_10, 187, &engineService, this_ptr); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_7$$9, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&engines, &extension, &engineService, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&engineService) != IS_STRING) { - ZEPHIR_INIT_NVAR(&_11$$12); - object_init_ex(&_11$$12, phalcon_mvc_view_exception_ce); - ZEPHIR_INIT_NVAR(&_12$$12); - ZEPHIR_CONCAT_SV(&_12$$12, "Invalid template engine registration for extension: ", &extension); - ZEPHIR_CALL_METHOD(NULL, &_11$$12, "__construct", &_13, 32, &_12$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$12, "phalcon/Mvc/View.zep", 1186); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_15$$11); - zephir_create_array(&_15$$11, 1, 0); - zephir_array_fast_append(&_15$$11, this_ptr); - ZEPHIR_CALL_METHOD(&_14$$11, &di, "get", NULL, 0, &engineService, &_15$$11); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_14$$11, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, ®isteredEngines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4$$5, ®isteredEngines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, ®isteredEngines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&engineService, ®isteredEngines, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&engineService) == IS_OBJECT) { - if (zephir_is_instance_of(&engineService, SL("Closure"))) { - _17$$15 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_16$$15, _17$$15, "bind", &_9, 0, &engineService, &di); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&engineService, &_16$$15); - ZEPHIR_CALL_FUNCTION(&_16$$15, "call_user_func", &_10, 187, &engineService, this_ptr); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_16$$15, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&engines, &extension, &engineService, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&engineService) != IS_STRING) { - ZEPHIR_INIT_NVAR(&_18$$18); - object_init_ex(&_18$$18, phalcon_mvc_view_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$18); - ZEPHIR_CONCAT_SV(&_19$$18, "Invalid template engine registration for extension: ", &extension); - ZEPHIR_CALL_METHOD(NULL, &_18$$18, "__construct", &_13, 32, &_19$$18); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$18, "phalcon/Mvc/View.zep", 1186); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_21$$17); - zephir_create_array(&_21$$17, 1, 0); - zephir_array_fast_append(&_21$$17, this_ptr); - ZEPHIR_CALL_METHOD(&_20$$17, &di, "get", NULL, 0, &engineService, &_21$$17); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_20$$17, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, ®isteredEngines, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&engineService); - ZEPHIR_INIT_NVAR(&extension); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &engines); - } - RETURN_CCTOR(&engines); -} - -static PHP_METHOD(Phalcon_Mvc_View, processRender) +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, destroy) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, renderLevel = 0; - zend_bool fireEvents, silence = 0, _5, _30; - zval params; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, *fireEvents_param = NULL, layoutsDir, layout, pickView, layoutName, engines, renderView, pickViewAction, eventsManager, disabledLevels, templatesBefore, templatesAfter, templateBefore, templateAfter, _0, _2, _4, _8, _9, _1$$3, _6$$11, _7$$11, _10$$15, _11$$17, *_12$$17, _13$$17, _14$$18, _15$$18, _16$$19, _17$$19, _18$$21, _19$$21, _20$$23, *_21$$23, _22$$23, _23$$24, _24$$24, _25$$25, _26$$25, _27$$27, _28$$27, _29$$13, _31$$28; - zval controllerName, actionName, _3$$7; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sessionId, sessionId_sub, _1, _2, _3$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&layoutsDir); - ZVAL_UNDEF(&layout); - ZVAL_UNDEF(&pickView); - ZVAL_UNDEF(&layoutName); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&renderView); - ZVAL_UNDEF(&pickViewAction); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&disabledLevels); - ZVAL_UNDEF(&templatesBefore); - ZVAL_UNDEF(&templatesAfter); - ZVAL_UNDEF(&templateBefore); - ZVAL_UNDEF(&templateAfter); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_6$$11); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_10$$15); - ZVAL_UNDEF(&_11$$17); - ZVAL_UNDEF(&_13$$17); - ZVAL_UNDEF(&_14$$18); - ZVAL_UNDEF(&_15$$18); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_17$$19); - ZVAL_UNDEF(&_18$$21); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$23); - ZVAL_UNDEF(&_22$$23); - ZVAL_UNDEF(&_23$$24); - ZVAL_UNDEF(&_24$$24); - ZVAL_UNDEF(&_25$$25); - ZVAL_UNDEF(&_26$$25); - ZVAL_UNDEF(&_27$$27); - ZVAL_UNDEF(&_28$$27); - ZVAL_UNDEF(&_29$$13); - ZVAL_UNDEF(&_31$$28); - ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&_3$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - Z_PARAM_BOOL(fireEvents) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(sessionId) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms_param, &fireEvents_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - if (!fireEvents_param) { - fireEvents = 1; - } else { - fireEvents = zephir_get_boolval(fireEvents_param); - } + zephir_fetch_params(1, 1, 0, &sessionId); - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("disabled"), PH_NOISY_CC | PH_READONLY); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { - ZEPHIR_CALL_FUNCTION(&_1$$3, "ob_get_contents", NULL, 494); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1$$3); - RETURN_MM_BOOL(0); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("controllerName"), &controllerName); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvars", NULL, 0, ¶ms); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("layoutsDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&layoutsDir, &_2); - if (!(zephir_is_true(&layoutsDir))) { - ZEPHIR_INIT_NVAR(&layoutsDir); - ZVAL_STRING(&layoutsDir, "layouts/"); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("layout"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&layout, &_2); - if (zephir_is_true(&layout)) { - ZEPHIR_CPY_WRT(&layoutName, &layout); - } else { - ZEPHIR_CPY_WRT(&layoutName, &controllerName); - } - ZEPHIR_CALL_METHOD(&engines, this_ptr, "loadtemplateengines", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pickView"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pickView, &_2); - if (Z_TYPE_P(&pickView) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$7); - ZEPHIR_CONCAT_VSV(&_3$$7, &controllerName, "/", &actionName); - ZEPHIR_CPY_WRT(&renderView, &_3$$7); - } else { - ZEPHIR_OBS_NVAR(&renderView); - zephir_array_fetch_long(&renderView, &pickView, 0, PH_NOISY, "phalcon/Mvc/View.zep", 1273); - if (Z_TYPE_P(&layoutName) == IS_NULL) { - ZEPHIR_OBS_VAR(&pickViewAction); - if (zephir_array_isset_long_fetch(&pickViewAction, &pickView, 1, 0)) { - ZEPHIR_CPY_WRT(&layoutName, &pickViewAction); - } - } - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_2); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CREATE_SYMBOL_TABLE(); - - _5 = fireEvents; - if (_5) { - _5 = Z_TYPE_P(&eventsManager) == IS_OBJECT; - } - if (_5) { - ZEPHIR_INIT_VAR(&_7$$11); - ZVAL_STRING(&_7$$11, "view:beforeRender"); - ZEPHIR_CALL_METHOD(&_6$$11, &eventsManager, "fire", NULL, 0, &_7$$11, this_ptr); + _0 = !(ZEPHIR_IS_EMPTY(sessionId)); + if (_0) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "has", NULL, 0, sessionId); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$11)) { - RETURN_MM_BOOL(0); - } - } - ZEPHIR_CALL_FUNCTION(&_8, "ob_get_contents", NULL, 494); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_8); - silence = 1; - zephir_read_property(&_2, this_ptr, ZEND_STRL("disabledLevels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&disabledLevels, &_2); - ZEPHIR_OBS_VAR(&_9); - zephir_read_property(&_9, this_ptr, ZEND_STRL("renderLevel"), PH_NOISY_CC); - renderLevel = zephir_get_intval(&_9); - if (renderLevel) { - if (renderLevel >= 1) { - if (!(zephir_array_isset_long(&disabledLevels, 1))) { - ZEPHIR_INIT_ZVAL_NREF(_10$$15); - ZVAL_LONG(&_10$$15, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_10$$15); - if (silence) { - ZVAL_BOOL(&_10$$15, 1); - } else { - ZVAL_BOOL(&_10$$15, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &renderView, &_10$$15); - zephir_check_call_status(); - } - } - if (renderLevel >= 2) { - if (!(zephir_array_isset_long(&disabledLevels, 2))) { - ZEPHIR_INIT_ZVAL_NREF(_11$$17); - ZVAL_LONG(&_11$$17, 2); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_11$$17); - zephir_read_property(&_11$$17, this_ptr, ZEND_STRL("templatesBefore"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&templatesBefore, &_11$$17); - silence = 0; - zephir_is_iterable(&templatesBefore, 0, "phalcon/Mvc/View.zep", 1349); - if (Z_TYPE_P(&templatesBefore) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&templatesBefore), _12$$17) - { - ZEPHIR_INIT_NVAR(&templateBefore); - ZVAL_COPY(&templateBefore, _12$$17); - ZEPHIR_INIT_NVAR(&_14$$18); - ZEPHIR_CONCAT_VV(&_14$$18, &layoutsDir, &templateBefore); - if (silence) { - ZVAL_BOOL(&_15$$18, 1); - } else { - ZVAL_BOOL(&_15$$18, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_14$$18, &_15$$18); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &templatesBefore, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_13$$17, &templatesBefore, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_13$$17)) { - break; - } - ZEPHIR_CALL_METHOD(&templateBefore, &templatesBefore, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_16$$19); - ZEPHIR_CONCAT_VV(&_16$$19, &layoutsDir, &templateBefore); - if (silence) { - ZVAL_BOOL(&_17$$19, 1); - } else { - ZVAL_BOOL(&_17$$19, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_16$$19, &_17$$19); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &templatesBefore, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&templateBefore); - silence = 1; - } - } - if (renderLevel >= 3) { - if (!(zephir_array_isset_long(&disabledLevels, 3))) { - ZEPHIR_INIT_ZVAL_NREF(_18$$21); - ZVAL_LONG(&_18$$21, 3); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_18$$21); - ZEPHIR_INIT_VAR(&_19$$21); - ZEPHIR_CONCAT_VV(&_19$$21, &layoutsDir, &layoutName); - if (silence) { - ZVAL_BOOL(&_18$$21, 1); - } else { - ZVAL_BOOL(&_18$$21, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_19$$21, &_18$$21); - zephir_check_call_status(); - } - } - if (renderLevel >= 4) { - if (!(zephir_array_isset_long(&disabledLevels, 4))) { - ZEPHIR_INIT_ZVAL_NREF(_20$$23); - ZVAL_LONG(&_20$$23, 4); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_20$$23); - zephir_read_property(&_20$$23, this_ptr, ZEND_STRL("templatesAfter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&templatesAfter, &_20$$23); - silence = 0; - zephir_is_iterable(&templatesAfter, 0, "phalcon/Mvc/View.zep", 1385); - if (Z_TYPE_P(&templatesAfter) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&templatesAfter), _21$$23) - { - ZEPHIR_INIT_NVAR(&templateAfter); - ZVAL_COPY(&templateAfter, _21$$23); - ZEPHIR_INIT_NVAR(&_23$$24); - ZEPHIR_CONCAT_VV(&_23$$24, &layoutsDir, &templateAfter); - if (silence) { - ZVAL_BOOL(&_24$$24, 1); - } else { - ZVAL_BOOL(&_24$$24, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_23$$24, &_24$$24); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &templatesAfter, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_22$$23, &templatesAfter, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_22$$23)) { - break; - } - ZEPHIR_CALL_METHOD(&templateAfter, &templatesAfter, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_25$$25); - ZEPHIR_CONCAT_VV(&_25$$25, &layoutsDir, &templateAfter); - if (silence) { - ZVAL_BOOL(&_26$$25, 1); - } else { - ZVAL_BOOL(&_26$$25, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_25$$25, &_26$$25); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &templatesAfter, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&templateAfter); - silence = 1; - } - } - if (renderLevel >= 5) { - if (!(zephir_array_isset_long(&disabledLevels, 5))) { - ZEPHIR_INIT_ZVAL_NREF(_27$$27); - ZVAL_LONG(&_27$$27, 5); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_27$$27); - zephir_read_property(&_27$$27, this_ptr, ZEND_STRL("mainView"), PH_NOISY_CC | PH_READONLY); - if (silence) { - ZVAL_BOOL(&_28$$27, 1); - } else { - ZVAL_BOOL(&_28$$27, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_27$$27, &_28$$27); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_ZVAL_NREF(_29$$13); - ZVAL_LONG(&_29$$13, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_29$$13); - } - _30 = fireEvents; - if (_30) { - _30 = Z_TYPE_P(&eventsManager) == IS_OBJECT; + _0 = zephir_is_true(&_2); } - if (_30) { - ZEPHIR_INIT_VAR(&_31$$28); - ZVAL_STRING(&_31$$28, "view:afterRender"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_31$$28, this_ptr); + if (_0) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_3$$3, "delete", NULL, 0, sessionId); zephir_check_call_status(); + RETURN_MM(); } RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_View, getDirSeparator) +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, gc) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *directory_param = NULL, _0, _1; - zval directory; + zval *maxlifetime_param = NULL; + zend_long maxlifetime; zval *this_ptr = getThis(); - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(directory) + Z_PARAM_LONG(maxlifetime) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &directory_param); - if (UNEXPECTED(Z_TYPE_P(directory_param) != IS_STRING && Z_TYPE_P(directory_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'directory' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(directory_param) == IS_STRING)) { - zephir_get_strval(&directory, directory_param); - } else { - ZEPHIR_INIT_VAR(&directory); - } + zephir_fetch_params_without_memory_grow(1, 0, &maxlifetime_param); + maxlifetime = zephir_get_intval(maxlifetime_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); - ZEPHIR_CONCAT_VS(return_value, &_0, "/"); - RETURN_MM(); + RETURN_BOOL(1); } -zend_object *zephir_init_properties_Phalcon_Mvc_View(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, read) { - zval _0, _2, _4, _6, _8, _10, _12, _14, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$10); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("viewParams"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("viewsDirs"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("templatesBefore"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templatesBefore"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("templatesAfter"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templatesAfter"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("registeredEngines"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_13$$9); - } - zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("disabledLevels"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_14) == IS_NULL) { - ZEPHIR_INIT_VAR(&_15$$10); - array_init(&_15$$10); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("disabledLevels"), &_15$$10); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sessionId, sessionId_sub, data, _0, _1; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(sessionId) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &sessionId); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewBaseInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewBaseInterface, phalcon, mvc_viewbaseinterface, phalcon_mvc_viewbaseinterface_method_entry); - - return SUCCESS; + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&data, &_0, "get", NULL, 0, sessionId); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + if (Z_TYPE_P(&data) == IS_NULL) { + ZVAL_STRING(&_1, ""); + } else { + ZEPHIR_CPY_WRT(&_1, &data); + } + RETURN_CCTOR(&_1); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getContent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getParamsToView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getViewsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, partial); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setContent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setParamToView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setVar); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setViewsDir); - - +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, open) +{ + zval *savePath, savePath_sub, *sessionName, sessionName_sub; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&savePath_sub); + ZVAL_UNDEF(&sessionName_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(savePath) + Z_PARAM_ZVAL(sessionName) + ZEND_PARSE_PARAMETERS_END(); #endif + zephir_fetch_params_without_memory_grow(2, 0, &savePath, &sessionName); + RETURN_BOOL(1); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewInterface) +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, write) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewInterface, phalcon, mvc_viewinterface, phalcon_mvc_viewinterface_method_entry); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sessionId, sessionId_sub, *data, data_sub, _0; + zval *this_ptr = getThis(); - zend_class_implements(phalcon_mvc_viewinterface_ce, 1, phalcon_mvc_viewbaseinterface_ce); - return SUCCESS; -} + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(sessionId) + Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_END(); +#endif -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateAfter); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateBefore); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, disable); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, enable); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, finish); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActionName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActiveRenderPath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getControllerName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayout); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayoutsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getMainView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getPartialsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, isDisabled); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, pick); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, registerEngines); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, render); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayout); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayoutsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setMainView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setPartialsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setRenderLevel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateAfter); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateBefore); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, start); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &sessionId, &data); -#ifdef HAVE_CONFIG_H -#endif + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "set", NULL, 0, sessionId, data); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Session_Adapter_AbstractAdapter, getArrVal) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); +#endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Dispatcher, Exception, phalcon, mvc_dispatcher_exception, phalcon_dispatcher_exception_ce, NULL, 0); - return SUCCESS; + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 1)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CTOR(&value); } @@ -59289,868 +52833,1037 @@ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Collection) +ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Libmemcached) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, Collection, phalcon, mvc_micro_collection, phalcon_mvc_micro_collection_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("handler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("handlers"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_micro_collection_ce, SL("lazy"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_micro_collection_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); - phalcon_mvc_micro_collection_ce->create_object = zephir_init_properties_Phalcon_Mvc_Micro_Collection; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Libmemcached, phalcon, session_adapter_libmemcached, phalcon_session_adapter_abstractadapter_ce, phalcon_session_adapter_libmemcached_method_entry, 0); - zend_class_implements(phalcon_mvc_micro_collection_ce, 1, phalcon_mvc_micro_collectioninterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, delete) +static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval options; + zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&factory_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_adapterfactory_ce) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 1, 1, &factory, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DELETE"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "prefix"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sess-memc-"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); zephir_check_call_status(); - RETURN_THIS(); + zephir_array_update_string(&options, SL("prefix"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "libmemcached"); + ZEPHIR_CALL_METHOD(&_3, factory, "newinstance", NULL, 0, &_1, &options); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_3); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, get) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Noop) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Session\\Adapter, Noop, phalcon, session_adapter_noop, phalcon_session_adapter_noop_method_entry, 0); + + zend_declare_property_null(phalcon_session_adapter_noop_ce, SL("connection"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_session_adapter_noop_ce, SL("options"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_session_adapter_noop_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_session_adapter_noop_ce, SL("ttl"), 8600, ZEND_ACC_PROTECTED); + phalcon_session_adapter_noop_ce->create_object = zephir_init_properties_Phalcon_Session_Adapter_Noop; + + zend_class_implements(phalcon_session_adapter_noop_ce, 1, php_session_iface_entry); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Session_Adapter_Noop, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval *options_param = NULL, prefix; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&prefix); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GET"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_OBS_VAR(&prefix); + if (!(zephir_array_isset_string_fetch(&prefix, &options, SL("prefix"), 0))) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, ""); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandler) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, close) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "handler"); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandlers) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, destroy) { + zval *sessionId, sessionId_sub; zval *this_ptr = getThis(); + ZVAL_UNDEF(&sessionId_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(sessionId) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "handlers"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getPrefix) -{ - zval *this_ptr = getThis(); - + zephir_fetch_params_without_memory_grow(1, 0, &sessionId); - RETURN_MEMBER(getThis(), "prefix"); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, head) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, gc) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval *maxlifetime_param = NULL; + zend_long maxlifetime; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(maxlifetime) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } + zephir_fetch_params_without_memory_grow(1, 0, &maxlifetime_param); + maxlifetime = zephir_get_intval(maxlifetime_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HEAD"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, isLazy) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, read) { + zval *sessionId, sessionId_sub; zval *this_ptr = getThis(); + ZVAL_UNDEF(&sessionId_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(sessionId) + ZEND_PARSE_PARAMETERS_END(); +#endif + + zephir_fetch_params_without_memory_grow(1, 0, &sessionId); - RETURN_MEMBER(getThis(), "lazy"); + + RETURN_STRING(""); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, map) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, open) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval *savePath, savePath_sub, *sessionName, sessionName_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&savePath_sub); + ZVAL_UNDEF(&sessionName_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(savePath) + Z_PARAM_ZVAL(sessionName) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } + zephir_fetch_params_without_memory_grow(2, 0, &savePath, &sessionName); - ZVAL_NULL(&_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, mapVia) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, write) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *method, method_sub, *name_param = NULL; - zval routePattern, name; + zval *sessionId, sessionId_sub, *data, data_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&data_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_ZVAL(method) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(sessionId) + Z_PARAM_ZVAL(data) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &routePattern_param, &handler, &method, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } + zephir_fetch_params_without_memory_grow(2, 0, &sessionId, &data); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, method, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, options) +static PHP_METHOD(Phalcon_Session_Adapter_Noop, getPrefixedName) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval *name = NULL, name_sub, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&name_sub); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); + zephir_fetch_params(1, 1, 0, &name); + ZEPHIR_SEPARATE_PARAM(name); + + + zephir_cast_to_string(&_0, name); + ZEPHIR_CPY_WRT(name, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CONCAT_VV(return_value, &_1, name); + RETURN_MM(); +} + +zend_object *zephir_init_properties_Phalcon_Session_Adapter_Noop(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } +} - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OPTIONS"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Redis) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Redis, phalcon, session_adapter_redis, phalcon_session_adapter_abstractadapter_ce, phalcon_session_adapter_redis_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, patch) +static PHP_METHOD(Phalcon_Session_Adapter_Redis, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval options; + zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&factory_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_adapterfactory_ce) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 1, 1, &factory, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PATCH"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "prefix"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sess-reds-"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); zephir_check_call_status(); - RETURN_THIS(); + zephir_array_update_string(&options, SL("prefix"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "redis"); + ZEPHIR_CALL_METHOD(&_3, factory, "newinstance", NULL, 0, &_1, &options); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_3); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, post) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Stream) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Stream, phalcon, session_adapter_stream, phalcon_session_adapter_noop_ce, phalcon_session_adapter_stream_method_entry, 0); + + zend_declare_property_string(phalcon_session_adapter_stream_ce, SL("path"), "", ZEND_ACC_PRIVATE); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Session_Adapter_Stream, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zephir_fcall_cache_entry *_0 = NULL; + zval *options_param = NULL, path, _1, _2, _3, _6, _4$$4, _5$$4; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "POST"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_CALL_PARENT(NULL, phalcon_session_adapter_stream_ce, getThis(), "__construct", &_0, 0, &options); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "session.save_path"); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "phpiniget", NULL, 0, &_2); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "savePath"); + ZEPHIR_CALL_METHOD(&path, this_ptr, "getarrval", NULL, 0, &options, &_2, &_1); + zephir_check_call_status(); + if (UNEXPECTED(1 == ZEPHIR_IS_EMPTY(&path))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_session_exception_ce, "The session save path cannot be empty", "phalcon/Session/Adapter/Stream.zep", 67); + return; + } + ZEPHIR_CALL_METHOD(&_3, this_ptr, "phpiswritable", NULL, 0, &path); + zephir_check_call_status(); + if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_3))) { + ZEPHIR_INIT_VAR(&_4$$4); + object_init_ex(&_4$$4, phalcon_session_exception_ce); + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_SVS(&_5$$4, "The session save path [", &path, "] is not writable"); + ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", NULL, 32, &_5$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_4$$4, "phalcon/Session/Adapter/Stream.zep", 71); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_6, this_ptr, "getdirseparator", NULL, 511, &path); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("path"), &_6); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, put) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, destroy) { + zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval *sessionId, sessionId_sub, file, _0, _1, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&file); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(sessionId) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } + zephir_fetch_params(1, 1, 0, &sessionId); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PUT"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_read_property(&_0, this_ptr, ZEND_STRL("path"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getprefixedname", NULL, 0, sessionId); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&file); + ZEPHIR_CONCAT_VV(&file, &_0, &_1); + _2 = (zephir_file_exists(&file) == SUCCESS); + if (_2) { + ZEPHIR_CALL_FUNCTION(&_3, "is_file", NULL, 0, &file); + zephir_check_call_status(); + _2 = zephir_is_true(&_3); + } + if (_2) { + ZEPHIR_CALL_FUNCTION(NULL, "unlink", NULL, 122, &file); + zephir_check_call_status(); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setHandler) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, gc) { - zend_bool lazy; - zval *handler, handler_sub, *lazy_param = NULL, __$true, __$false; + zend_bool _6$$3, _9$$3, _12$$5, _14$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_8 = NULL, *_11 = NULL; + zval *maxlifetime_param = NULL, file, pattern, time, _0, _1, _2, _3, *_4, _5, _7$$3, _10$$3, _13$$5, _15$$5; + zend_long maxlifetime, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&time); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_15$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(lazy) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(maxlifetime) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 1, &handler, &lazy_param); - if (!lazy_param) { - lazy = 0; - } else { - lazy = zephir_get_boolval(lazy_param); - } + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &maxlifetime_param); + maxlifetime = zephir_get_intval(maxlifetime_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("handler"), handler); - if (lazy) { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$true); + zephir_read_property(&_0, this_ptr, ZEND_STRL("path"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_CONCAT_VVS(&pattern, &_0, &_1, "*"); + ZEPHIR_INIT_VAR(&_2); + zephir_time(&_2); + ZEPHIR_INIT_VAR(&time); + ZVAL_LONG(&time, (zephir_get_numberval(&_2) - maxlifetime)); + ZEPHIR_CALL_FUNCTION(&_3, "glob", NULL, 0, &pattern); + zephir_check_call_status(); + zephir_is_iterable(&_3, 0, "phalcon/Session/Adapter/Stream.zep", 111); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) + { + ZEPHIR_INIT_NVAR(&file); + ZVAL_COPY(&file, _4); + _6$$3 = 1 == (zephir_file_exists(&file) == SUCCESS); + if (_6$$3) { + ZEPHIR_CALL_FUNCTION(&_7$$3, "is_file", &_8, 0, &file); + zephir_check_call_status(); + _6$$3 = ZEPHIR_IS_TRUE_IDENTICAL(&_7$$3); + } + _9$$3 = _6$$3; + if (_9$$3) { + ZEPHIR_INIT_NVAR(&_10$$3); + zephir_filemtime(&_10$$3, &file); + _9$$3 = ZEPHIR_LT(&_10$$3, &time); + } + if (_9$$3) { + ZEPHIR_CALL_FUNCTION(NULL, "unlink", &_11, 122, &file); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$false); + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&file, &_3, "current", NULL, 0); + zephir_check_call_status(); + _12$$5 = 1 == (zephir_file_exists(&file) == SUCCESS); + if (_12$$5) { + ZEPHIR_CALL_FUNCTION(&_13$$5, "is_file", &_8, 0, &file); + zephir_check_call_status(); + _12$$5 = ZEPHIR_IS_TRUE_IDENTICAL(&_13$$5); + } + _14$$5 = _12$$5; + if (_14$$5) { + ZEPHIR_INIT_NVAR(&_15$$5); + zephir_filemtime(&_15$$5, &file); + _14$$5 = ZEPHIR_LT(&_15$$5, &time); + } + if (_14$$5) { + ZEPHIR_CALL_FUNCTION(NULL, "unlink", &_11, 122, &file); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_THISW(); + ZEPHIR_INIT_NVAR(&file); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setLazy) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, open) { - zval *lazy_param = NULL, __$true, __$false; - zend_bool lazy; + zval *savePath, savePath_sub, *sessionName, sessionName_sub; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&savePath_sub); + ZVAL_UNDEF(&sessionName_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(lazy) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(savePath) + Z_PARAM_ZVAL(sessionName) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &lazy_param); - if (UNEXPECTED(Z_TYPE_P(lazy_param) != IS_TRUE && Z_TYPE_P(lazy_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'lazy' must be of the type bool")); - RETURN_NULL(); - } - lazy = (Z_TYPE_P(lazy_param) == IS_TRUE); + zephir_fetch_params_without_memory_grow(2, 0, &savePath, &sessionName); - if (lazy) { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$false); - } - RETURN_THISW(); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setPrefix) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, read) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *prefix_param = NULL; - zval prefix; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sessionId, sessionId_sub, data, name, pointer, _0, _1, _2, _3$$3, _4$$3, _5$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&pointer); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(prefix) + Z_PARAM_ZVAL(sessionId) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } + zephir_fetch_params(1, 1, 0, &sessionId); - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); - RETURN_THIS(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("path"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getprefixedname", NULL, 0, sessionId); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&name); + ZEPHIR_CONCAT_VV(&name, &_0, &_1); + ZEPHIR_INIT_VAR(&data); + ZVAL_STRING(&data, ""); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "phpfileexists", NULL, 0, &name); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_2)) { + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "r"); + ZEPHIR_CALL_METHOD(&pointer, this_ptr, "phpfopen", NULL, 0, &name, &_3$$3); + zephir_check_call_status(); + ZVAL_LONG(&_4$$3, 1); + ZEPHIR_CALL_FUNCTION(&_5$$3, "flock", NULL, 131, &pointer, &_4$$3); + zephir_check_call_status(); + if (zephir_is_true(&_5$$3)) { + ZEPHIR_CALL_METHOD(&data, this_ptr, "phpfilegetcontents", NULL, 0, &name); + zephir_check_call_status(); + } + zephir_fclose(&pointer); + if (ZEPHIR_IS_FALSE_IDENTICAL(&data)) { + RETURN_MM_STRING(""); + } + } + RETURN_CCTOR(&data); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, addMap) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, write) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval routePattern, name; - zval *method, method_sub, *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sessionId, sessionId_sub, *data, data_sub, name, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&method_sub); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&sessionId_sub); + ZVAL_UNDEF(&data_sub); ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ZVAL(method) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(sessionId) + Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &sessionId, &data); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("path"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getprefixedname", NULL, 0, sessionId); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&name); + ZEPHIR_CONCAT_VV(&name, &_0, &_1); + ZVAL_LONG(&_3, 2); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "phpfileputcontents", NULL, 0, &name, data, &_3); + zephir_check_call_status(); + RETURN_MM_BOOL(!ZEPHIR_IS_FALSE_IDENTICAL(&_2)); +} + +static PHP_METHOD(Phalcon_Session_Adapter_Stream, getArrVal) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval cast; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null, value; + zval collection; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&cast); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_STR_OR_NULL(cast) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &method, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 2, &collection_param, &index, &defaultValue, &cast_param); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (!cast_param) { + ZEPHIR_INIT_VAR(&cast); } else { - ZEPHIR_INIT_VAR(&routePattern); + if (UNEXPECTED(Z_TYPE_P(cast_param) != IS_STRING && Z_TYPE_P(cast_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cast' must be of the type string")); + RETURN_MM_NULL(); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + if (EXPECTED(Z_TYPE_P(cast_param) == IS_STRING)) { + zephir_get_strval(&cast, cast_param); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&cast); + } } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, method); - zephir_array_fast_append(&_0, &routePattern); - zephir_array_fast_append(&_0, handler); - zephir_array_fast_append(&_0, &name); - zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); - ZEPHIR_MM_RESTORE(); + ZEPHIR_OBS_VAR(&value); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + if (UNEXPECTED(zephir_is_true(&cast))) { + ZEPHIR_MAKE_REF(&value); + ZEPHIR_CALL_FUNCTION(NULL, "settype", NULL, 11, &value, &cast); + ZEPHIR_UNREF(&value); + zephir_check_call_status(); + } + RETURN_CCTOR(&value); } -zend_object *zephir_init_properties_Phalcon_Mvc_Micro_Collection(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, getDirSeparator) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zval *directory_param = NULL, _0, _1; + zval directory; + zval *this_ptr = getThis(); - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} + ZVAL_UNDEF(&directory); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(directory) + ZEND_PARSE_PARAMETERS_END(); +#endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &directory_param); + if (UNEXPECTED(Z_TYPE_P(directory_param) != IS_STRING && Z_TYPE_P(directory_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'directory' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(directory_param) == IS_STRING)) { + zephir_get_strval(&directory, directory_param); + } else { + ZEPHIR_INIT_VAR(&directory); + } -#ifdef HAVE_CONFIG_H -#endif + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/"); + zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); + ZEPHIR_CONCAT_VS(return_value, &_0, "/"); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Session_Adapter_Stream, phpFileExists) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *filename_param = NULL; + zval filename; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&filename); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filename) + ZEND_PARSE_PARAMETERS_END(); +#endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &filename_param); + zephir_get_strval(&filename, filename_param); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_CollectionInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, CollectionInterface, phalcon, mvc_micro_collectioninterface, phalcon_mvc_micro_collectioninterface_method_entry); - return SUCCESS; + RETURN_MM_BOOL((zephir_file_exists(&filename) == SUCCESS)); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandler); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandlers); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getPrefix); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, head); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, isLazy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, map); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, options); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, patch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, post); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, put); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setHandler); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setLazy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setPrefix); - - +static PHP_METHOD(Phalcon_Session_Adapter_Stream, phpFileGetContents) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *filename_param = NULL; + zval filename; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&filename); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filename) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &filename_param); + zephir_get_strval(&filename, filename_param); + zephir_file_get_contents(return_value, &filename); + RETURN_MM(); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Exception) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, phpFilePutContents) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Micro, Exception, phalcon, mvc_micro_exception, zend_ce_exception, NULL, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long flags, ZEPHIR_LAST_CALL_STATUS; + zval *filename_param = NULL, *data, data_sub, *flags_param = NULL, *context = NULL, context_sub, __$null, _0; + zval filename; + zval *this_ptr = getThis(); - return SUCCESS; -} + ZVAL_UNDEF(&filename); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&context_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(filename) + Z_PARAM_ZVAL(data) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(flags) + Z_PARAM_ZVAL_OR_NULL(context) + ZEND_PARSE_PARAMETERS_END(); +#endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 2, &filename_param, &data, &flags_param, &context); + zephir_get_strval(&filename, filename_param); + if (!flags_param) { + flags = 0; + } else { + flags = zephir_get_intval(flags_param); + } + if (!context) { + context = &context_sub; + context = &__$null; + } -#ifdef HAVE_CONFIG_H -#endif + ZVAL_LONG(&_0, flags); + ZEPHIR_RETURN_CALL_FUNCTION("file_put_contents", NULL, 138, &filename, data, &_0, context); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Session_Adapter_Stream, phpFopen) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *filename_param = NULL, *mode_param = NULL; + zval filename, mode; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&filename); + ZVAL_UNDEF(&mode); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(filename) + Z_PARAM_STR(mode) + ZEND_PARSE_PARAMETERS_END(); +#endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &filename_param, &mode_param); + zephir_get_strval(&filename, filename_param); + zephir_get_strval(&mode, mode_param); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_LazyLoader) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, LazyLoader, phalcon, mvc_micro_lazyloader, phalcon_mvc_micro_lazyloader_method_entry, 0); - zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("definition"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("handler"), ZEND_ACC_PROTECTED); - return SUCCESS; + ZEPHIR_RETURN_CALL_FUNCTION("fopen", NULL, 139, &filename, &mode); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __construct) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, phpIniGet) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *definition_param = NULL; - zval definition; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *varname_param = NULL; + zval varname; zval *this_ptr = getThis(); - ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&varname); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(definition) + Z_PARAM_STR(varname) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &definition_param); - if (UNEXPECTED(Z_TYPE_P(definition_param) != IS_STRING && Z_TYPE_P(definition_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'definition' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(definition_param) == IS_STRING)) { - zephir_get_strval(&definition, definition_param); - } else { - ZEPHIR_INIT_VAR(&definition); - } + zephir_fetch_params(1, 1, 0, &varname_param); + zephir_get_strval(&varname, varname_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), &definition); - ZEPHIR_MM_RESTORE(); + ZEPHIR_RETURN_CALL_FUNCTION("ini_get", NULL, 0, &varname); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, callMethod) +static PHP_METHOD(Phalcon_Session_Adapter_Stream, phpIsWritable) { - zval _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *method_param = NULL, *arguments = NULL, arguments_sub, *modelBinder = NULL, modelBinder_sub, __$null, handler, definition, bindCacheKey, _0, _1$$4, _2$$4, _3$$5; - zval method; + zval *filename_param = NULL; + zval filename; zval *this_ptr = getThis(); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&arguments_sub); - ZVAL_UNDEF(&modelBinder_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&bindCacheKey); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&filename); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(method) - Z_PARAM_ZVAL(arguments) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(modelBinder, phalcon_mvc_model_binderinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filename) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &method_param, &arguments, &modelBinder); - if (UNEXPECTED(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { - zephir_get_strval(&method, method_param); - } else { - ZEPHIR_INIT_VAR(&method); - } - ZEPHIR_SEPARATE_PARAM(arguments); - if (!modelBinder) { - modelBinder = &modelBinder_sub; - modelBinder = &__$null; - } + zephir_fetch_params(1, 1, 0, &filename_param); + zephir_get_strval(&filename, filename_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("handler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handler, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&definition, &_0); - if (Z_TYPE_P(&handler) != IS_OBJECT) { - if (!(zephir_class_exists(&definition, 1))) { - ZEPHIR_INIT_VAR(&_1$$4); - object_init_ex(&_1$$4, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_CONCAT_SVS(&_2$$4, "Handler '", &definition, "' doesn't exist"); - ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 32, &_2$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Micro/LazyLoader.zep", 55); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&handler); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&handler, &definition); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("handler"), &handler); - } - if (Z_TYPE_P(modelBinder) != IS_NULL) { - ZEPHIR_INIT_VAR(&bindCacheKey); - ZEPHIR_CONCAT_SVSV(&bindCacheKey, "_PHMB_", &definition, "_", &method); - ZEPHIR_CALL_METHOD(&_3$$5, modelBinder, "bindtohandler", NULL, 0, &handler, arguments, &bindCacheKey, &method); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(arguments, &_3$$5); - } - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 2, 0); - zephir_array_fast_append(&_4, &handler); - zephir_array_fast_append(&_4, &method); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_4, arguments); + ZEPHIR_RETURN_CALL_FUNCTION("is_writable", NULL, 0, &filename); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getDefinition) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "definition"); +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Db_AbstractDb) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, AbstractDb, phalcon, db_abstractdb, phalcon_db_abstractdb_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getHandler) +static PHP_METHOD(Phalcon_Db_AbstractDb, setup) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, escapeIdentifiers, forceCasting; + zval options; zval *this_ptr = getThis(); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&escapeIdentifiers); + ZVAL_UNDEF(&forceCasting); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &options_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - RETURN_MEMBER(getThis(), "handler"); + + ZEPHIR_OBS_VAR(&escapeIdentifiers); + if (zephir_array_isset_string_fetch(&escapeIdentifiers, &options, SL("escapeSqlIdentifiers"), 0)) { + ZEPHIR_GLOBAL(db).escape_identifiers = zend_is_true(&escapeIdentifiers); + } + ZEPHIR_OBS_VAR(&forceCasting); + if (zephir_array_isset_string_fetch(&forceCasting, &options, SL("forceCasting"), 0)) { + ZEPHIR_GLOBAL(db).force_casting = zend_is_true(&forceCasting); + } + ZEPHIR_MM_RESTORE(); } @@ -60163,336 +53876,411 @@ static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getHandler) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_MiddlewareInterface) +ZEPHIR_INIT_CLASS(Phalcon_Db_Column) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, MiddlewareInterface, phalcon, mvc_micro_middlewareinterface, phalcon_mvc_micro_middlewareinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Column, phalcon, db_column, phalcon_db_column_method_entry, 0); - return SUCCESS; -} + zend_declare_property_null(phalcon_db_column_ce, SL("after"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_column_ce, SL("autoIncrement"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_column_ce, SL("bindType"), 2, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_column_ce, SL("comment"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_column_ce, SL("defaultValue"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_column_ce, SL("first"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_column_ce, SL("isNumeric"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_column_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_column_ce, SL("notNull"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_column_ce, SL("primary"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_column_ce, SL("scale"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_column_ce, SL("size"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_column_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_column_ce, SL("typeReference"), -1, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_column_ce, SL("typeValues"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_column_ce, SL("unsigned"), 0, ZEND_ACC_PROTECTED); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_BLOB"), 3); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_MiddlewareInterface, call); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_BOOL"), 5); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_DECIMAL"), 32); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_INT"), 1); -#ifdef HAVE_CONFIG_H -#endif + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_NULL"), 0); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_STR"), 2); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_SKIP"), 1024); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BIGINTEGER"), 14); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BIT"), 19); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Url, Exception, phalcon, mvc_url_exception, zend_ce_exception, NULL, 0); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BINARY"), 26); - return SUCCESS; -} + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BLOB"), 11); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BOOLEAN"), 8); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_CHAR"), 5); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DATE"), 1); -#ifdef HAVE_CONFIG_H -#endif + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DATETIME"), 4); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DECIMAL"), 3); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DOUBLE"), 9); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_ENUM"), 18); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_FLOAT"), 7); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_UrlInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Url, UrlInterface, phalcon, mvc_url_urlinterface, phalcon_mvc_url_urlinterface_method_entry); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_INTEGER"), 0); - return SUCCESS; -} + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_JSON"), 15); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, getBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, getBaseUri); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, setBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, setBaseUri); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, path); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_JSONB"), 16); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_LONGBLOB"), 13); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_LONGTEXT"), 24); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMBLOB"), 12); -#ifdef HAVE_CONFIG_H -#endif + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMINTEGER"), 21); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMTEXT"), 23); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_SMALLINTEGER"), 22); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TEXT"), 6); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TIME"), 20); -static void phalcon_get_uri(zval *return_value, zval *path) -{ - int i, found = 0, mark = 0; - char *cursor, *str, ch; + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TIMESTAMP"), 17); - if (Z_TYPE_P(path) != IS_STRING) { - RETURN_EMPTY_STRING(); - } + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYBLOB"), 10); - if (Z_STRLEN_P(path) > 0) { - cursor = Z_STRVAL_P(path) + Z_STRLEN_P(path) - 1; - for (i = Z_STRLEN_P(path); i > 0; i--) { - ch = *cursor; - if (ch == '/' || ch == '\\') { - found++; - if (found == 1) { - mark = i - 1; - } else { - str = emalloc(mark - i + 1); - memcpy(str, Z_STRVAL_P(path) + i, mark - i); - str[mark - i] = '\0'; - ZVAL_STRINGL(return_value, str, mark - i); - return; - } - } - cursor--; - } - } + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYINTEGER"), 26); - RETURN_EMPTY_STRING(); + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYTEXT"), 25); + + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_VARBINARY"), 27); + + zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_VARCHAR"), 2); + + zend_class_implements(phalcon_db_column_ce, 1, phalcon_db_columninterface_ce); + return SUCCESS; } -zval *phalcon_replace_marker(int named, zval *paths, zval *replacements, unsigned long *position, char *cursor, char *marker) +static PHP_METHOD(Phalcon_Db_Column, __construct) { - unsigned int length = 0, variable_length, ch, j; - char *item = NULL, *cursor_var, *variable = NULL; - int not_valid = 0; - zval *zv, *tmp; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval definition; + zval *name_param = NULL, *definition_param = NULL, __$true, __$false, type, notNull, primary, size, scale, dunsigned, first, after, bindType, isNumeric, autoIncrement, defaultValue, typeReference, typeValues, comment; + zval name; + zval *this_ptr = getThis(); - if (named) { - length = cursor - marker - 1; - item = estrndup(marker + 1, length); - cursor_var = item; - marker = item; - for (j = 0; j < length; j++) { - ch = *cursor_var; - if (ch == '\0') { - not_valid = 1; + ZVAL_UNDEF(&name); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(¬Null); + ZVAL_UNDEF(&primary); + ZVAL_UNDEF(&size); + ZVAL_UNDEF(&scale); + ZVAL_UNDEF(&dunsigned); + ZVAL_UNDEF(&first); + ZVAL_UNDEF(&after); + ZVAL_UNDEF(&bindType); + ZVAL_UNDEF(&isNumeric); + ZVAL_UNDEF(&autoIncrement); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&typeReference); + ZVAL_UNDEF(&typeValues); + ZVAL_UNDEF(&comment); + ZVAL_UNDEF(&definition); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ARRAY(definition) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + + + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + ZEPHIR_OBS_VAR(&type); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &definition, SL("type"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type is required", "phalcon/Db/Column.zep", 348); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + ZEPHIR_OBS_VAR(&typeReference); + if (zephir_array_isset_string_fetch(&typeReference, &definition, SL("typeReference"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("typeReference"), &typeReference); + } + ZEPHIR_OBS_VAR(&typeValues); + if (zephir_array_isset_string_fetch(&typeValues, &definition, SL("typeValues"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("typeValues"), &typeValues); + } + ZEPHIR_OBS_VAR(¬Null); + if (zephir_array_isset_string_fetch(¬Null, &definition, SL("notNull"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("notNull"), ¬Null); + } + ZEPHIR_OBS_VAR(&primary); + if (zephir_array_isset_string_fetch(&primary, &definition, SL("primary"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("primary"), &primary); + } + ZEPHIR_OBS_VAR(&size); + if (zephir_array_isset_string_fetch(&size, &definition, SL("size"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("size"), &size); + } + ZEPHIR_OBS_VAR(&scale); + if (zephir_array_isset_string_fetch(&scale, &definition, SL("scale"), 0)) { + do { + if (ZEPHIR_IS_LONG(&type, 14) || ZEPHIR_IS_LONG(&type, 3) || ZEPHIR_IS_LONG(&type, 9) || ZEPHIR_IS_LONG(&type, 7) || ZEPHIR_IS_LONG(&type, 0) || ZEPHIR_IS_LONG(&type, 21) || ZEPHIR_IS_LONG(&type, 22) || ZEPHIR_IS_LONG(&type, 26)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("scale"), &scale); break; } - if (j == 0 && !((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z'))){ - not_valid = 1; - break; + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type does not support scale parameter", "phalcon/Db/Column.zep", 398); + return; + } while(0); + + } + ZEPHIR_OBS_VAR(&defaultValue); + if (zephir_array_isset_string_fetch(&defaultValue, &definition, SL("default"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultValue"), &defaultValue); + } + ZEPHIR_OBS_VAR(&dunsigned); + if (zephir_array_isset_string_fetch(&dunsigned, &definition, SL("unsigned"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("unsigned"), &dunsigned); + } + ZEPHIR_OBS_VAR(&isNumeric); + if (zephir_array_isset_string_fetch(&isNumeric, &definition, SL("isNumeric"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isNumeric"), &isNumeric); + } + ZEPHIR_OBS_VAR(&autoIncrement); + if (zephir_array_isset_string_fetch(&autoIncrement, &definition, SL("autoIncrement"), 0)) { + if (!(zephir_is_true(&autoIncrement))) { + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$false); } - if ((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_' || ch == ':') { - if (ch == ':') { - variable_length = cursor_var - marker; - variable = estrndup(marker, variable_length); + } else { + do { + if (ZEPHIR_IS_LONG(&type, 14) || ZEPHIR_IS_LONG(&type, 0) || ZEPHIR_IS_LONG(&type, 21) || ZEPHIR_IS_LONG(&type, 22) || ZEPHIR_IS_LONG(&type, 26)) { + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$false); + } break; } - } else { - not_valid = 1; - break; - } - cursor_var++; + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type cannot be auto-increment", "phalcon/Db/Column.zep", 442); + return; + } while(0); + } } + if (zephir_array_isset_string_fetch(&first, &definition, SL("first"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("first"), &first); + } + if (zephir_array_isset_string_fetch(&after, &definition, SL("after"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("after"), &after); + } + if (zephir_array_isset_string_fetch(&bindType, &definition, SL("bindType"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindType"), &bindType); + } + if (zephir_array_isset_string_fetch(&comment, &definition, SL("comment"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("comment"), &comment); + } + ZEPHIR_MM_RESTORE(); +} - if (!not_valid) { +static PHP_METHOD(Phalcon_Db_Column, getAfterPosition) +{ + zval *this_ptr = getThis(); - if (zend_hash_index_exists(Z_ARRVAL_P(paths), *position)) { - if (named) { - if (variable) { - efree(item); - item = variable; - length = variable_length; - } - if (zend_hash_str_exists(Z_ARRVAL_P(replacements), item, length)) { - if ((zv = zend_hash_str_find(Z_ARRVAL_P(replacements), item, length)) != NULL) { - efree(item); - (*position)++; - return zv; - } - } - } else { - if ((zv = zend_hash_index_find(Z_ARRVAL_P(paths), *position)) != NULL) { - if (Z_TYPE_P(zv) == IS_STRING) { - if (zend_hash_str_exists(Z_ARRVAL_P(replacements), Z_STRVAL_P(zv), Z_STRLEN_P(zv))) { - if ((tmp = zend_hash_str_find(Z_ARRVAL_P(replacements), Z_STRVAL_P(zv), Z_STRLEN_P(zv))) != NULL) { - (*position)++; - return tmp; - } - } - } - } - } - } - (*position)++; - } - if (item) { - efree(item); - } + RETURN_MEMBER(getThis(), "after"); +} - return NULL; +static PHP_METHOD(Phalcon_Db_Column, getBindType) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "bindType"); } -static void phalcon_replace_paths(zval *return_value, zval *pattern, zval *paths, zval *replacements) +static PHP_METHOD(Phalcon_Db_Column, getComment) { + zval *this_ptr = getThis(); - char *cursor, *marker = NULL; - unsigned int bracket_count = 0, parentheses_count = 0, intermediate = 0; - unsigned char ch; - smart_str route_str = {0}; - zend_ulong position = 1; - int i; - zval *replace, replace_copy; - int use_copy, looking_placeholder = 0; - if (Z_TYPE_P(pattern) != IS_STRING || Z_TYPE_P(replacements) != IS_ARRAY || Z_TYPE_P(paths) != IS_ARRAY) { - ZVAL_NULL(return_value); - php_error_docref(NULL, E_WARNING, "Invalid arguments supplied for phalcon_replace_paths()"); - return; - } - if (Z_STRLEN_P(pattern) <= 0) { - ZVAL_FALSE(return_value); - return; - } + RETURN_MEMBER(getThis(), "comment"); +} - cursor = Z_STRVAL_P(pattern); - if (*cursor == '/') { - ++cursor; - i = 1; - } - else { - i = 0; - } +static PHP_METHOD(Phalcon_Db_Column, getDefault) +{ + zval *this_ptr = getThis(); - if (!zend_hash_num_elements(Z_ARRVAL_P(paths))) { - ZVAL_STRINGL(return_value, Z_STRVAL_P(pattern) + i, Z_STRLEN_P(pattern) - i); - return; - } - for (; i < Z_STRLEN_P(pattern); ++i) { - ch = *cursor; - if (ch == '\0') { - break; - } + RETURN_MEMBER(getThis(), "defaultValue"); +} - if (parentheses_count == 0 && !looking_placeholder) { - if (ch == '{') { - if (bracket_count == 0) { - marker = cursor; - intermediate = 0; - } - bracket_count++; - } else { - if (ch == '}') { - bracket_count--; - if (intermediate > 0) { - if (bracket_count == 0) { - replace = phalcon_replace_marker(1, paths, replacements, &position, cursor, marker); - if (replace) { - use_copy = 0; - if (Z_TYPE_P(replace) != IS_STRING) { - use_copy = zend_make_printable_zval(replace, &replace_copy); - if (use_copy) { - replace = &replace_copy; - } - } - smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); - if (use_copy) { - zval_dtor(&replace_copy); - } - } - cursor++; - continue; - } - } - } - } - } +static PHP_METHOD(Phalcon_Db_Column, getName) +{ + zval *this_ptr = getThis(); - if (bracket_count == 0 && !looking_placeholder) { - if (ch == '(') { - if (parentheses_count == 0) { - marker = cursor; - intermediate = 0; - } - parentheses_count++; - } else { - if (ch == ')') { - parentheses_count--; - if (intermediate > 0) { - if (parentheses_count == 0) { - replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); - if (replace) { - use_copy = 0; - if (Z_TYPE_P(replace) != IS_STRING) { - use_copy = zend_make_printable_zval(replace, &replace_copy); - if (use_copy) { - replace = &replace_copy; - } - } - smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); - if (use_copy) { - zval_dtor(&replace_copy); - } - } - cursor++; - continue; - } - } - } - } - } - if (bracket_count == 0 && parentheses_count == 0) { - if (looking_placeholder) { - if (intermediate > 0) { - if (ch < 'a' || ch > 'z' || i == (Z_STRLEN_P(pattern) - 1)) { - replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); - if (replace) { - use_copy = 0; - if (Z_TYPE_P(replace) != IS_STRING) { - use_copy = zend_make_printable_zval(replace, &replace_copy); - if (use_copy) { - replace = &replace_copy; - } - } - smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); - if (use_copy) { - zval_dtor(&replace_copy); - } - } - looking_placeholder = 0; - continue; - } - } - } else { - if (ch == ':') { - looking_placeholder = 1; - marker = cursor; - intermediate = 0; - } - } - } - if (bracket_count > 0 || parentheses_count > 0 || looking_placeholder) { - intermediate++; - } else { - smart_str_appendc(&route_str, ch); - } + RETURN_MEMBER(getThis(), "name"); +} - cursor++; - } - smart_str_0(&route_str); +static PHP_METHOD(Phalcon_Db_Column, getScale) +{ + zval *this_ptr = getThis(); - if (route_str.s) { - RETURN_STR(route_str.s); - } else { - smart_str_free(&route_str); - RETURN_EMPTY_STRING(); + + + RETURN_MEMBER(getThis(), "scale"); +} + +static PHP_METHOD(Phalcon_Db_Column, getSize) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "size"); +} + +static PHP_METHOD(Phalcon_Db_Column, getType) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Db_Column, getTypeReference) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "typeReference"); +} + +static PHP_METHOD(Phalcon_Db_Column, getTypeValues) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "typeValues"); +} + +static PHP_METHOD(Phalcon_Db_Column, hasDefault) +{ + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(0); } + zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultValue"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(Z_TYPE_P(&_1) != IS_NULL); +} + +static PHP_METHOD(Phalcon_Db_Column, isAutoIncrement) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "autoIncrement"); +} + +static PHP_METHOD(Phalcon_Db_Column, isFirst) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "first"); +} + +static PHP_METHOD(Phalcon_Db_Column, isNotNull) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "notNull"); +} + +static PHP_METHOD(Phalcon_Db_Column, isNumeric) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "isNumeric"); +} + +static PHP_METHOD(Phalcon_Db_Column, isPrimary) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "primary"); +} + +static PHP_METHOD(Phalcon_Db_Column, isUnsigned) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "unsigned"); } + #ifdef HAVE_CONFIG_H #endif @@ -60500,13 +54288,29 @@ static void phalcon_replace_paths(zval *return_value, zval *pattern, zval *paths -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Db_ColumnInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Application, Exception, phalcon, mvc_application_exception, phalcon_application_exception_ce, NULL, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ColumnInterface, phalcon, db_columninterface, phalcon_db_columninterface_method_entry); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getAfterPosition); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getBindType); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getDefault); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getScale); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getSize); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getTypeReference); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getTypeValues); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, hasDefault); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isAutoIncrement); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isFirst); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isNotNull); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isNumeric); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isPrimary); +ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isUnsigned); @@ -60517,3352 +54321,3431 @@ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Annotations) +ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Annotations, phalcon, mvc_router_annotations, phalcon_mvc_router_ce, phalcon_mvc_router_annotations_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Dialect, phalcon, db_dialect, phalcon_db_dialect_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("actionPreformatCallback"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("controllerSuffix"), "Controller", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("handlers"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("routePrefix"), "", ZEND_ACC_PROTECTED); - phalcon_mvc_router_annotations_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Annotations; + zend_declare_property_null(phalcon_db_dialect_ce, SL("escapeChar"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_dialect_ce, SL("customFunctions"), ZEND_ACC_PROTECTED); + phalcon_db_dialect_ce->create_object = zephir_init_properties_Phalcon_Db_Dialect; + zend_class_implements(phalcon_db_dialect_ce, 1, phalcon_db_dialectinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addModuleResource) +static PHP_METHOD(Phalcon_Db_Dialect, createSavepoint) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *module_param = NULL, *handler_param = NULL, *prefix_param = NULL; - zval module, handler, prefix; + zval *name_param = NULL; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&name); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(module) - Z_PARAM_STR(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(prefix) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &module_param, &handler_param, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be of the type string")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(module_param) == IS_STRING)) { - zephir_get_strval(&module, module_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&module); + ZEPHIR_INIT_VAR(&name); } - if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); + + + ZEPHIR_CONCAT_SV(return_value, "SAVEPOINT ", &name); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Dialect, escape) +{ + zend_bool _2$$5, _12$$7, _13$$7, _17$$9, _18$$9; + zend_string *_11; + zend_ulong _10; + zval _7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *str_param = NULL, *escapeChar_param = NULL, parts, key, part, newParts, _5, _6, *_8, _9, _0$$4, _3$$6, _14$$7, _16$$7, _19$$9, _21$$9; + zval str, escapeChar, _1$$4, _4$$6, _15$$7, _20$$9; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&str); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_15$$7); + ZVAL_UNDEF(&_20$$9); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&part); + ZVAL_UNDEF(&newParts); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_19$$9); + ZVAL_UNDEF(&_21$$9); + ZVAL_UNDEF(&_7); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(str) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &str_param, &escapeChar_param); + if (UNEXPECTED(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { - zephir_get_strval(&handler, handler_param); - } else { - ZEPHIR_INIT_VAR(&handler); - } - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); + if (EXPECTED(Z_TYPE_P(str_param) == IS_STRING)) { + zephir_get_strval(&str, str_param); } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&str); } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&prefix); - } + zephir_get_strval(&escapeChar, escapeChar_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - zephir_array_fast_append(&_0, &prefix); - zephir_array_fast_append(&_0, &handler); - zephir_array_fast_append(&_0, &module); - zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); - RETURN_THIS(); + if (!(ZEPHIR_GLOBAL(db).escape_identifiers)) { + RETURN_CTOR(&str); + } + if (ZEPHIR_IS_EMPTY(&escapeChar)) { + ZEPHIR_OBS_VAR(&_0$$4); + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("escapeChar"), PH_NOISY_CC); + zephir_cast_to_string(&_1$$4, &_0$$4); + ZEPHIR_CPY_WRT(&escapeChar, &_1$$4); + } + if (!(zephir_memnstr_str(&str, SL("."), "phalcon/Db/Dialect.zep", 52))) { + _2$$5 = !ZEPHIR_IS_STRING(&escapeChar, ""); + if (_2$$5) { + _2$$5 = !ZEPHIR_IS_STRING(&str, "*"); + } + if (_2$$5) { + ZEPHIR_INIT_VAR(&_3$$6); + ZEPHIR_INIT_VAR(&_4$$6); + ZEPHIR_CONCAT_VV(&_4$$6, &escapeChar, &escapeChar); + zephir_fast_str_replace(&_3$$6, &escapeChar, &_4$$6, &str); + ZEPHIR_CONCAT_VVV(return_value, &escapeChar, &_3$$6, &escapeChar); + RETURN_MM(); + } + RETURN_CTOR(&str); + } + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_INIT_VAR(&_6); + zephir_fast_trim(&_6, &str, &escapeChar, ZEPHIR_TRIM_BOTH); + zephir_fast_explode_str(&_5, SL("."), &_6, LONG_MAX); + zephir_get_arrval(&_7, &_5); + ZEPHIR_CPY_WRT(&parts, &_7); + ZEPHIR_CPY_WRT(&newParts, &parts); + zephir_is_iterable(&parts, 0, "phalcon/Db/Dialect.zep", 72); + if (Z_TYPE_P(&parts) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&parts), _10, _11, _8) + { + ZEPHIR_INIT_NVAR(&key); + if (_11 != NULL) { + ZVAL_STR_COPY(&key, _11); + } else { + ZVAL_LONG(&key, _10); + } + ZEPHIR_INIT_NVAR(&part); + ZVAL_COPY(&part, _8); + _12$$7 = ZEPHIR_IS_STRING(&escapeChar, ""); + if (!(_12$$7)) { + _12$$7 = ZEPHIR_IS_STRING(&part, ""); + } + _13$$7 = _12$$7; + if (!(_13$$7)) { + _13$$7 = ZEPHIR_IS_STRING(&part, "*"); + } + if (_13$$7) { + continue; + } + ZEPHIR_INIT_NVAR(&_14$$7); + ZEPHIR_INIT_NVAR(&_15$$7); + ZEPHIR_CONCAT_VV(&_15$$7, &escapeChar, &escapeChar); + zephir_fast_str_replace(&_14$$7, &escapeChar, &_15$$7, &part); + ZEPHIR_INIT_NVAR(&_16$$7); + ZEPHIR_CONCAT_VVV(&_16$$7, &escapeChar, &_14$$7, &escapeChar); + zephir_array_update_zval(&newParts, &key, &_16$$7, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &parts, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9, &parts, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &parts, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&part, &parts, "current", NULL, 0); + zephir_check_call_status(); + _17$$9 = ZEPHIR_IS_STRING(&escapeChar, ""); + if (!(_17$$9)) { + _17$$9 = ZEPHIR_IS_STRING(&part, ""); + } + _18$$9 = _17$$9; + if (!(_18$$9)) { + _18$$9 = ZEPHIR_IS_STRING(&part, "*"); + } + if (_18$$9) { + continue; + } + ZEPHIR_INIT_NVAR(&_19$$9); + ZEPHIR_INIT_NVAR(&_20$$9); + ZEPHIR_CONCAT_VV(&_20$$9, &escapeChar, &escapeChar); + zephir_fast_str_replace(&_19$$9, &escapeChar, &_20$$9, &part); + ZEPHIR_INIT_NVAR(&_21$$9); + ZEPHIR_CONCAT_VVV(&_21$$9, &escapeChar, &_19$$9, &escapeChar); + zephir_array_update_zval(&newParts, &key, &_21$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &parts, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&part); + ZEPHIR_INIT_NVAR(&key); + zephir_fast_join_str(return_value, SL("."), &newParts); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addResource) +static PHP_METHOD(Phalcon_Db_Dialect, escapeSchema) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *handler_param = NULL, *prefix_param = NULL; - zval handler, prefix; + zval *str_param = NULL, *escapeChar_param = NULL, _0$$4, _2; + zval str, escapeChar, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&str); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(handler) + Z_PARAM_STR(str) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(prefix) + Z_PARAM_STR_OR_NULL(escapeChar) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &handler_param, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); + zephir_fetch_params(1, 1, 1, &str_param, &escapeChar_param); + if (UNEXPECTED(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { - zephir_get_strval(&handler, handler_param); - } else { - ZEPHIR_INIT_VAR(&handler); - } - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); + if (EXPECTED(Z_TYPE_P(str_param) == IS_STRING)) { + zephir_get_strval(&str, str_param); } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&str); } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&prefix); - } + zephir_get_strval(&escapeChar, escapeChar_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, &prefix); - zephir_array_fast_append(&_0, &handler); - zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); - RETURN_THIS(); + if (!(ZEPHIR_GLOBAL(db).escape_identifiers)) { + RETURN_CTOR(&str); + } + if (ZEPHIR_IS_STRING(&escapeChar, "")) { + ZEPHIR_OBS_VAR(&_0$$4); + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("escapeChar"), PH_NOISY_CC); + zephir_cast_to_string(&_1$$4, &_0$$4); + ZEPHIR_CPY_WRT(&escapeChar, &_1$$4); + } + ZEPHIR_INIT_VAR(&_2); + zephir_fast_trim(&_2, &str, &escapeChar, ZEPHIR_TRIM_BOTH); + ZEPHIR_CONCAT_VVV(return_value, &escapeChar, &_2, &escapeChar); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getResources) +static PHP_METHOD(Phalcon_Db_Dialect, forUpdate) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *sqlQuery_param = NULL; + zval sqlQuery; zval *this_ptr = getThis(); + ZVAL_UNDEF(&sqlQuery); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sqlQuery) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "handlers"); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); + } + + + ZEPHIR_CONCAT_VS(return_value, &sqlQuery, " FOR UPDATE"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) +static PHP_METHOD(Phalcon_Db_Dialect, getColumnList) { - zend_string *_20$$18, *_41$$41; - zend_ulong _19$$18, _40$$41; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_13 = NULL, *_16 = NULL, *_24 = NULL, *_35 = NULL, *_48 = NULL; + zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, __$null, annotationsService, handlers, controllerSuffix, scope, prefix, route, compiledPattern, container, handler, controllerName, lowerControllerName, namespaceName, moduleName, handlerAnnotations, classAnnotations, annotations, annotation, methodAnnotations, method, collection, _0, _1, *_2, _3, _5$$6, _7$$6, _8$$6, _9$$7, _10$$7, _11$$4, _12$$12, *_14$$15, _15$$15, *_17$$18, _18$$18, _21$$19, *_22$$19, _23$$19, _25$$23, *_26$$23, _27$$23, _28$$29, _29$$29, _30$$29, _31$$30, _32$$30, _33$$27, _34$$35, *_36$$38, _37$$38, *_38$$41, _39$$41, _42$$42, *_43$$42, _44$$42, _45$$46, *_46$$46, _47$$46; - zval uri, sufixed; + zval escapeChar; + zval *columnList_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, column, *_0, _1, _2$$3, _4$$4; + zval columnList, bindCounts, columns; zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&sufixed); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&annotationsService); - ZVAL_UNDEF(&handlers); - ZVAL_UNDEF(&controllerSuffix); - ZVAL_UNDEF(&scope); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&compiledPattern); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&lowerControllerName); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&handlerAnnotations); - ZVAL_UNDEF(&classAnnotations); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&annotation); - ZVAL_UNDEF(&methodAnnotations); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&columnList); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&column); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$4); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_15$$15); - ZVAL_UNDEF(&_18$$18); - ZVAL_UNDEF(&_21$$19); - ZVAL_UNDEF(&_23$$19); - ZVAL_UNDEF(&_25$$23); - ZVAL_UNDEF(&_27$$23); - ZVAL_UNDEF(&_28$$29); - ZVAL_UNDEF(&_29$$29); - ZVAL_UNDEF(&_30$$29); - ZVAL_UNDEF(&_31$$30); - ZVAL_UNDEF(&_32$$30); - ZVAL_UNDEF(&_33$$27); - ZVAL_UNDEF(&_34$$35); - ZVAL_UNDEF(&_37$$38); - ZVAL_UNDEF(&_39$$41); - ZVAL_UNDEF(&_42$$42); - ZVAL_UNDEF(&_44$$42); - ZVAL_UNDEF(&_45$$46); - ZVAL_UNDEF(&_47$$46); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(columnList) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &columnList_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&columnList, columnList_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); } else { - ZEPHIR_INIT_VAR(&uri); + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/Mvc/Router/Annotations.zep", 114); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handlers, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("controllerSuffix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&controllerSuffix, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "annotations"); - ZEPHIR_CALL_METHOD(&annotationsService, &container, "getshared", NULL, 0, &_1); - zephir_check_call_status(); - zephir_is_iterable(&handlers, 0, "phalcon/Mvc/Router/Annotations.zep", 250); - if (Z_TYPE_P(&handlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&handlers), _2) + ZEPHIR_INIT_VAR(&columns); + array_init(&columns); + zephir_is_iterable(&columnList, 0, "phalcon/Db/Dialect.zep", 128); + if (Z_TYPE_P(&columnList) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columnList), _0) { - ZEPHIR_INIT_NVAR(&scope); - ZVAL_COPY(&scope, _2); - if (Z_TYPE_P(&scope) != IS_ARRAY) { - continue; - } - ZEPHIR_OBS_NVAR(&prefix); - zephir_array_fetch_long(&prefix, &scope, 0, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 129); - if (!(ZEPHIR_IS_EMPTY(&prefix))) { - ZEPHIR_INIT_NVAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", &_4, 100, &prefix); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$6, &route, "getcompiledpattern", &_6, 487); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7$$6); - ZVAL_STRING(&_7$$6, "$#"); - ZEPHIR_INIT_NVAR(&_8$$6); - ZVAL_STRING(&_8$$6, "#"); - ZEPHIR_INIT_NVAR(&compiledPattern); - zephir_fast_str_replace(&compiledPattern, &_7$$6, &_8$$6, &_5$$6); - if (zephir_memnstr_str(&compiledPattern, SL("^"), "phalcon/Mvc/Router/Annotations.zep", 146)) { - ZEPHIR_INIT_NVAR(&_9$$7); - ZEPHIR_INIT_NVAR(&_10$$7); - zephir_preg_match(&_10$$7, &compiledPattern, &uri, &_9$$7, 0, 0 , 0 ); - if (!(zephir_is_true(&_10$$7))) { - continue; - } - } else if (!(zephir_start_with(&uri, &prefix, NULL))) { - continue; - } - } - ZEPHIR_OBS_NVAR(&handler); - zephir_array_fetch_long(&handler, &scope, 1, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 161); - if (zephir_memnstr_str(&handler, SL("\\"), "phalcon/Mvc/Router/Annotations.zep", 163)) { - ZEPHIR_INIT_NVAR(&controllerName); - zephir_get_class_ns(&controllerName, &handler, 0); - ZEPHIR_INIT_NVAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &handler, 0); - } else { - ZEPHIR_CPY_WRT(&controllerName, &handler); - ZEPHIR_OBS_NVAR(&namespaceName); - zephir_fetch_property(&namespaceName, this_ptr, SL("defaultNamespace"), PH_SILENT_CC); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &__$null); - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_isset_long_fetch(&moduleName, &scope, 2, 0); - ZEPHIR_INIT_NVAR(&_11$$4); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - ZEPHIR_CPY_WRT(&_11$$4, &moduleName); - } else { - ZEPHIR_INIT_NVAR(&_11$$4); - ZVAL_STRING(&_11$$4, ""); - } - ZEPHIR_CPY_WRT(&moduleName, &_11$$4); - ZEPHIR_INIT_NVAR(&_11$$4); - ZEPHIR_CONCAT_VV(&_11$$4, &controllerName, &controllerSuffix); - zephir_get_strval(&sufixed, &_11$$4); - if (Z_TYPE_P(&namespaceName) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_12$$12); - ZEPHIR_CONCAT_VSV(&_12$$12, &namespaceName, "\\", &sufixed); - zephir_get_strval(&sufixed, &_12$$12); - } - ZEPHIR_CALL_METHOD(&handlerAnnotations, &annotationsService, "get", &_13, 0, &sufixed); + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _0); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getsqlcolumn", &_3, 43, &column, &escapeChar, &bindCounts); zephir_check_call_status(); - if (Z_TYPE_P(&handlerAnnotations) != IS_OBJECT) { - continue; + zephir_array_append(&columns, &_2$$3, PH_SEPARATE, "phalcon/Db/Dialect.zep", 125); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columnList, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &columnList, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; } - ZEPHIR_CALL_METHOD(&classAnnotations, &handlerAnnotations, "getclassannotations", NULL, 0); + ZEPHIR_CALL_METHOD(&column, &columnList, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&classAnnotations) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&annotations, &classAnnotations, "getannotations", NULL, 0); + ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "getsqlcolumn", &_3, 43, &column, &escapeChar, &bindCounts); zephir_check_call_status(); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - zephir_is_iterable(&annotations, 0, "phalcon/Mvc/Router/Annotations.zep", 218); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _14$$15) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _14$$15); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$15, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$15)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } - } - ZEPHIR_CALL_METHOD(&methodAnnotations, &handlerAnnotations, "getmethodsannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&lowerControllerName); - zephir_uncamelize(&lowerControllerName, &controllerName, NULL ); - zephir_is_iterable(&methodAnnotations, 0, "phalcon/Mvc/Router/Annotations.zep", 244); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodAnnotations), _19$$18, _20$$18, _17$$18) - { - ZEPHIR_INIT_NVAR(&method); - if (_20$$18 != NULL) { - ZVAL_STR_COPY(&method, _20$$18); - } else { - ZVAL_LONG(&method, _19$$18); - } - ZEPHIR_INIT_NVAR(&collection); - ZVAL_COPY(&collection, _17$$18); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_21$$19, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_21$$19, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_21$$19) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_21$$19), _22$$19) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _22$$19); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_21$$19, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_23$$19, &_21$$19, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_23$$19)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_21$$19, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_21$$19, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_18$$18, &methodAnnotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_18$$18)) { - break; - } - ZEPHIR_CALL_METHOD(&method, &methodAnnotations, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&collection, &methodAnnotations, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_25$$23, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_25$$23, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_25$$23) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_25$$23), _26$$23) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _26$$23); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_25$$23, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_27$$23, &_25$$23, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_27$$23)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_25$$23, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_25$$23, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&collection); - ZEPHIR_INIT_NVAR(&method); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &handlers, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &handlers, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&scope, &handlers, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&scope) != IS_ARRAY) { - continue; - } - ZEPHIR_OBS_NVAR(&prefix); - zephir_array_fetch_long(&prefix, &scope, 0, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 129); - if (!(ZEPHIR_IS_EMPTY(&prefix))) { - ZEPHIR_INIT_NVAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", &_4, 100, &prefix); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_28$$29, &route, "getcompiledpattern", &_6, 487); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_29$$29); - ZVAL_STRING(&_29$$29, "$#"); - ZEPHIR_INIT_NVAR(&_30$$29); - ZVAL_STRING(&_30$$29, "#"); - ZEPHIR_INIT_NVAR(&compiledPattern); - zephir_fast_str_replace(&compiledPattern, &_29$$29, &_30$$29, &_28$$29); - if (zephir_memnstr_str(&compiledPattern, SL("^"), "phalcon/Mvc/Router/Annotations.zep", 146)) { - ZEPHIR_INIT_NVAR(&_31$$30); - ZEPHIR_INIT_NVAR(&_32$$30); - zephir_preg_match(&_32$$30, &compiledPattern, &uri, &_31$$30, 0, 0 , 0 ); - if (!(zephir_is_true(&_32$$30))) { - continue; - } - } else if (!(zephir_start_with(&uri, &prefix, NULL))) { - continue; - } - } - ZEPHIR_OBS_NVAR(&handler); - zephir_array_fetch_long(&handler, &scope, 1, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 161); - if (zephir_memnstr_str(&handler, SL("\\"), "phalcon/Mvc/Router/Annotations.zep", 163)) { - ZEPHIR_INIT_NVAR(&controllerName); - zephir_get_class_ns(&controllerName, &handler, 0); - ZEPHIR_INIT_NVAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &handler, 0); - } else { - ZEPHIR_CPY_WRT(&controllerName, &handler); - ZEPHIR_OBS_NVAR(&namespaceName); - zephir_fetch_property(&namespaceName, this_ptr, SL("defaultNamespace"), PH_SILENT_CC); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &__$null); - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_isset_long_fetch(&moduleName, &scope, 2, 0); - ZEPHIR_INIT_NVAR(&_33$$27); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - ZEPHIR_CPY_WRT(&_33$$27, &moduleName); - } else { - ZEPHIR_INIT_NVAR(&_33$$27); - ZVAL_STRING(&_33$$27, ""); - } - ZEPHIR_CPY_WRT(&moduleName, &_33$$27); - ZEPHIR_INIT_NVAR(&_33$$27); - ZEPHIR_CONCAT_VV(&_33$$27, &controllerName, &controllerSuffix); - zephir_get_strval(&sufixed, &_33$$27); - if (Z_TYPE_P(&namespaceName) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_34$$35); - ZEPHIR_CONCAT_VSV(&_34$$35, &namespaceName, "\\", &sufixed); - zephir_get_strval(&sufixed, &_34$$35); - } - ZEPHIR_CALL_METHOD(&handlerAnnotations, &annotationsService, "get", &_35, 0, &sufixed); - zephir_check_call_status(); - if (Z_TYPE_P(&handlerAnnotations) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&classAnnotations, &handlerAnnotations, "getclassannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&classAnnotations) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&annotations, &classAnnotations, "getannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - zephir_is_iterable(&annotations, 0, "phalcon/Mvc/Router/Annotations.zep", 218); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _36$$38) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _36$$38); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_37$$38, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_37$$38)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } - } - ZEPHIR_CALL_METHOD(&methodAnnotations, &handlerAnnotations, "getmethodsannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&lowerControllerName); - zephir_uncamelize(&lowerControllerName, &controllerName, NULL ); - zephir_is_iterable(&methodAnnotations, 0, "phalcon/Mvc/Router/Annotations.zep", 244); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodAnnotations), _40$$41, _41$$41, _38$$41) - { - ZEPHIR_INIT_NVAR(&method); - if (_41$$41 != NULL) { - ZVAL_STR_COPY(&method, _41$$41); - } else { - ZVAL_LONG(&method, _40$$41); - } - ZEPHIR_INIT_NVAR(&collection); - ZVAL_COPY(&collection, _38$$41); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_42$$42, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_42$$42, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_42$$42) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_42$$42), _43$$42) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _43$$42); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_42$$42, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_44$$42, &_42$$42, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_44$$42)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_42$$42, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_42$$42, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_39$$41, &methodAnnotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_39$$41)) { - break; - } - ZEPHIR_CALL_METHOD(&method, &methodAnnotations, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&collection, &methodAnnotations, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_45$$46, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_45$$46, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_45$$46) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_45$$46), _46$$46) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _46$$46); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_45$$46, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_47$$46, &_45$$46, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_47$$46)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_45$$46, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_45$$46, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&collection); - ZEPHIR_INIT_NVAR(&method); - } - ZEPHIR_CALL_METHOD(NULL, &handlers, "next", NULL, 0); + zephir_array_append(&columns, &_4$$4, PH_SEPARATE, "phalcon/Db/Dialect.zep", 125); + ZEPHIR_CALL_METHOD(NULL, &columnList, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&scope); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, getThis(), "handle", &_48, 0, &uri); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&column); + zephir_fast_join_str(return_value, SL(", "), &columns); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) +static PHP_METHOD(Phalcon_Db_Dialect, getCustomFunctions) { - zend_string *_12$$18, *_18$$21; - zend_ulong _11$$18, _17$$21; - zend_bool isRoute = 0, _8, _21; + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "customFunctions"); +} + +static PHP_METHOD(Phalcon_Db_Dialect, getSqlColumn) +{ + zend_bool _5, _3$$4, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_13 = NULL, *_14 = NULL, *_19 = NULL, *_20 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, annotation_sub, name, proxyActionName, actionName, routePrefix, paths, value, uri, route, methods, converts, param, convert, converterParam, routeName, beforeMatch, _0, _1, _2, _5, _6, _3$$6, _4$$6, _7$$16, *_9$$18, _10$$18, *_15$$21, _16$$21; - zval module, namespaceName, controller, action; + zval bindCounts; + zval escapeChar; + zval *column = NULL, column_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, columnExpression, columnAlias, columnField, columnDomain, _6, _0$$3, _1$$6, _2$$7; zval *this_ptr = getThis(); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(&annotation_sub); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&proxyActionName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&routePrefix); - ZVAL_UNDEF(&paths); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&converts); - ZVAL_UNDEF(¶m); - ZVAL_UNDEF(&convert); - ZVAL_UNDEF(&converterParam); - ZVAL_UNDEF(&routeName); - ZVAL_UNDEF(&beforeMatch); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&columnExpression); + ZVAL_UNDEF(&columnAlias); + ZVAL_UNDEF(&columnField); + ZVAL_UNDEF(&columnDomain); ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_7$$16); - ZVAL_UNDEF(&_10$$18); - ZVAL_UNDEF(&_16$$21); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&bindCounts); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(module) - Z_PARAM_STR(namespaceName) - Z_PARAM_STR(controller) - Z_PARAM_STR(action) - Z_PARAM_OBJECT_OF_CLASS(annotation, phalcon_annotations_annotation_ce) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(column) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); - if (UNEXPECTED(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(module_param) == IS_STRING)) { - zephir_get_strval(&module, module_param); - } else { - ZEPHIR_INIT_VAR(&module); - } - if (UNEXPECTED(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(namespaceName_param) == IS_STRING)) { - zephir_get_strval(&namespaceName, namespaceName_param); - } else { - ZEPHIR_INIT_VAR(&namespaceName); - } - if (UNEXPECTED(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controller_param) == IS_STRING)) { - zephir_get_strval(&controller, controller_param); + zephir_fetch_params(1, 1, 2, &column, &escapeChar_param, &bindCounts_param); + ZEPHIR_SEPARATE_PARAM(column); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&controller); - } - if (UNEXPECTED(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_strval(&escapeChar, escapeChar_param); } - if (EXPECTED(Z_TYPE_P(action_param) == IS_STRING)) { - zephir_get_strval(&action, action_param); + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); } else { - ZEPHIR_INIT_VAR(&action); + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - isRoute = 0; - ZEPHIR_INIT_VAR(&methods); - ZVAL_NULL(&methods); - ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL, 0); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_STRING(&name, "Route")) { - isRoute = 1; - break; - } - if (ZEPHIR_IS_STRING(&name, "Get") || ZEPHIR_IS_STRING(&name, "Post") || ZEPHIR_IS_STRING(&name, "Put") || ZEPHIR_IS_STRING(&name, "Patch") || ZEPHIR_IS_STRING(&name, "Delete") || ZEPHIR_IS_STRING(&name, "Options")) { - isRoute = 1; - ZEPHIR_INIT_NVAR(&methods); - zephir_fast_strtoupper(&methods, &name); - break; - } - } while(0); - - if (!(isRoute)) { - RETURN_MM_NULL(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("actionSuffix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - ZEPHIR_INIT_VAR(&proxyActionName); - zephir_fast_str_replace(&proxyActionName, &_0, &_1, &action); - zephir_read_property(&_2, this_ptr, ZEND_STRL("routePrefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&routePrefix, &_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("actionPreformatCallback"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) != IS_NULL) { - zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("actionPreformatCallback"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_4$$6, "call_user_func", NULL, 187, &_3$$6, &proxyActionName); + if (Z_TYPE_P(column) != IS_ARRAY) { + ZVAL_NULL(&_0$$3); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, column, &_0$$3, &escapeChar); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&proxyActionName, &_4$$6); - } - ZEPHIR_INIT_VAR(&actionName); - zephir_fast_strtolower(&actionName, &proxyActionName); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "paths"); - ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, 0, &_5); - zephir_check_call_status(); - if (Z_TYPE_P(&paths) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&paths); - array_init(&paths); - } - if (!(ZEPHIR_IS_EMPTY(&module))) { - zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); - } - if (!(ZEPHIR_IS_EMPTY(&namespaceName))) { - zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); + RETURN_MM(); } - zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); - ZVAL_LONG(&_6, 0); - ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, 0, &_6); - zephir_check_call_status(); - if (Z_TYPE_P(&value) != IS_NULL) { - if (!ZEPHIR_IS_STRING(&value, "/")) { - ZEPHIR_INIT_VAR(&uri); - ZEPHIR_CONCAT_VV(&uri, &routePrefix, &value); + if (!(zephir_array_isset_string(column, SL("type")))) { + ZEPHIR_OBS_VAR(&columnField); + zephir_array_fetch_long(&columnField, column, 0, PH_NOISY, "phalcon/Db/Dialect.zep", 160); + if (Z_TYPE_P(&columnField) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&columnExpression); + zephir_create_array(&columnExpression, 2, 0); + add_assoc_stringl_ex(&columnExpression, SL("type"), SL("scalar")); + zephir_array_update_string(&columnExpression, SL("value"), &columnField, PH_COPY | PH_SEPARATE); + } else if (ZEPHIR_IS_STRING_IDENTICAL(&columnField, "*")) { + ZEPHIR_INIT_VAR(&_1$$6); + zephir_create_array(&_1$$6, 1, 0); + add_assoc_stringl_ex(&_1$$6, SL("type"), SL("all")); + ZEPHIR_CPY_WRT(&columnExpression, &_1$$6); } else { - if (Z_TYPE_P(&routePrefix) != IS_NULL) { - ZEPHIR_CPY_WRT(&uri, &routePrefix); - } else { - ZEPHIR_CPY_WRT(&uri, &value); - } + ZEPHIR_INIT_VAR(&_2$$7); + zephir_create_array(&_2$$7, 2, 0); + add_assoc_stringl_ex(&_2$$7, SL("type"), SL("qualified")); + zephir_array_update_string(&_2$$7, SL("name"), &columnField, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&columnExpression, &_2$$7); } - } else { - ZEPHIR_INIT_NVAR(&uri); - ZEPHIR_CONCAT_VV(&uri, &routePrefix, &actionName); - } - ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, 0, &uri, &paths); - zephir_check_call_status(); - if (Z_TYPE_P(&methods) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$16); - ZVAL_STRING(&_7$$16, "methods"); - ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, 0, &_7$$16); - zephir_check_call_status(); - } - _8 = Z_TYPE_P(&methods) == IS_ARRAY; - if (!(_8)) { - _8 = Z_TYPE_P(&methods) == IS_STRING; - } - if (_8) { - ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "converts"); - ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, &_5); - zephir_check_call_status(); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - zephir_is_iterable(&converts, 0, "phalcon/Mvc/Router/Annotations.zep", 373); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&converts), _11$$18, _12$$18, _9$$18) - { - ZEPHIR_INIT_NVAR(¶m); - if (_12$$18 != NULL) { - ZVAL_STR_COPY(¶m, _12$$18); - } else { - ZVAL_LONG(¶m, _11$$18); - } - ZEPHIR_INIT_NVAR(&convert); - ZVAL_COPY(&convert, _9$$18); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_13, 0, ¶m, &convert); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &converts, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$18, &converts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$18)) { - break; - } - ZEPHIR_CALL_METHOD(¶m, &converts, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&convert, &converts, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_14, 0, ¶m, &convert); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &converts, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_OBS_VAR(&columnDomain); + _3$$4 = zephir_array_isset_long_fetch(&columnDomain, column, 1, 0); + if (_3$$4) { + _3$$4 = !ZEPHIR_IS_STRING_IDENTICAL(&columnDomain, ""); } - ZEPHIR_INIT_NVAR(&convert); - ZEPHIR_INIT_NVAR(¶m); - } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "converters"); - ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, &_5); - zephir_check_call_status(); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - zephir_is_iterable(&converts, 0, "phalcon/Mvc/Router/Annotations.zep", 384); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&converts), _17$$21, _18$$21, _15$$21) - { - ZEPHIR_INIT_NVAR(&converterParam); - if (_18$$21 != NULL) { - ZVAL_STR_COPY(&converterParam, _18$$21); - } else { - ZVAL_LONG(&converterParam, _17$$21); - } - ZEPHIR_INIT_NVAR(&convert); - ZVAL_COPY(&convert, _15$$21); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_19, 0, &converterParam, &convert); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &converts, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_16$$21, &converts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_16$$21)) { - break; - } - ZEPHIR_CALL_METHOD(&converterParam, &converts, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&convert, &converts, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_20, 0, &converterParam, &convert); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &converts, "next", NULL, 0); - zephir_check_call_status(); - } + if (_3$$4) { + zephir_array_update_string(&columnExpression, SL("domain"), &columnDomain, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&convert); - ZEPHIR_INIT_NVAR(&converterParam); + ZEPHIR_OBS_VAR(&columnAlias); + _4$$4 = zephir_array_isset_long_fetch(&columnAlias, column, 2, 0); + if (_4$$4) { + _4$$4 = zephir_is_true(&columnAlias); + } + if (_4$$4) { + zephir_array_update_string(&columnExpression, SL("sqlAlias"), &columnAlias, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_CPY_WRT(&columnExpression, column); } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "beforeMatch"); - ZEPHIR_CALL_METHOD(&beforeMatch, annotation, "getnamedargument", NULL, 0, &_5); + ZEPHIR_CALL_METHOD(column, this_ptr, "getsqlexpression", NULL, 0, &columnExpression, &escapeChar, &bindCounts); zephir_check_call_status(); - _21 = Z_TYPE_P(&beforeMatch) == IS_ARRAY; - if (!(_21)) { - _21 = Z_TYPE_P(&beforeMatch) == IS_STRING; + ZEPHIR_OBS_NVAR(&columnAlias); + _5 = zephir_array_isset_string_fetch(&columnAlias, &columnExpression, SL("sqlAlias"), 0); + if (!(_5)) { + ZEPHIR_OBS_NVAR(&columnAlias); + _5 = zephir_array_isset_string_fetch(&columnAlias, &columnExpression, SL("alias"), 0); } - if (_21) { - ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); + if (_5) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparecolumnalias", NULL, 0, column, &columnAlias, &escapeChar); zephir_check_call_status(); + RETURN_MM(); } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "name"); - ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, 0, &_5); + ZVAL_NULL(&_6); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparecolumnalias", NULL, 0, column, &_6, &escapeChar); zephir_check_call_status(); - if (Z_TYPE_P(&routeName) == IS_STRING) { - ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &routeName); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processControllerAnnotation) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpression) { + zend_bool _1$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *handler_param = NULL, *annotation, annotation_sub, _0, _1$$3, _2$$3; - zval handler; + zend_long ZEPHIR_LAST_CALL_STATUS, i = 0, _2$$9; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, type, times, postTimes, rawValue, value, _11, _12, _0$$7, _3$$9, _4$$11, _5$$11, _6$$8, _7$$14, _8$$14, _9$$18, _10$$18; + zval expression, bindCounts, placeholders; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&annotation_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(×); + ZVAL_UNDEF(&postTimes); + ZVAL_UNDEF(&rawValue); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_0$$7); + ZVAL_UNDEF(&_3$$9); + ZVAL_UNDEF(&_4$$11); + ZVAL_UNDEF(&_5$$11); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_7$$14); + ZVAL_UNDEF(&_8$$14); + ZVAL_UNDEF(&_9$$18); + ZVAL_UNDEF(&_10$$18); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(handler) - Z_PARAM_OBJECT_OF_CLASS(annotation, phalcon_annotations_annotation_ce) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &handler_param, &annotation); - if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); } - if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { - zephir_get_strval(&handler, handler_param); + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); } else { - ZEPHIR_INIT_VAR(&handler); + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_CALL_METHOD(&_0, annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&_0, "RoutePrefix")) { - ZVAL_LONG(&_2$$3, 0); - ZEPHIR_CALL_METHOD(&_1$$3, annotation, "getargument", NULL, 0, &_2$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &_1$$3); + ZEPHIR_OBS_VAR(&type); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &expression, SL("type"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL expression", "phalcon/Db/Dialect.zep", 224); + return; } + do { + if (ZEPHIR_IS_STRING(&type, "scalar")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionscalar", NULL, 44, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "object")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionobject", NULL, 45, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "qualified")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionqualified", NULL, 46, &expression, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "literal")) { + zephir_array_fetch_string(&_0$$7, &expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 258); + RETURN_CTOR(&_0$$7); + } + if (ZEPHIR_IS_STRING(&type, "placeholder")) { + ZEPHIR_OBS_VAR(×); + if (zephir_array_isset_string_fetch(×, &expression, SL("times"), 0)) { + ZEPHIR_INIT_VAR(&placeholders); + array_init(&placeholders); + ZEPHIR_OBS_VAR(&rawValue); + zephir_array_fetch_string(&rawValue, &expression, SL("rawValue"), PH_NOISY, "phalcon/Db/Dialect.zep", 264); + ZEPHIR_OBS_VAR(&value); + zephir_array_fetch_string(&value, &expression, SL("value"), PH_NOISY, "phalcon/Db/Dialect.zep", 265); + ZEPHIR_OBS_VAR(&postTimes); + if (zephir_array_isset_fetch(&postTimes, &bindCounts, &rawValue, 0)) { + ZEPHIR_CPY_WRT(×, &postTimes); + } + ZEPHIR_CPY_WRT(&_3$$9, ×); + _2$$9 = 1; + _1$$9 = 0; + if (ZEPHIR_GE_LONG(&_3$$9, _2$$9)) { + while (1) { + if (_1$$9) { + _2$$9++; + if (!(ZEPHIR_GE_LONG(&_3$$9, _2$$9))) { + break; + } + } else { + _1$$9 = 1; + } + i = _2$$9; + ZEPHIR_INIT_NVAR(&_4$$11); + ZVAL_LONG(&_4$$11, ((i - 1))); + ZEPHIR_INIT_NVAR(&_5$$11); + ZEPHIR_CONCAT_VV(&_5$$11, &value, &_4$$11); + zephir_array_append(&placeholders, &_5$$11, PH_SEPARATE, "phalcon/Db/Dialect.zep", 272); + } + } + zephir_fast_join_str(return_value, SL(", "), &placeholders); + RETURN_MM(); + } + zephir_array_fetch_string(&_6$$8, &expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 278); + RETURN_CTOR(&_6$$8); + } + if (ZEPHIR_IS_STRING(&type, "binary-op")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionbinaryoperations", NULL, 47, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "unary-op")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionunaryoperations", NULL, 48, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "parentheses")) { + zephir_array_fetch_string(&_8$$14, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 304); + ZEPHIR_CALL_METHOD(&_7$$14, this_ptr, "getsqlexpression", NULL, 49, &_8$$14, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "(", &_7$$14, ")"); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "functionCall")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionfunctioncall", NULL, 50, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "list")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionlist", NULL, 51, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "all")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionall", NULL, 52, &expression, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "select")) { + zephir_array_fetch_string(&_10$$18, &expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 336); + ZEPHIR_CALL_METHOD(&_9$$18, this_ptr, "select", NULL, 0, &_10$$18); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "(", &_9$$18, ")"); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "cast")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressioncastvalue", NULL, 53, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "convert")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionconvertvalue", NULL, 54, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "case")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressioncase", NULL, 55, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + } while(0); + + ZEPHIR_INIT_VAR(&_11); + object_init_ex(&_11, phalcon_db_exception_ce); + ZEPHIR_INIT_VAR(&_12); + ZEPHIR_CONCAT_SVS(&_12, "Invalid SQL expression type '", &type, "'"); + ZEPHIR_CALL_METHOD(NULL, &_11, "__construct", NULL, 32, &_12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11, "phalcon/Db/Dialect.zep", 369); ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionSuffix) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionSuffix_param = NULL; - zval actionSuffix; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval escapeChar; + zval *table, table_sub, *escapeChar_param = NULL, tableName, schemaName, aliasName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&actionSuffix); + ZVAL_UNDEF(&table_sub); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&aliasName); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionSuffix) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &actionSuffix_param); - if (UNEXPECTED(Z_TYPE_P(actionSuffix_param) != IS_STRING && Z_TYPE_P(actionSuffix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionSuffix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionSuffix_param) == IS_STRING)) { - zephir_get_strval(&actionSuffix, actionSuffix_param); + zephir_fetch_params(1, 1, 1, &table, &escapeChar_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&actionSuffix); + zephir_get_strval(&escapeChar, escapeChar_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("actionSuffix"), &actionSuffix); - ZEPHIR_MM_RESTORE(); + if (Z_TYPE_P(table) == IS_ARRAY) { + ZEPHIR_OBS_VAR(&tableName); + zephir_array_fetch_long(&tableName, table, 0, PH_NOISY, "phalcon/Db/Dialect.zep", 385); + ZEPHIR_OBS_VAR(&schemaName); + zephir_array_isset_long_fetch(&schemaName, table, 1, 0); + ZEPHIR_OBS_VAR(&aliasName); + zephir_array_isset_long_fetch(&aliasName, table, 2, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparetable", NULL, 0, &tableName, &schemaName, &aliasName, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 56, table, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionPreformatCallback) +static PHP_METHOD(Phalcon_Db_Dialect, limit) { + zend_bool _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *callback = NULL, callback_sub, __$null, _0$$4; + zval *sqlQuery_param = NULL, *number, number_sub, _0$$3, _1$$3, _3$$3, _4$$4, _5$$4; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&callback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&number_sub); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(callback) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(sqlQuery) + Z_PARAM_ZVAL(number) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &callback); - if (!callback) { - callback = &callback_sub; - callback = &__$null; + zephir_fetch_params(1, 2, 0, &sqlQuery_param, &number); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); } - if (EXPECTED(zephir_is_callable(callback))) { - zephir_update_property_zval(this_ptr, ZEND_STRL("actionPreformatCallback"), callback); - } else if (Z_TYPE_P(callback) == IS_NULL) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_NVAR(&_0$$4); - zephir_create_closure_ex(&_0$$4, NULL, phalcon_10__closure_ce, SL("__invoke")); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionPreformatCallback"), &_0$$4); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The 'callback' parameter must be either a callable or NULL.", "phalcon/Mvc/Router/Annotations.zep", 463); - return; + if (Z_TYPE_P(number) == IS_ARRAY) { + zephir_array_fetch_long(&_0$$3, number, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 428); + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SV(&_1$$3, " LIMIT ", &_0$$3); + zephir_concat_self(&sqlQuery, &_1$$3); + _2$$3 = zephir_array_isset_long(number, 1); + if (_2$$3) { + zephir_array_fetch_long(&_3$$3, number, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 430); + _2$$3 = ((zephir_fast_strlen_ev(&_3$$3)) ? 1 : 0); + } + if (_2$$3) { + zephir_array_fetch_long(&_4$$4, number, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 431); + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_SV(&_5$$4, " OFFSET ", &_4$$4); + zephir_concat_self(&sqlQuery, &_5$$4); + } + RETURN_CTOR(&sqlQuery); } - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_VSV(return_value, &sqlQuery, " LIMIT ", number); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getActionPreformatCallback) +static PHP_METHOD(Phalcon_Db_Dialect, registerCustomFunction) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, *customFunction, customFunction_sub; + zval name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&customFunction_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(customFunction) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "actionPreformatCallback"); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &customFunction); + zephir_get_strval(&name, name_param); + + + zephir_update_property_array(this_ptr, SL("customFunctions"), &name, customFunction); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setControllerSuffix) +static PHP_METHOD(Phalcon_Db_Dialect, releaseSavepoint) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerSuffix_param = NULL; - zval controllerSuffix; + zval *name_param = NULL; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerSuffix); + ZVAL_UNDEF(&name); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerSuffix) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &controllerSuffix_param); - if (UNEXPECTED(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be of the type string")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { - zephir_get_strval(&controllerSuffix, controllerSuffix_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&controllerSuffix); + ZEPHIR_INIT_VAR(&name); } - zephir_update_property_zval(this_ptr, ZEND_STRL("controllerSuffix"), &controllerSuffix); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_SV(return_value, "RELEASE SAVEPOINT ", &name); + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router_Annotations(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Dialect, rollbackSavepoint) { - zval _0, _2, _4, _6, _8, _10, _12, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteIds"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteNames"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_13$$9); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&name); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Exception, phalcon, mvc_router_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; + ZEPHIR_CONCAT_SV(return_value, "ROLLBACK TO SAVEPOINT ", &name); + RETURN_MM(); } +static PHP_METHOD(Phalcon_Db_Dialect, select) +{ + zend_bool _5, _9, _12, _15, _18, _21, _23; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *definition_param = NULL, tables, columns, sql, distinct, joins, where, escapeChar, groupBy, having, orderBy, limit, forUpdate, bindCounts, _0, _1, _2, _3, _4, _6$$10, _7$$10, _8$$10, _10$$11, _11$$11, _13$$12, _14$$12, _16$$13, _17$$13, _19$$14, _20$$14; + zval definition, _22$$15; + zval *this_ptr = getThis(); - - -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&distinct); + ZVAL_UNDEF(&joins); + ZVAL_UNDEF(&where); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&groupBy); + ZVAL_UNDEF(&having); + ZVAL_UNDEF(&orderBy); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&forUpdate); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6$$10); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_13$$12); + ZVAL_UNDEF(&_14$$12); + ZVAL_UNDEF(&_16$$13); + ZVAL_UNDEF(&_17$$13); + ZVAL_UNDEF(&_19$$14); + ZVAL_UNDEF(&_20$$14); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(definition) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &definition_param); + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + ZEPHIR_OBS_VAR(&tables); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &definition, SL("tables"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'tables' is required in the definition array", "phalcon/Db/Dialect.zep", 477); + return; + } + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/Db/Dialect.zep", 483); + return; + } + ZEPHIR_OBS_VAR(&distinct); + if (zephir_array_isset_string_fetch(&distinct, &definition, SL("distinct"), 0)) { + ZEPHIR_INIT_VAR(&sql); + if (zephir_is_true(&distinct)) { + ZVAL_STRING(&sql, "SELECT DISTINCT"); + } else { + ZVAL_STRING(&sql, "SELECT ALL"); + } + } else { + ZEPHIR_INIT_NVAR(&sql); + ZVAL_STRING(&sql, "SELECT"); + } + ZEPHIR_OBS_VAR(&bindCounts); + zephir_array_isset_string_fetch(&bindCounts, &definition, SL("bindCounts"), 0); + if (Z_TYPE_P(&bindCounts) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&bindCounts); + array_init(&bindCounts); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("escapeChar"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&escapeChar, &_0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcolumnlist", NULL, 57, &columns, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_SV(&_2, " ", &_1); + zephir_concat_self(&sql, &_2); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getsqlexpressionfrom", NULL, 58, &tables, &escapeChar); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SV(&_4, " ", &_3); + zephir_concat_self(&sql, &_4); + ZEPHIR_OBS_VAR(&joins); + _5 = zephir_array_isset_string_fetch(&joins, &definition, SL("joins"), 0); + if (_5) { + _5 = zephir_is_true(&joins); + } + if (_5) { + zephir_array_fetch_string(&_7$$10, &definition, SL("joins"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 517); + ZEPHIR_CALL_METHOD(&_6$$10, this_ptr, "getsqlexpressionjoins", NULL, 59, &_7$$10, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_8$$10); + ZEPHIR_CONCAT_SV(&_8$$10, " ", &_6$$10); + zephir_concat_self(&sql, &_8$$10); + } + ZEPHIR_OBS_VAR(&where); + _9 = zephir_array_isset_string_fetch(&where, &definition, SL("where"), 0); + if (_9) { + _9 = zephir_is_true(&where); + } + if (_9) { + ZEPHIR_CALL_METHOD(&_10$$11, this_ptr, "getsqlexpressionwhere", NULL, 60, &where, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_11$$11); + ZEPHIR_CONCAT_SV(&_11$$11, " ", &_10$$11); + zephir_concat_self(&sql, &_11$$11); + } + ZEPHIR_OBS_VAR(&groupBy); + _12 = zephir_array_isset_string_fetch(&groupBy, &definition, SL("group"), 0); + if (_12) { + _12 = zephir_is_true(&groupBy); + } + if (_12) { + ZEPHIR_CALL_METHOD(&_13$$12, this_ptr, "getsqlexpressiongroupby", NULL, 61, &groupBy, &escapeChar); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_14$$12); + ZEPHIR_CONCAT_SV(&_14$$12, " ", &_13$$12); + zephir_concat_self(&sql, &_14$$12); + } + ZEPHIR_OBS_VAR(&having); + _15 = zephir_array_isset_string_fetch(&having, &definition, SL("having"), 0); + if (_15) { + _15 = zephir_is_true(&having); + } + if (_15) { + ZEPHIR_CALL_METHOD(&_16$$13, this_ptr, "getsqlexpressionhaving", NULL, 62, &having, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_17$$13); + ZEPHIR_CONCAT_SV(&_17$$13, " ", &_16$$13); + zephir_concat_self(&sql, &_17$$13); + } + ZEPHIR_OBS_VAR(&orderBy); + _18 = zephir_array_isset_string_fetch(&orderBy, &definition, SL("order"), 0); + if (_18) { + _18 = zephir_is_true(&orderBy); + } + if (_18) { + ZEPHIR_CALL_METHOD(&_19$$14, this_ptr, "getsqlexpressionorderby", NULL, 63, &orderBy, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_20$$14); + ZEPHIR_CONCAT_SV(&_20$$14, " ", &_19$$14); + zephir_concat_self(&sql, &_20$$14); + } + ZEPHIR_OBS_VAR(&limit); + _21 = zephir_array_isset_string_fetch(&limit, &definition, SL("limit"), 0); + if (_21) { + _21 = zephir_is_true(&limit); + } + if (_21) { + ZEPHIR_INIT_VAR(&_22$$15); + zephir_create_array(&_22$$15, 2, 0); + zephir_array_update_string(&_22$$15, SL("sql"), &sql, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_22$$15, SL("value"), &limit, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&sql, this_ptr, "getsqlexpressionlimit", NULL, 64, &_22$$15, &escapeChar, &bindCounts); + zephir_check_call_status(); + } + _23 = zephir_array_isset_string_fetch(&forUpdate, &definition, SL("forUpdate"), 1); + if (_23) { + _23 = zephir_is_true(&forUpdate); + } + if (_23) { + zephir_concat_self_str(&sql, SL(" FOR UPDATE")); + } + RETURN_CCTOR(&sql); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Group) +static PHP_METHOD(Phalcon_Db_Dialect, supportsSavepoints) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Group, phalcon, mvc_router_group, phalcon_mvc_router_group_method_entry, 0); + zval *this_ptr = getThis(); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("hostname"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("paths"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("prefix"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("routes"), ZEND_ACC_PROTECTED); - phalcon_mvc_router_group_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Group; - zend_class_implements(phalcon_mvc_router_group_ce, 1, phalcon_mvc_router_groupinterface_ce); - return SUCCESS; + + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, __construct) +static PHP_METHOD(Phalcon_Db_Dialect, supportsReleaseSavepoints) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *paths = NULL, paths_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &paths); - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - - _0 = Z_TYPE_P(paths) == IS_ARRAY; - if (!(_0)) { - _0 = Z_TYPE_P(paths) == IS_STRING; - } - if (_0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), paths); - } - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("initialize")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, paths); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "supportssavepoints", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, add) +static PHP_METHOD(Phalcon_Db_Dialect, getColumnSize) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null; - zval pattern; + zval *column, column_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; - } + zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, httpMethods); + ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "(", &_0, ")"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addConnect) +static PHP_METHOD(Phalcon_Db_Dialect, getColumnSizeAndScale) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *column, column_sub, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } + zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "CONNECT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, column, "getscale", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "(", &_0, ",", &_1, ")"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addDelete) +static PHP_METHOD(Phalcon_Db_Dialect, checkColumnType) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *column, column_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } + zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DELETE"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZEPHIR_CALL_METHOD(&_0, column, "gettype", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&_0) == IS_STRING) { + ZEPHIR_RETURN_CALL_METHOD(column, "gettypereference", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(column, "gettype", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addGet) +static PHP_METHOD(Phalcon_Db_Dialect, checkColumnTypeSql) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *column, column_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } + zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GET"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZEPHIR_CALL_METHOD(&_0, column, "gettype", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&_0) != IS_STRING) { + RETURN_MM_STRING(""); + } + ZEPHIR_RETURN_CALL_METHOD(column, "gettype", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addHead) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionAll) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, domain, _0; + zval expression; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&domain); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 1, &expression_param, &escapeChar_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_get_strval(&escapeChar, escapeChar_param); } + ZEPHIR_OBS_VAR(&domain); + zephir_array_isset_string_fetch(&domain, &expression, SL("domain"), 0); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HEAD"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZVAL_STRING(&_0, "*"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, &_0, &domain, &escapeChar); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addOptions) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionBinaryOperations) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0, _1, _2; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&left); + ZVAL_UNDEF(&right); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OPTIONS"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_array_fetch_string(&_0, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 654); + ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", NULL, 0, &_0, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_fetch_string(&_1, &expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 660); + ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", NULL, 49, &_1, &escapeChar, &bindCounts); zephir_check_call_status(); + zephir_array_fetch_string(&_2, &expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 665); + ZEPHIR_CONCAT_VSVSV(return_value, &left, " ", &_2, " ", &right); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPatch) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionCase) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar, sql; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, whenClause, _0, _1, _2, _3, *_4, _5, _6$$3, _7$$4, _8$$4, _9$$4, _10$$4, _11$$4, _12$$5, _13$$5, _14$$5, _15$$6, _16$$7, _17$$7, _18$$7, _19$$7, _20$$7, _21$$8, _22$$8, _23$$8; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&whenClause); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&_11$$4); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_18$$7); + ZVAL_UNDEF(&_19$$7); + ZVAL_UNDEF(&_20$$7); + ZVAL_UNDEF(&_21$$8); + ZVAL_UNDEF(&_22$$8); + ZVAL_UNDEF(&_23$$8); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&sql); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PATCH"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_array_fetch_string(&_1, &expression, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 682); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", NULL, 0, &_1, &escapeChar, &bindCounts); zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_SV(&_2, "CASE ", &_0); + zephir_get_strval(&sql, &_2); + zephir_array_fetch_string(&_3, &expression, SL("when-clauses"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 684); + zephir_is_iterable(&_3, 0, "phalcon/Db/Dialect.zep", 695); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) + { + ZEPHIR_INIT_NVAR(&whenClause); + ZVAL_COPY(&whenClause, _4); + zephir_array_fetch_string(&_6$$3, &whenClause, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 685); + if (ZEPHIR_IS_STRING(&_6$$3, "when")) { + zephir_array_fetch_string(&_8$$4, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 687); + ZEPHIR_CALL_METHOD(&_7$$4, this_ptr, "getsqlexpression", NULL, 49, &_8$$4, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_fetch_string(&_10$$4, &whenClause, SL("then"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 689); + ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getsqlexpression", NULL, 49, &_10$$4, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$4); + ZEPHIR_CONCAT_SVSV(&_11$$4, " WHEN ", &_7$$4, " THEN ", &_9$$4); + zephir_concat_self(&sql, &_11$$4); + } else { + zephir_array_fetch_string(&_13$$5, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 691); + ZEPHIR_CALL_METHOD(&_12$$5, this_ptr, "getsqlexpression", NULL, 49, &_13$$5, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$5); + ZEPHIR_CONCAT_SV(&_14$$5, " ELSE ", &_12$$5); + zephir_concat_self(&sql, &_14$$5); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&whenClause, &_3, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_15$$6, &whenClause, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 685); + if (ZEPHIR_IS_STRING(&_15$$6, "when")) { + zephir_array_fetch_string(&_17$$7, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 687); + ZEPHIR_CALL_METHOD(&_16$$7, this_ptr, "getsqlexpression", NULL, 49, &_17$$7, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_fetch_string(&_19$$7, &whenClause, SL("then"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 689); + ZEPHIR_CALL_METHOD(&_18$$7, this_ptr, "getsqlexpression", NULL, 49, &_19$$7, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_20$$7); + ZEPHIR_CONCAT_SVSV(&_20$$7, " WHEN ", &_16$$7, " THEN ", &_18$$7); + zephir_concat_self(&sql, &_20$$7); + } else { + zephir_array_fetch_string(&_22$$8, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 691); + ZEPHIR_CALL_METHOD(&_21$$8, this_ptr, "getsqlexpression", NULL, 49, &_22$$8, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_23$$8); + ZEPHIR_CONCAT_SV(&_23$$8, " ELSE ", &_21$$8); + zephir_concat_self(&sql, &_23$$8); + } + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&whenClause); + ZEPHIR_CONCAT_VS(return_value, &sql, " END"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPost) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionCastValue) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0, _1; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&left); + ZVAL_UNDEF(&right); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "POST"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_array_fetch_string(&_0, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 712); + ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", NULL, 0, &_0, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_fetch_string(&_1, &expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 718); + ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", NULL, 49, &_1, &escapeChar, &bindCounts); zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "CAST(", &left, " AS ", &right, ")"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPurge) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionConvertValue) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0, _1; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&left); + ZVAL_UNDEF(&right); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PURGE"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_array_fetch_string(&_0, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 740); + ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", NULL, 0, &_0, &escapeChar, &bindCounts); zephir_check_call_status(); + zephir_array_fetch_string(&_1, &expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 746); + ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", NULL, 49, &_1, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "CONVERT(", &left, " USING ", &right, ")"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPut) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionFrom) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar; + zval *expression, expression_sub, *escapeChar_param = NULL, table, tables, *_0$$3, _1$$3, _5$$3, _2$$4, _4$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&expression_sub); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + Z_PARAM_ZVAL(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 1, &expression, &escapeChar_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_get_strval(&escapeChar, escapeChar_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PUT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); - zephir_check_call_status(); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&tables); + array_init(&tables); + zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 768); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0$$3) + { + ZEPHIR_INIT_NVAR(&table); + ZVAL_COPY(&table, _0$$3); + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getsqltable", &_3, 65, &table, &escapeChar); + zephir_check_call_status(); + zephir_array_append(&tables, &_2$$4, PH_SEPARATE, "phalcon/Db/Dialect.zep", 765); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, expression, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&table, expression, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getsqltable", &_3, 65, &table, &escapeChar); + zephir_check_call_status(); + zephir_array_append(&tables, &_4$$5, PH_SEPARATE, "phalcon/Db/Dialect.zep", 765); + ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&table); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_fast_join_str(&_5$$3, SL(", "), &tables); + ZEPHIR_CPY_WRT(&tables, &_5$$3); + } else { + ZEPHIR_CPY_WRT(&tables, expression); + } + ZEPHIR_CONCAT_SV(return_value, "FROM ", &tables); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addTrace) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionFunctionCall) { + zend_bool _1, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, __$false, name, customFunction, arguments, _0, _4$$4; + zval expression, bindCounts, _2$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&_2$$4); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&customFunction); + ZVAL_UNDEF(&arguments); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "TRACE"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); - zephir_check_call_status(); + ZEPHIR_OBS_VAR(&name); + zephir_array_fetch_string(&name, &expression, SL("name"), PH_NOISY, "phalcon/Db/Dialect.zep", 789); + ZEPHIR_OBS_VAR(&customFunction); + zephir_read_property(&_0, this_ptr, ZEND_STRL("customFunctions"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&customFunction, &_0, &name, 0)) { + ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(&customFunction, NULL, 0, this_ptr, &expression, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_OBS_VAR(&arguments); + _1 = zephir_array_isset_string_fetch(&arguments, &expression, SL("arguments"), 0); + if (_1) { + _1 = Z_TYPE_P(&arguments) == IS_ARRAY; + } + if (_1) { + ZEPHIR_INIT_VAR(&_2$$4); + zephir_create_array(&_2$$4, 3, 0); + add_assoc_stringl_ex(&_2$$4, SL("type"), SL("list")); + zephir_array_update_string(&_2$$4, SL("parentheses"), &__$false, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_2$$4, SL("value"), &arguments, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&arguments, this_ptr, "getsqlexpression", NULL, 0, &_2$$4, &escapeChar, &bindCounts); + zephir_check_call_status(); + _3$$4 = zephir_array_isset_string(&expression, SL("distinct")); + if (_3$$4) { + zephir_array_fetch_string(&_4$$4, &expression, SL("distinct"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 806); + _3$$4 = zephir_is_true(&_4$$4); + } + if (_3$$4) { + ZEPHIR_CONCAT_VSVS(return_value, &name, "(DISTINCT ", &arguments, ")"); + RETURN_MM(); + } + ZEPHIR_CONCAT_VSVS(return_value, &name, "(", &arguments, ")"); + RETURN_MM(); + } + ZEPHIR_CONCAT_VS(return_value, &name, "()"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, beforeMatch) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionGroupBy) { - zval *beforeMatch, beforeMatch_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval bindCounts; + zval escapeChar; + zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, field, fields, *_0$$3, _1$$3, _5$$3, _2$$4, _4$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&beforeMatch_sub); + ZVAL_UNDEF(&expression_sub); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&bindCounts); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(beforeMatch) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) + ZEND_PARSE_PARAMETERS_END(); +#endif - zephir_fetch_params_without_memory_grow(1, 0, &beforeMatch); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), beforeMatch); - RETURN_THISW(); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 844); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0$$3) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _0$$3); + if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-GROUP-BY expression", "phalcon/Db/Dialect.zep", 834); + return; + } + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getsqlexpression", &_3, 0, &field, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&fields, &_2$$4, PH_SEPARATE, "phalcon/Db/Dialect.zep", 841); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, expression, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&field, expression, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-GROUP-BY expression", "phalcon/Db/Dialect.zep", 834); + return; + } + ZEPHIR_CALL_METHOD(&_4$$6, this_ptr, "getsqlexpression", &_3, 49, &field, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&fields, &_4$$6, PH_SEPARATE, "phalcon/Db/Dialect.zep", 841); + ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_fast_join_str(&_5$$3, SL(", "), &fields); + ZEPHIR_CPY_WRT(&fields, &_5$$3); + } else { + ZEPHIR_CPY_WRT(&fields, expression); + } + ZEPHIR_CONCAT_SV(return_value, "GROUP BY ", &fields); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, clear) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionHaving) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, _0; + zval expression, bindCounts; zval *this_ptr = getThis(); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&escapeChar); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Router_Group, getBeforeMatch) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "beforeMatch"); -} - -static PHP_METHOD(Phalcon_Mvc_Router_Group, getHostname) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "hostname"); -} - -static PHP_METHOD(Phalcon_Mvc_Router_Group, getPaths) -{ - zval *this_ptr = getThis(); - + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - RETURN_MEMBER(getThis(), "paths"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", NULL, 0, &expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, "HAVING ", &_0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, getPrefix) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionJoins) { + zend_bool _2$$3, _9$$3, _13$$11, _19$$11; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_11 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval bindCounts; + zval escapeChar, sql; + zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, condition, join, joinCondition, joinTable, joinType, joinConditionsArray, *_0, _1, _10$$3, _12$$3, *_4$$6, _5$$6, _8$$6, _6$$7, _7$$8, _20$$11, _21$$11, *_14$$14, _15$$14, _18$$14, _16$$15, _17$$16; zval *this_ptr = getThis(); + ZVAL_UNDEF(&expression_sub); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&joinCondition); + ZVAL_UNDEF(&joinTable); + ZVAL_UNDEF(&joinType); + ZVAL_UNDEF(&joinConditionsArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_20$$11); + ZVAL_UNDEF(&_21$$11); + ZVAL_UNDEF(&_15$$14); + ZVAL_UNDEF(&_18$$14); + ZVAL_UNDEF(&_16$$15); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&bindCounts); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "prefix"); -} - -static PHP_METHOD(Phalcon_Mvc_Router_Group, getRoutes) -{ - zval *this_ptr = getThis(); - + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - RETURN_MEMBER(getThis(), "routes"); + ZEPHIR_INIT_VAR(&joinType); + ZVAL_STRING(&joinType, ""); + ZEPHIR_INIT_VAR(&sql); + zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 918); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0) + { + ZEPHIR_INIT_NVAR(&join); + ZVAL_COPY(&join, _0); + ZEPHIR_OBS_NVAR(&joinConditionsArray); + _2$$3 = zephir_array_isset_string_fetch(&joinConditionsArray, &join, SL("conditions"), 0); + if (_2$$3) { + _2$$3 = !(ZEPHIR_IS_EMPTY(&joinConditionsArray)); + } + if (_2$$3) { + if (!(zephir_array_isset_long(&joinConditionsArray, 0))) { + ZEPHIR_CALL_METHOD(&joinCondition, this_ptr, "getsqlexpression", &_3, 0, &joinConditionsArray, &escapeChar, &bindCounts); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&joinCondition); + array_init(&joinCondition); + zephir_is_iterable(&joinConditionsArray, 0, "phalcon/Db/Dialect.zep", 903); + if (Z_TYPE_P(&joinConditionsArray) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joinConditionsArray), _4$$6) + { + ZEPHIR_INIT_NVAR(&condition); + ZVAL_COPY(&condition, _4$$6); + ZEPHIR_CALL_METHOD(&_6$$7, this_ptr, "getsqlexpression", &_3, 49, &condition, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&joinCondition, &_6$$7, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$6, &joinConditionsArray, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$6)) { + break; + } + ZEPHIR_CALL_METHOD(&condition, &joinConditionsArray, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "getsqlexpression", &_3, 49, &condition, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&joinCondition, &_7$$8, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); + ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&condition); + ZEPHIR_INIT_NVAR(&_8$$6); + zephir_fast_join_str(&_8$$6, SL(" AND "), &joinCondition); + ZEPHIR_CPY_WRT(&joinCondition, &_8$$6); + } + } else { + ZEPHIR_INIT_NVAR(&joinCondition); + ZVAL_LONG(&joinCondition, 1); + } + ZEPHIR_OBS_NVAR(&joinType); + _9$$3 = zephir_array_isset_string_fetch(&joinType, &join, SL("type"), 0); + if (_9$$3) { + _9$$3 = zephir_is_true(&joinType); + } + if (_9$$3) { + zephir_concat_self_str(&joinType, SL(" ")); + } + zephir_array_fetch_string(&_10$$3, &join, SL("source"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 913); + ZEPHIR_CALL_METHOD(&joinTable, this_ptr, "getsqltable", &_11, 65, &_10$$3, &escapeChar); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$3); + ZEPHIR_CONCAT_SVSVSV(&_12$$3, " ", &joinType, "JOIN ", &joinTable, " ON ", &joinCondition); + zephir_concat_self(&sql, &_12$$3); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, expression, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&join, expression, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&joinConditionsArray); + _13$$11 = zephir_array_isset_string_fetch(&joinConditionsArray, &join, SL("conditions"), 0); + if (_13$$11) { + _13$$11 = !(ZEPHIR_IS_EMPTY(&joinConditionsArray)); + } + if (_13$$11) { + if (!(zephir_array_isset_long(&joinConditionsArray, 0))) { + ZEPHIR_CALL_METHOD(&joinCondition, this_ptr, "getsqlexpression", &_3, 49, &joinConditionsArray, &escapeChar, &bindCounts); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&joinCondition); + array_init(&joinCondition); + zephir_is_iterable(&joinConditionsArray, 0, "phalcon/Db/Dialect.zep", 903); + if (Z_TYPE_P(&joinConditionsArray) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joinConditionsArray), _14$$14) + { + ZEPHIR_INIT_NVAR(&condition); + ZVAL_COPY(&condition, _14$$14); + ZEPHIR_CALL_METHOD(&_16$$15, this_ptr, "getsqlexpression", &_3, 49, &condition, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&joinCondition, &_16$$15, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_15$$14, &joinConditionsArray, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_15$$14)) { + break; + } + ZEPHIR_CALL_METHOD(&condition, &joinConditionsArray, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_17$$16, this_ptr, "getsqlexpression", &_3, 49, &condition, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&joinCondition, &_17$$16, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); + ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&condition); + ZEPHIR_INIT_NVAR(&_18$$14); + zephir_fast_join_str(&_18$$14, SL(" AND "), &joinCondition); + ZEPHIR_CPY_WRT(&joinCondition, &_18$$14); + } + } else { + ZEPHIR_INIT_NVAR(&joinCondition); + ZVAL_LONG(&joinCondition, 1); + } + ZEPHIR_OBS_NVAR(&joinType); + _19$$11 = zephir_array_isset_string_fetch(&joinType, &join, SL("type"), 0); + if (_19$$11) { + _19$$11 = zephir_is_true(&joinType); + } + if (_19$$11) { + zephir_concat_self_str(&joinType, SL(" ")); + } + zephir_array_fetch_string(&_20$$11, &join, SL("source"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 913); + ZEPHIR_CALL_METHOD(&joinTable, this_ptr, "getsqltable", &_11, 65, &_20$$11, &escapeChar); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_21$$11); + ZEPHIR_CONCAT_SVSVSV(&_21$$11, " ", &joinType, "JOIN ", &joinTable, " ON ", &joinCondition); + zephir_concat_self(&sql, &_21$$11); + ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&join); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, setHostname) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionLimit) { + zend_bool _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *hostname_param = NULL; - zval hostname; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval bindCounts, _4; + zval escapeChar; + zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, sql, value, limit, offset, _0$$4, _1$$5, _3$$7; zval *this_ptr = getThis(); - ZVAL_UNDEF(&hostname); + ZVAL_UNDEF(&expression_sub); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&_4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(hostname) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &hostname_param); - zephir_get_strval(&hostname, hostname_param); + zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("hostname"), &hostname); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&sql); + ZVAL_STRING(&sql, ""); + ZEPHIR_INIT_VAR(&offset); + ZVAL_NULL(&offset); + ZEPHIR_OBS_VAR(&value); + zephir_array_fetch_string(&value, expression, SL("value"), PH_NOISY, "phalcon/Db/Dialect.zep", 934); + if (zephir_array_isset_string(expression, SL("sql"))) { + ZEPHIR_OBS_NVAR(&sql); + zephir_array_fetch_string(&sql, expression, SL("sql"), PH_NOISY, "phalcon/Db/Dialect.zep", 937); + } + if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_OBS_VAR(&_0$$4); + zephir_array_fetch_string(&_0$$4, &value, SL("number"), PH_NOISY, "phalcon/Db/Dialect.zep", 941); + if (Z_TYPE_P(&_0$$4) == IS_ARRAY) { + zephir_array_fetch_string(&_1$$5, &value, SL("number"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 943); + ZEPHIR_CALL_METHOD(&limit, this_ptr, "getsqlexpression", NULL, 0, &_1$$5, &escapeChar, &bindCounts); + zephir_check_call_status(); + } else { + ZEPHIR_OBS_NVAR(&limit); + zephir_array_fetch_string(&limit, &value, SL("number"), PH_NOISY, "phalcon/Db/Dialect.zep", 948); + } + ZEPHIR_OBS_NVAR(&offset); + _2$$4 = zephir_array_isset_string_fetch(&offset, &value, SL("offset"), 0); + if (_2$$4) { + _2$$4 = Z_TYPE_P(&offset) == IS_ARRAY; + } + if (_2$$4) { + ZEPHIR_CALL_METHOD(&_3$$7, this_ptr, "getsqlexpression", NULL, 49, &offset, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&offset, &_3$$7); + } + } else { + ZEPHIR_CPY_WRT(&limit, &value); + } + ZEPHIR_INIT_VAR(&_4); + zephir_create_array(&_4, 2, 0); + zephir_array_fast_append(&_4, &limit); + zephir_array_fast_append(&_4, &offset); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "limit", NULL, 0, &sql, &_4); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, setPaths) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionList) { - zval *paths, paths_sub; + zend_bool _0, _1, _7$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, item, values, separator, *_2$$4, _3$$4, _8$$4, _9$$4, _4$$5, _6$$6; + zval expression, bindCounts, items; zval *this_ptr = getThis(); - ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&items); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&separator); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(paths) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &paths); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), paths); - RETURN_THISW(); + ZEPHIR_INIT_VAR(&items); + array_init(&items); + ZEPHIR_INIT_VAR(&separator); + ZVAL_STRING(&separator, ", "); + if (zephir_array_isset_string(&expression, SL("separator"))) { + ZEPHIR_OBS_NVAR(&separator); + zephir_array_fetch_string(&separator, &expression, SL("separator"), PH_NOISY, "phalcon/Db/Dialect.zep", 987); + } + ZEPHIR_OBS_VAR(&values); + _0 = zephir_array_isset_long_fetch(&values, &expression, 0, 0); + if (!(_0)) { + ZEPHIR_OBS_NVAR(&values); + _0 = zephir_array_isset_string_fetch(&values, &expression, SL("value"), 0); + } + _1 = _0; + if (_1) { + _1 = Z_TYPE_P(&values) == IS_ARRAY; + } + if (_1) { + zephir_is_iterable(&values, 0, "phalcon/Db/Dialect.zep", 996); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _2$$4) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _2$$4); + ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getsqlexpression", &_5, 0, &item, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&items, &_4$$5, PH_SEPARATE, "phalcon/Db/Dialect.zep", 993); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &values, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&item, &values, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getsqlexpression", &_5, 49, &item, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_append(&items, &_6$$6, PH_SEPARATE, "phalcon/Db/Dialect.zep", 993); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&item); + _7$$4 = zephir_array_isset_string(&expression, SL("parentheses")); + if (_7$$4) { + zephir_array_fetch_string(&_8$$4, &expression, SL("parentheses"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 996); + _7$$4 = ZEPHIR_IS_FALSE_IDENTICAL(&_8$$4); + } + if (_7$$4) { + zephir_fast_join(return_value, &separator, &items); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_9$$4); + zephir_fast_join(&_9$$4, &separator, &items); + ZEPHIR_CONCAT_SVS(return_value, "(", &_9$$4, ")"); + RETURN_MM(); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-list expression", "phalcon/Db/Dialect.zep", 1003); + return; } -static PHP_METHOD(Phalcon_Mvc_Router_Group, setPrefix) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionObject) { + zend_bool _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *prefix_param = NULL; - zval prefix; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, domain, objectExpression; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&objectExpression); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &prefix_param); - zephir_get_strval(&prefix, prefix_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&domain); + ZVAL_NULL(&domain); + ZEPHIR_INIT_VAR(&objectExpression); + zephir_create_array(&objectExpression, 1, 0); + add_assoc_stringl_ex(&objectExpression, SL("type"), SL("all")); + ZEPHIR_OBS_NVAR(&domain); + _0 = zephir_array_isset_string_fetch(&domain, &expression, SL("column"), 0); + if (!(_0)) { + ZEPHIR_OBS_NVAR(&domain); + _0 = zephir_array_isset_string_fetch(&domain, &expression, SL("domain"), 0); + } + _1 = _0; + if (_1) { + _1 = !ZEPHIR_IS_STRING(&domain, ""); + } + if (_1) { + zephir_array_update_string(&objectExpression, SL("domain"), &domain, PH_COPY | PH_SEPARATE); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpression", NULL, 0, &objectExpression, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addRoute) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionOrderBy) { + zend_bool _4$$4, _7$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null, mergedPaths, route, defaultPaths, processedPaths, _1, _2; - zval pattern; + zval bindCounts; + zval escapeChar; + zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, field, fields, type, fieldSql, *_0$$3, _1$$3, _9$$3, _2$$4, _5$$6, _6$$7, _8$$9; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&mergedPaths); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&defaultPaths); - ZVAL_UNDEF(&processedPaths); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&expression_sub); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&fieldSql); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&bindCounts); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + Z_PARAM_ZVAL(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_OBS_VAR(&defaultPaths); - zephir_read_property(&defaultPaths, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC); - if (Z_TYPE_P(&defaultPaths) == IS_ARRAY) { - if (Z_TYPE_P(paths) == IS_STRING) { - ZEPHIR_CALL_CE_STATIC(&processedPaths, phalcon_mvc_router_route_ce, "getroutepaths", &_0, 0, paths); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&processedPaths, paths); - } - if (Z_TYPE_P(&processedPaths) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&mergedPaths); - zephir_fast_array_merge(&mergedPaths, &defaultPaths, &processedPaths); + ZEPHIR_INIT_VAR(&fieldSql); + ZVAL_NULL(&fieldSql); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 1068); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0$$3) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _0$$3); + if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-ORDER-BY expression", "phalcon/Db/Dialect.zep", 1049); + return; + } + zephir_array_fetch_long(&_2$$4, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1053); + ZEPHIR_CALL_METHOD(&fieldSql, this_ptr, "getsqlexpression", &_3, 0, &_2$$4, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&type); + _4$$4 = zephir_array_isset_long_fetch(&type, &field, 1, 0); + if (_4$$4) { + _4$$4 = !ZEPHIR_IS_STRING(&type, ""); + } + if (_4$$4) { + ZEPHIR_INIT_NVAR(&_5$$6); + ZEPHIR_CONCAT_SV(&_5$$6, " ", &type); + zephir_concat_self(&fieldSql, &_5$$6); + } + zephir_array_append(&fields, &fieldSql, PH_SEPARATE, "phalcon/Db/Dialect.zep", 1065); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CPY_WRT(&mergedPaths, &defaultPaths); + ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, expression, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&field, expression, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-ORDER-BY expression", "phalcon/Db/Dialect.zep", 1049); + return; + } + zephir_array_fetch_long(&_6$$7, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1053); + ZEPHIR_CALL_METHOD(&fieldSql, this_ptr, "getsqlexpression", &_3, 49, &_6$$7, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&type); + _7$$7 = zephir_array_isset_long_fetch(&type, &field, 1, 0); + if (_7$$7) { + _7$$7 = !ZEPHIR_IS_STRING(&type, ""); + } + if (_7$$7) { + ZEPHIR_INIT_NVAR(&_8$$9); + ZEPHIR_CONCAT_SV(&_8$$9, " ", &type); + zephir_concat_self(&fieldSql, &_8$$9); + } + zephir_array_append(&fields, &fieldSql, PH_SEPARATE, "phalcon/Db/Dialect.zep", 1065); + ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_VAR(&_9$$3); + zephir_fast_join_str(&_9$$3, SL(", "), &fields); + ZEPHIR_CPY_WRT(&fields, &_9$$3); } else { - ZEPHIR_CPY_WRT(&mergedPaths, paths); + ZEPHIR_CPY_WRT(&fields, expression); } - ZEPHIR_INIT_VAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VV(&_2, &_1, &pattern); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 100, &_2, &mergedPaths, httpMethods); - zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("routes"), &route); - ZEPHIR_CALL_METHOD(NULL, &route, "setgroup", NULL, 488, this_ptr); - zephir_check_call_status(); - RETURN_CCTOR(&route); + ZEPHIR_CONCAT_SV(return_value, "ORDER BY ", &fields); + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router_Group(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionQualified) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_GroupInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, GroupInterface, phalcon, mvc_router_groupinterface, phalcon_mvc_router_groupinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, add); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addConnect); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addDelete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addGet); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addHead); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPost); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPurge); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPut); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addTrace); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, beforeMatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getBeforeMatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getPrefix); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getRoutes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPrefix); - - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, column, domain; + zval expression; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&escapeChar); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &expression_param, &escapeChar_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Route) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Route, phalcon, mvc_router_route, phalcon_mvc_router_route_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("compiledPattern"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("converters"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("group"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("hostname"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("id"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("methods"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("match"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("paths"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("pattern"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_router_route_ce, SL("uniqueId"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - phalcon_mvc_router_route_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Route; - - zend_class_implements(phalcon_mvc_router_route_ce, 1, phalcon_mvc_router_routeinterface_ce); - return SUCCESS; + ZEPHIR_OBS_VAR(&column); + zephir_array_fetch_string(&column, &expression, SL("name"), PH_NOISY, "phalcon/Db/Dialect.zep", 1083); + ZEPHIR_OBS_VAR(&domain); + if (!(zephir_array_isset_string_fetch(&domain, &expression, SL("domain"), 0))) { + ZEPHIR_INIT_NVAR(&domain); + ZVAL_NULL(&domain); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, &column, &domain, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, __construct) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null, routeId, uniqueId, _0; - zval pattern; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, value, _0$$3; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&routeId); - ZVAL_UNDEF(&uniqueId); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + Z_PARAM_ARRAY(expression) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_get_strval(&escapeChar, escapeChar_param); } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, &pattern, paths); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "via", NULL, 0, httpMethods); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&_0); - zephir_read_static_property_ce(&_0, phalcon_mvc_router_route_ce, SL("uniqueId"), PH_NOISY_CC); - ZEPHIR_CPY_WRT(&uniqueId, &_0); - ZEPHIR_CPY_WRT(&routeId, &uniqueId); - zephir_update_property_zval(this_ptr, ZEND_STRL("id"), &routeId); - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, (zephir_get_numberval(&uniqueId) + 1)); - zephir_update_static_property_ce(phalcon_mvc_router_route_ce, ZEND_STRL("uniqueId"), &_0); - ZEPHIR_MM_RESTORE(); + if (zephir_array_isset_string(&expression, SL("column"))) { + zephir_array_fetch_string(&_0$$3, &expression, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1107); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlcolumn", NULL, 43, &_0$$3); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_OBS_VAR(&value); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &expression, SL("value"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL expression", "phalcon/Db/Dialect.zep", 1111); + return; + } + if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpression", NULL, 0, &value, &escapeChar, &bindCounts); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, beforeMatch) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionUnaryOperations) { - zval *callback, callback_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval escapeChar; + zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0$$3, _1$$3, _2$$4, _3$$4; + zval expression, bindCounts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&callback_sub); + ZVAL_UNDEF(&expression); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&left); + ZVAL_UNDEF(&right); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&escapeChar); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(callback) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &callback); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); + ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), callback); - RETURN_THISW(); + ZEPHIR_OBS_VAR(&left); + if (zephir_array_isset_string_fetch(&left, &expression, SL("left"), 0)) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getsqlexpression", NULL, 0, &left, &escapeChar, &bindCounts); + zephir_check_call_status(); + zephir_array_fetch_string(&_1$$3, &expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1138); + ZEPHIR_CONCAT_VSV(return_value, &_0$$3, " ", &_1$$3); + RETURN_MM(); + } + ZEPHIR_OBS_VAR(&right); + if (zephir_array_isset_string_fetch(&right, &expression, SL("right"), 0)) { + zephir_array_fetch_string(&_2$$4, &expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1145); + ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "getsqlexpression", NULL, 49, &right, &escapeChar, &bindCounts); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &_2$$4, " ", &_3$$4); + RETURN_MM(); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-unary expression", "phalcon/Db/Dialect.zep", 1148); + return; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, compilePattern) +static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionWhere) { - zend_bool _14; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *pattern_param = NULL, _0$$4, _1$$4, _2$$5, _3$$5, _4$$6, _5$$6, _6$$7, _7$$7, _8$$8, _9$$8, _10$$8, _11$$9, _12$$9, _13$$9; - zval pattern, idPattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval bindCounts; + zval escapeChar; + zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, whereSql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&idPattern); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$8); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&expression_sub); + ZVAL_UNDEF(&whereSql); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&bindCounts); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(expression) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_ARRAY(bindCounts) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &pattern_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (!bindCounts_param) { + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); } - if (zephir_memnstr_str(&pattern, SL(":"), "phalcon/Mvc/Router/Route.zep", 141)) { - ZEPHIR_INIT_VAR(&idPattern); - ZVAL_STRING(&idPattern, "/([\\w0-9\\_\\-]+)"); - if (zephir_memnstr_str(&pattern, SL("/:module"), "phalcon/Mvc/Router/Route.zep", 146)) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "/:module"); - zephir_fast_str_replace(&_0$$4, &_1$$4, &idPattern, &pattern); - zephir_get_strval(&pattern, &_0$$4); - } - if (zephir_memnstr_str(&pattern, SL("/:controller"), "phalcon/Mvc/Router/Route.zep", 151)) { - ZEPHIR_INIT_VAR(&_2$$5); - ZEPHIR_INIT_VAR(&_3$$5); - ZVAL_STRING(&_3$$5, "/:controller"); - zephir_fast_str_replace(&_2$$5, &_3$$5, &idPattern, &pattern); - zephir_get_strval(&pattern, &_2$$5); - } - if (zephir_memnstr_str(&pattern, SL("/:namespace"), "phalcon/Mvc/Router/Route.zep", 156)) { - ZEPHIR_INIT_VAR(&_4$$6); - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "/:namespace"); - zephir_fast_str_replace(&_4$$6, &_5$$6, &idPattern, &pattern); - zephir_get_strval(&pattern, &_4$$6); - } - if (zephir_memnstr_str(&pattern, SL("/:action"), "phalcon/Mvc/Router/Route.zep", 161)) { - ZEPHIR_INIT_VAR(&_6$$7); - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_STRING(&_7$$7, "/:action"); - zephir_fast_str_replace(&_6$$7, &_7$$7, &idPattern, &pattern); - zephir_get_strval(&pattern, &_6$$7); - } - if (zephir_memnstr_str(&pattern, SL("/:params"), "phalcon/Mvc/Router/Route.zep", 166)) { - ZEPHIR_INIT_VAR(&_8$$8); - ZEPHIR_INIT_VAR(&_9$$8); - ZVAL_STRING(&_9$$8, "/:params"); - ZEPHIR_INIT_VAR(&_10$$8); - ZVAL_STRING(&_10$$8, "(/.*)*"); - zephir_fast_str_replace(&_8$$8, &_9$$8, &_10$$8, &pattern); - zephir_get_strval(&pattern, &_8$$8); - } - if (zephir_memnstr_str(&pattern, SL("/:int"), "phalcon/Mvc/Router/Route.zep", 171)) { - ZEPHIR_INIT_VAR(&_11$$9); - ZEPHIR_INIT_VAR(&_12$$9); - ZVAL_STRING(&_12$$9, "/:int"); - ZEPHIR_INIT_VAR(&_13$$9); - ZVAL_STRING(&_13$$9, "/([0-9]+)"); - zephir_fast_str_replace(&_11$$9, &_12$$9, &_13$$9, &pattern); - zephir_get_strval(&pattern, &_11$$9); - } - } - _14 = zephir_memnstr_str(&pattern, SL("("), "phalcon/Mvc/Router/Route.zep", 182); - if (!(_14)) { - _14 = zephir_memnstr_str(&pattern, SL("["), "phalcon/Mvc/Router/Route.zep", 182); - } - if (_14) { - ZEPHIR_CONCAT_SVS(return_value, "#^", &pattern, "$#u"); - RETURN_MM(); + if (Z_TYPE_P(expression) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&whereSql, this_ptr, "getsqlexpression", NULL, 0, expression, &escapeChar, &bindCounts); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&whereSql, expression); } - RETURN_CTOR(&pattern); + ZEPHIR_CONCAT_SV(return_value, "WHERE ", &whereSql); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, convert) +static PHP_METHOD(Phalcon_Db_Dialect, prepareColumnAlias) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *converter, converter_sub; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *qualified_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, _0$$3; + zval qualified, alias, escapeChar; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&converter_sub); + ZVAL_UNDEF(&qualified); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&_0$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(converter) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(qualified) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(escapeChar) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &name_param, &converter); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 1, 2, &qualified_param, &alias_param, &escapeChar_param); + if (UNEXPECTED(Z_TYPE_P(qualified_param) != IS_STRING && Z_TYPE_P(qualified_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'qualified' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(qualified_param) == IS_STRING)) { + zephir_get_strval(&qualified, qualified_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&qualified); + } + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); + } else { + zephir_get_strval(&alias, alias_param); + } + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); } - zephir_update_property_array(this_ptr, SL("converters"), &name, converter); - RETURN_THIS(); + if (!ZEPHIR_IS_STRING(&alias, "")) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "escape", NULL, 56, &alias, &escapeChar); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &qualified, " AS ", &_0$$3); + RETURN_MM(); + } + RETURN_CTOR(&qualified); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, extractNamedParams) +static PHP_METHOD(Phalcon_Db_Dialect, prepareTable) { - long _0, _5$$10, _26$$18; - zend_long cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; - zend_bool notValid = 0, _6$$11, _7$$11, _8$$11, _9$$11, _10$$11, _11$$11, _12$$11, _13$$11, _14$$11, _15$$11, _16$$11, _17$$11, _25$$17, _29$$34, _30$$35, _31$$35, _32$$35; - char ch = 0, prevCh; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *pattern_param = NULL, tmp, matches, _1$$10, _2$$10, _3$$10, _18$$15, _19$$15, _20$$15, _22$$15, _23$$15; - zval pattern, route, item, variable, regexp, _4$$10, _21$$15, _24$$15, _27$$25, _28$$28; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, _0, _1$$3, _2$$3, _3$$4, _4$$4; + zval table, schema, alias, escapeChar; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&variable); - ZVAL_UNDEF(®exp); - ZVAL_UNDEF(&_4$$10); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_24$$15); - ZVAL_UNDEF(&_27$$25); - ZVAL_UNDEF(&_28$$28); - ZVAL_UNDEF(&tmp); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&_1$$10); - ZVAL_UNDEF(&_2$$10); - ZVAL_UNDEF(&_3$$10); - ZVAL_UNDEF(&_18$$15); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_20$$15); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_23$$15); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + Z_PARAM_STR_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(escapeChar) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &pattern_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 3, &table_param, &schema_param, &alias_param, &escapeChar_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); + } + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); + } else { + zephir_get_strval(&alias, alias_param); + } + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); } - prevCh = '\0'; - bracketCount = 0; - parenthesesCount = 0; - foundPattern = 0; - intermediate = 0; - numberMatches = 0; - if (zephir_fast_strlen_ev(&pattern) == 0) { - RETURN_MM_BOOL(0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "escape", NULL, 56, &table, &escapeChar); + zephir_check_call_status(); + zephir_get_strval(&table, &_0); + if (!ZEPHIR_IS_STRING(&schema, "")) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "escapeschema", NULL, 66, &schema, &escapeChar); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_VSV(&_2$$3, &_1$$3, ".", &table); + zephir_get_strval(&table, &_2$$3); } - ZEPHIR_INIT_VAR(&matches); - array_init(&matches); - ZEPHIR_INIT_VAR(&route); - for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { - cursor = _0; - ch = ZEPHIR_STRING_OFFSET(&pattern, _0); - if (parenthesesCount == 0) { - if (ch == '{') { - if (bracketCount == 0) { - marker = (cursor + 1); - intermediate = 0; - notValid = 0; - } - bracketCount++; - } else if (ch == '}') { - bracketCount--; - if (intermediate > 0) { - if (bracketCount == 0) { - numberMatches++; - ZEPHIR_INIT_NVAR(&variable); - ZEPHIR_INIT_NVAR(®exp); - ZVAL_LONG(&_1$$10, marker); - ZVAL_LONG(&_2$$10, (cursor - marker)); - ZEPHIR_INIT_NVAR(&_3$$10); - zephir_substr(&_3$$10, &pattern, zephir_get_intval(&_1$$10), zephir_get_intval(&_2$$10), 0); - zephir_cast_to_string(&_4$$10, &_3$$10); - ZEPHIR_CPY_WRT(&item, &_4$$10); - for (_5$$10 = 0; _5$$10 < Z_STRLEN_P(&item); _5$$10++) { - cursorVar = _5$$10; - ch = ZEPHIR_STRING_OFFSET(&item, _5$$10); - if (ch == '\0') { - break; - } - _6$$11 = cursorVar == 0; - if (_6$$11) { - _7$$11 = ch >= 'a'; - if (_7$$11) { - _7$$11 = ch <= 'z'; - } - _8$$11 = _7$$11; - if (!(_8$$11)) { - _9$$11 = ch >= 'A'; - if (_9$$11) { - _9$$11 = ch <= 'Z'; - } - _8$$11 = _9$$11; - } - _6$$11 = !(_8$$11); - } - if (_6$$11) { - notValid = 1; - break; - } - _10$$11 = ch >= 'a'; - if (_10$$11) { - _10$$11 = ch <= 'z'; - } - _11$$11 = _10$$11; - if (!(_11$$11)) { - _12$$11 = ch >= 'A'; - if (_12$$11) { - _12$$11 = ch <= 'Z'; - } - _11$$11 = _12$$11; - } - _13$$11 = _11$$11; - if (!(_13$$11)) { - _14$$11 = ch >= '0'; - if (_14$$11) { - _14$$11 = ch <= '9'; - } - _13$$11 = _14$$11; - } - _15$$11 = _13$$11; - if (!(_15$$11)) { - _15$$11 = ch == '-'; - } - _16$$11 = _15$$11; - if (!(_16$$11)) { - _16$$11 = ch == '_'; - } - _17$$11 = _16$$11; - if (!(_17$$11)) { - _17$$11 = ch == ':'; - } - if (_17$$11) { - if (ch == ':') { - ZVAL_LONG(&_18$$15, 0); - ZVAL_LONG(&_19$$15, cursorVar); - ZEPHIR_INIT_NVAR(&_20$$15); - zephir_substr(&_20$$15, &item, 0 , zephir_get_intval(&_19$$15), 0); - zephir_cast_to_string(&_21$$15, &_20$$15); - ZEPHIR_CPY_WRT(&variable, &_21$$15); - ZVAL_LONG(&_22$$15, (cursorVar + 1)); - ZEPHIR_INIT_NVAR(&_23$$15); - zephir_substr(&_23$$15, &item, zephir_get_intval(&_22$$15), 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_cast_to_string(&_24$$15, &_23$$15); - ZEPHIR_CPY_WRT(®exp, &_24$$15); - break; - } - } else { - notValid = 1; - break; - } - } - if (!(notValid)) { - ZEPHIR_INIT_NVAR(&tmp); - ZVAL_LONG(&tmp, numberMatches); - _25$$17 = zephir_is_true(&variable); - if (_25$$17) { - _25$$17 = zephir_is_true(®exp); - } - if (_25$$17) { - foundPattern = 0; - for (_26$$18 = 0; _26$$18 < Z_STRLEN_P(®exp); _26$$18++) { - ch = ZEPHIR_STRING_OFFSET(®exp, _26$$18); - if (ch == '\0') { - break; - } - if (!(foundPattern)) { - if (ch == '(') { - foundPattern = 1; - } - } else { - if (ch == ')') { - foundPattern = 2; - break; - } - } - } - if (foundPattern != 2) { - ZEPHIR_INIT_NVAR(&_27$$25); - ZEPHIR_CONCAT_SVS(&_27$$25, "(", ®exp, ")"); - zephir_concat_self(&route, &_27$$25); - } else { - zephir_concat_self(&route, ®exp); - } - zephir_array_update_zval(&matches, &variable, &tmp, PH_COPY | PH_SEPARATE); - } else { - zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)") - 1); - zephir_array_update_zval(&matches, &item, &tmp, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_INIT_NVAR(&_28$$28); - ZEPHIR_CONCAT_SVS(&_28$$28, "{", &item, "}"); - zephir_concat_self(&route, &_28$$28); - } - continue; - } - } - } - } - if (bracketCount == 0) { - if (ch == '(') { - parenthesesCount++; - } else if (ch == ')') { - parenthesesCount--; - if (parenthesesCount == 0) { - numberMatches++; - } - } - } - if (bracketCount > 0) { - intermediate++; - } else { - _29$$34 = parenthesesCount == 0; - if (_29$$34) { - _29$$34 = prevCh != '\\'; - } - if (_29$$34) { - _30$$35 = ch == '.'; - if (!(_30$$35)) { - _30$$35 = ch == '+'; - } - _31$$35 = _30$$35; - if (!(_31$$35)) { - _31$$35 = ch == '|'; - } - _32$$35 = _31$$35; - if (!(_32$$35)) { - _32$$35 = ch == '#'; - } - if (_32$$35) { - zephir_concat_self_str(&route, "\\", sizeof("\\") - 1); - } - } - zephir_concat_self_char(&route, ch); - prevCh = ch; - } + if (!ZEPHIR_IS_STRING(&alias, "")) { + ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "escape", NULL, 56, &alias, &escapeChar); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$4); + ZEPHIR_CONCAT_VSV(&_4$$4, &table, " AS ", &_3$$4); + zephir_get_strval(&table, &_4$$4); } - zephir_create_array(return_value, 2, 0); - zephir_array_fast_append(return_value, &route); - zephir_array_fast_append(return_value, &matches); - RETURN_MM(); + RETURN_CTOR(&table); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getBeforeMatch) +static PHP_METHOD(Phalcon_Db_Dialect, prepareQualified) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column_param = NULL, *domain_param = NULL, *escapeChar_param = NULL; + zval column, domain, escapeChar, _0$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&_0$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(column) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(domain) + Z_PARAM_STR_OR_NULL(escapeChar) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "beforeMatch"); -} - -static PHP_METHOD(Phalcon_Mvc_Router_Route, getCompiledPattern) -{ - zval *this_ptr = getThis(); - + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &column_param, &domain_param, &escapeChar_param); + if (UNEXPECTED(Z_TYPE_P(column_param) != IS_STRING && Z_TYPE_P(column_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'column' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(column_param) == IS_STRING)) { + zephir_get_strval(&column, column_param); + } else { + ZEPHIR_INIT_VAR(&column); + } + if (!domain_param) { + ZEPHIR_INIT_VAR(&domain); + } else { + zephir_get_strval(&domain, domain_param); + } + if (!escapeChar_param) { + ZEPHIR_INIT_VAR(&escapeChar); + } else { + zephir_get_strval(&escapeChar, escapeChar_param); + } - RETURN_MEMBER(getThis(), "compiledPattern"); + if (!ZEPHIR_IS_STRING(&domain, "")) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_VSV(&_0$$3, &domain, ".", &column); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 56, &_0$$3, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 56, &column, &escapeChar); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getConverters) +zend_object *zephir_init_properties_Phalcon_Db_Dialect(zend_class_entry *class_type) { - zval *this_ptr = getThis(); - - + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - RETURN_MEMBER(getThis(), "converters"); + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("customFunctions"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("customFunctions"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getGroup) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "group"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Router_Route, getHttpMethods) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "methods"); -} -static PHP_METHOD(Phalcon_Mvc_Router_Route, getHostname) +ZEPHIR_INIT_CLASS(Phalcon_Db_DialectInterface) { - zval *this_ptr = getThis(); - - + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, DialectInterface, phalcon, db_dialectinterface, phalcon_db_dialectinterface_method_entry); - RETURN_MEMBER(getThis(), "hostname"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getId) -{ - zval *this_ptr = getThis(); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addForeignKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addIndex); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addPrimaryKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createSavepoint); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createTable); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createView); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeColumns); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeIndexes); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeReferences); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropForeignKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropIndex); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropPrimaryKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropTable); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropView); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, forUpdate); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getColumnDefinition); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getColumnList); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getCustomFunctions); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getSqlExpression); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, limit); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, listTables); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, modifyColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, registerCustomFunction); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, releaseSavepoint); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, rollbackSavepoint); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, select); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, sharedLock); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, supportsReleaseSavepoints); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, supportsSavepoints); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, tableExists); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, tableOptions); +ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, viewExists); - RETURN_MEMBER(getThis(), "id"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Router_Route, getMatch) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "match"); -} -static PHP_METHOD(Phalcon_Mvc_Router_Route, getName) +ZEPHIR_INIT_CLASS(Phalcon_Db_Enum) { - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Enum, phalcon, db_enum, NULL, 0); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_ASSOC"), 2); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_BOTH"), 4); - RETURN_MEMBER(getThis(), "name"); -} + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_BOUND"), 6); -static PHP_METHOD(Phalcon_Mvc_Router_Route, getPaths) -{ - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_CLASS"), 8); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_CLASSTYPE"), 262144); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_COLUMN"), 7); - RETURN_MEMBER(getThis(), "paths"); -} + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_FUNC"), 10); -static PHP_METHOD(Phalcon_Mvc_Router_Route, getPattern) -{ - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_GROUP"), 65536); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_INTO"), 9); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_KEY_PAIR"), 12); - RETURN_MEMBER(getThis(), "pattern"); -} + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_LAZY"), 1); -static PHP_METHOD(Phalcon_Mvc_Router_Route, getReversedPaths) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_NAMED"), 11); - ZVAL_UNDEF(&_0); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_NUM"), 3); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_OBJ"), 5); - ZEPHIR_MM_GROW(); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_ORI_NEXT"), 0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("array_flip", NULL, 99, &_0); - zephir_check_call_status(); - RETURN_MM(); -} + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_PROPS_LATE"), 1048576); -static PHP_METHOD(Phalcon_Mvc_Router_Route, getRouteId) -{ - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_SERIALIZE"), 524288); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_UNIQUE"), 196608); + zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_DEFAULT"), 0); - RETURN_MEMBER(getThis(), "id"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getRoutePaths) -{ - zend_long _0$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paths = NULL, paths_sub, __$null, moduleName, controllerName, actionName, parts, routePaths, realClassName, namespaceName; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&routePaths); - ZVAL_UNDEF(&realClassName); - ZVAL_UNDEF(&namespaceName); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &paths); - if (!paths) { - paths = &paths_sub; - ZEPHIR_CPY_WRT(paths, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(paths); - } - if (Z_TYPE_P(paths) == IS_NULL) { - ZEPHIR_INIT_NVAR(paths); - array_init(paths); - } - if (Z_TYPE_P(paths) == IS_STRING) { - ZEPHIR_INIT_VAR(&moduleName); - ZVAL_NULL(&moduleName); - ZEPHIR_INIT_VAR(&controllerName); - ZVAL_NULL(&controllerName); - ZEPHIR_INIT_VAR(&actionName); - ZVAL_NULL(&actionName); - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("::"), paths, LONG_MAX); - do { - _0$$4 = zephir_fast_count_int(&parts); - if (_0$$4 == 3) { - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_fetch_long(&moduleName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 467); - ZEPHIR_OBS_NVAR(&controllerName); - zephir_array_fetch_long(&controllerName, &parts, 1, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 468); - ZEPHIR_OBS_NVAR(&actionName); - zephir_array_fetch_long(&actionName, &parts, 2, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 469); - break; - } - if (_0$$4 == 2) { - ZEPHIR_OBS_NVAR(&controllerName); - zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 473); - ZEPHIR_OBS_NVAR(&actionName); - zephir_array_fetch_long(&actionName, &parts, 1, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 474); - break; - } - if (_0$$4 == 1) { - ZEPHIR_OBS_NVAR(&controllerName); - zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 478); - break; - } - } while(0); - ZEPHIR_INIT_VAR(&routePaths); - array_init(&routePaths); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&controllerName) != IS_NULL) { - if (zephir_memnstr_str(&controllerName, SL("\\"), "phalcon/Mvc/Router/Route.zep", 492)) { - ZEPHIR_INIT_VAR(&realClassName); - zephir_get_class_ns(&realClassName, &controllerName, 0); - ZEPHIR_INIT_VAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &controllerName, 0); - if (zephir_is_true(&namespaceName)) { - zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_CPY_WRT(&realClassName, &controllerName); - } - zephir_array_update_string(&routePaths, SL("controller"), &realClassName, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&actionName) != IS_NULL) { - zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_CPY_WRT(&routePaths, paths); - } - if (UNEXPECTED(Z_TYPE_P(&routePaths) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The route contains invalid paths", "phalcon/Mvc/Router/Route.zep", 519); - return; - } - RETURN_CCTOR(&routePaths); +ZEPHIR_INIT_CLASS(Phalcon_Db_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db, Exception, phalcon, db_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, match) -{ - zval *callback, callback_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&callback_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(callback) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - zephir_fetch_params_without_memory_grow(1, 0, &callback); - zephir_update_property_zval(this_ptr, ZEND_STRL("match"), callback); - RETURN_THISW(); + +ZEPHIR_INIT_CLASS(Phalcon_Db_Index) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Index, phalcon, db_index, phalcon_db_index_method_entry, 0); + + zend_declare_property_null(phalcon_db_index_ce, SL("columns"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_index_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_index_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_db_index_ce, 1, phalcon_db_indexinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, reConfigure) +static PHP_METHOD(Phalcon_Db_Index, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, routePaths, pcrePattern, compiledPattern, extracted, _0$$4, _1$$4; - zval pattern; + zval columns; + zval *name_param = NULL, *columns_param = NULL, *type_param = NULL; + zval name, type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&routePaths); - ZVAL_UNDEF(&pcrePattern); - ZVAL_UNDEF(&compiledPattern); - ZVAL_UNDEF(&extracted); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&columns); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(name) + Z_PARAM_ARRAY(columns) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 2, 1, &name_param, &columns_param, &type_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&name); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_OBS_COPY_OR_DUP(&columns, columns_param); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); + ZVAL_STRING(&type, ""); + } else { + zephir_get_strval(&type, type_param); } - ZEPHIR_CALL_SELF(&routePaths, "getroutepaths", NULL, 0, paths); - zephir_check_call_status(); - if (!(zephir_start_with_str(&pattern, SL("#")))) { - if (zephir_memnstr_str(&pattern, SL("{"), "phalcon/Mvc/Router/Route.zep", 559)) { - ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, &pattern); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&pcrePattern); - zephir_array_fetch_long(&pcrePattern, &extracted, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 564); - ZEPHIR_INIT_VAR(&_0$$4); - zephir_array_fetch_long(&_1$$4, &extracted, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router/Route.zep", 565); - zephir_fast_array_merge(&_0$$4, &routePaths, &_1$$4); - ZEPHIR_CPY_WRT(&routePaths, &_0$$4); - } else { - ZEPHIR_CPY_WRT(&pcrePattern, &pattern); - } - ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, &pcrePattern); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&compiledPattern, &pattern); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("pattern"), &pattern); - zephir_update_property_zval(this_ptr, ZEND_STRL("compiledPattern"), &compiledPattern); - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), &routePaths); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, reset) +static PHP_METHOD(Phalcon_Db_Index, getColumns) { - zval _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, 0); - zephir_update_static_property_ce(phalcon_mvc_router_route_ce, ZEND_STRL("uniqueId"), &_0); + RETURN_MEMBER(getThis(), "columns"); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setGroup) +static PHP_METHOD(Phalcon_Db_Index, getName) { - zval *group, group_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&group_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(group, phalcon_mvc_router_groupinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - zephir_fetch_params_without_memory_grow(1, 0, &group); - zephir_update_property_zval(this_ptr, ZEND_STRL("group"), group); - RETURN_THISW(); + RETURN_MEMBER(getThis(), "name"); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setHttpMethods) +static PHP_METHOD(Phalcon_Db_Index, getType) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *httpMethods, httpMethods_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&httpMethods_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(httpMethods) - ZEND_PARSE_PARAMETERS_END(); + + + RETURN_MEMBER(getThis(), "type"); +} + + + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &httpMethods); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "via", NULL, 0, httpMethods); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Router_Route, setHostname) +ZEPHIR_INIT_CLASS(Phalcon_Db_IndexInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *hostname_param = NULL; - zval hostname; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, IndexInterface, phalcon, db_indexinterface, phalcon_db_indexinterface_method_entry); - ZVAL_UNDEF(&hostname); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(hostname) - ZEND_PARSE_PARAMETERS_END(); + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getColumns); +ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getType); + + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &hostname_param); - if (UNEXPECTED(Z_TYPE_P(hostname_param) != IS_STRING && Z_TYPE_P(hostname_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hostname' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(hostname_param) == IS_STRING)) { - zephir_get_strval(&hostname, hostname_param); - } else { - ZEPHIR_INIT_VAR(&hostname); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("hostname"), &hostname); - RETURN_THIS(); + +ZEPHIR_INIT_CLASS(Phalcon_Db_Profiler) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Profiler, phalcon, db_profiler, phalcon_db_profiler_method_entry, 0); + + zend_declare_property_null(phalcon_db_profiler_ce, SL("activeProfile"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_profiler_ce, SL("allProfiles"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_profiler_ce, SL("totalNanoseconds"), 0, ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setName) +static PHP_METHOD(Phalcon_Db_Profiler, getLastProfile) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); + RETURN_MEMBER(getThis(), "activeProfile"); +} +static PHP_METHOD(Phalcon_Db_Profiler, getNumberTotalStatements) +{ + zval _0; + zval *this_ptr = getThis(); - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - RETURN_THIS(); + ZVAL_UNDEF(&_0); + + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("allProfiles"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, via) +static PHP_METHOD(Phalcon_Db_Profiler, getTotalElapsedNanoseconds) { - zval *httpMethods, httpMethods_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&httpMethods_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(httpMethods) - ZEND_PARSE_PARAMETERS_END(); -#endif - zephir_fetch_params_without_memory_grow(1, 0, &httpMethods); + RETURN_MEMBER(getThis(), "totalNanoseconds"); +} +static PHP_METHOD(Phalcon_Db_Profiler, getTotalElapsedMilliseconds) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - zephir_update_property_zval(this_ptr, ZEND_STRL("methods"), httpMethods); - RETURN_THISW(); + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettotalelapsednanoseconds", NULL, 0); + zephir_check_call_status(); + RETURN_MM_DOUBLE(zephir_safe_div_zval_long(&_0, 1000000)); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router_Route(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Profiler, getTotalElapsedSeconds) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("paths"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methods"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("converters"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("converters"), &_5$$5); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_RouteInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, RouteInterface, phalcon, mvc_router_routeinterface, phalcon_mvc_router_routeinterface_method_entry); + ZEPHIR_MM_GROW(); - return SUCCESS; + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettotalelapsedmilliseconds", NULL, 0); + zephir_check_call_status(); + RETURN_MM_DOUBLE(zephir_safe_div_zval_long(&_0, 1000)); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, compilePattern); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, convert); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getCompiledPattern); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHttpMethods); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPattern); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getReversedPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getRouteId); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHttpMethods); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reConfigure); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, via); - - - -#ifdef HAVE_CONFIG_H -#endif - - - +static PHP_METHOD(Phalcon_Db_Profiler, getProfiles) +{ + zval *this_ptr = getThis(); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Behavior, phalcon, mvc_model_behavior, phalcon_mvc_model_behavior_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(phalcon_mvc_model_behavior_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_model_behavior_ce, 1, phalcon_mvc_model_behaviorinterface_ce); - return SUCCESS; + RETURN_MEMBER(getThis(), "allProfiles"); } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, __construct) +static PHP_METHOD(Phalcon_Db_Profiler, reset) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; - zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("allProfiles"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, getOptions) +static PHP_METHOD(Phalcon_Db_Profiler, startProfile) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *eventName_param = NULL, options, eventOptions, _0; - zval eventName; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval sqlVariables, sqlBindTypes; + zval *sqlStatement_param = NULL, *sqlVariables_param = NULL, *sqlBindTypes_param = NULL, __$true, activeProfile, _0; + zval sqlStatement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&eventOptions); + ZVAL_UNDEF(&sqlStatement); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&activeProfile); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&sqlVariables); + ZVAL_UNDEF(&sqlBindTypes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(sqlStatement) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(eventName) + Z_PARAM_ARRAY(sqlVariables) + Z_PARAM_ARRAY(sqlBindTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &eventName_param); - if (!eventName_param) { - ZEPHIR_INIT_VAR(&eventName); + zephir_fetch_params(1, 1, 2, &sqlStatement_param, &sqlVariables_param, &sqlBindTypes_param); + zephir_get_strval(&sqlStatement, sqlStatement_param); + if (!sqlVariables_param) { + ZEPHIR_INIT_VAR(&sqlVariables); + array_init(&sqlVariables); } else { - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_arrval(&sqlVariables, sqlVariables_param); } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); + if (!sqlBindTypes_param) { + ZEPHIR_INIT_VAR(&sqlBindTypes); + array_init(&sqlBindTypes); } else { - ZEPHIR_INIT_VAR(&eventName); - } + zephir_get_arrval(&sqlBindTypes, sqlBindTypes_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - if (!ZEPHIR_IS_NULL(&eventName)) { - if (!(zephir_array_isset_fetch(&eventOptions, &options, &eventName, 1))) { - RETURN_MM_NULL(); - } - RETURN_CTOR(&eventOptions); + ZEPHIR_INIT_VAR(&activeProfile); + object_init_ex(&activeProfile, phalcon_db_profiler_item_ce); + if (zephir_has_constructor(&activeProfile)) { + ZEPHIR_CALL_METHOD(NULL, &activeProfile, "__construct", NULL, 0); + zephir_check_call_status(); } - RETURN_CCTOR(&options); + + ZEPHIR_CALL_METHOD(NULL, &activeProfile, "setsqlstatement", NULL, 217, &sqlStatement); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &activeProfile, "setsqlvariables", NULL, 218, &sqlVariables); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &activeProfile, "setsqlbindtypes", NULL, 219, &sqlBindTypes); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_0, "hrtime", NULL, 202, &__$true); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &activeProfile, "setinitialtime", NULL, 220, &_0); + zephir_check_call_status(); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("beforestartprofile")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "beforestartprofile", NULL, 0, &activeProfile); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("activeProfile"), &activeProfile); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, missingMethod) +static PHP_METHOD(Phalcon_Db_Profiler, stopProfile) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval arguments; - zval method; - zval *model, model_sub, *method_param = NULL, *arguments_param = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval __$true, activeProfile, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&arguments); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(method) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(arguments) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&activeProfile); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &model, &method_param, &arguments_param); - zephir_get_strval(&method, method_param); - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); - } else { - zephir_get_arrval(&arguments, arguments_param); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("activeProfile"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&activeProfile, &_0); + ZEPHIR_CALL_FUNCTION(&_1, "hrtime", NULL, 202, &__$true); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &activeProfile, "setfinaltime", NULL, 0, &_1); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("totalNanoseconds"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &activeProfile, "gettotalelapsednanoseconds", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + zephir_add_function(&_3, &_0, &_2); + zephir_update_property_zval(this_ptr, ZEND_STRL("totalNanoseconds"), &_3); + zephir_update_property_array_append(this_ptr, SL("allProfiles"), &activeProfile); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("afterendprofile")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "afterendprofile", NULL, 0, &activeProfile); + zephir_check_call_status(); } + RETURN_THIS(); +} - RETURN_MM_NULL(); -} -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, mustTakeAction) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *eventName_param = NULL, _0; - zval eventName; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(eventName) - ZEND_PARSE_PARAMETERS_END(); +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &eventName_param); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &eventName)); + +ZEPHIR_INIT_CLASS(Phalcon_Db_RawValue) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, RawValue, phalcon, db_rawvalue, phalcon_db_rawvalue_method_entry, 0); + + zend_declare_property_null(phalcon_db_rawvalue_ce, SL("value"), ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, notify) +static PHP_METHOD(Phalcon_Db_RawValue, __construct) { + zval _2$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL, *model, model_sub; - zval type; + zval *value, value_sub, _0$$3, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &type_param, &model); - zephir_get_strval(&type, type_param); + zephir_fetch_params(1, 1, 0, &value); - RETURN_MM_NULL(); + if (ZEPHIR_IS_STRING_IDENTICAL(value, "")) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_INIT_NVAR(&_0$$3); + ZVAL_STRING(&_0$$3, "''"); + zephir_update_property_zval(this_ptr, ZEND_STRL("value"), &_0$$3); + } else if (Z_TYPE_P(value) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$4); + ZEPHIR_INIT_NVAR(&_1$$4); + ZVAL_STRING(&_1$$4, "NULL"); + zephir_update_property_zval(this_ptr, ZEND_STRL("value"), &_1$$4); + } else { + zephir_cast_to_string(&_2$$5, value); + zephir_update_property_zval(this_ptr, ZEND_STRL("value"), &_2$$5); + } + ZEPHIR_MM_RESTORE(); } +static PHP_METHOD(Phalcon_Db_RawValue, __toString) +{ + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - + RETURN_MEMBER(getThis(), "value"); +} +static PHP_METHOD(Phalcon_Db_RawValue, getValue) +{ + zval *this_ptr = getThis(); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BehaviorInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BehaviorInterface, phalcon, mvc_model_behaviorinterface, phalcon_mvc_model_behaviorinterface_method_entry); - return SUCCESS; + RETURN_MEMBER(getThis(), "value"); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, missingMethod); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, notify); @@ -63873,605 +57756,201 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, notify); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Binder) +ZEPHIR_INIT_CLASS(Phalcon_Db_Reference) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Binder, phalcon, mvc_model_binder, phalcon_mvc_model_binder_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("boundModels"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("cache"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("internalCache"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("originalValues"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_binder_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Binder; + ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Reference, phalcon, db_reference, phalcon_db_reference_method_entry, 0); - zend_class_implements(phalcon_mvc_model_binder_ce, 1, phalcon_mvc_model_binderinterface_ce); + zend_declare_property_null(phalcon_db_reference_ce, SL("columns"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("referencedColumns"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("referencedSchema"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("referencedTable"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("schemaName"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("onDelete"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_reference_ce, SL("onUpdate"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_db_reference_ce, 1, phalcon_db_referenceinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, __construct) -{ - zval *cache = NULL, cache_sub, __$null; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(cache, phalcon_cache_adapter_adapterinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - zephir_fetch_params_without_memory_grow(0, 1, &cache); - if (!cache) { - cache = &cache_sub; - cache = &__$null; - } - - - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Binder, bindToHandler) +static PHP_METHOD(Phalcon_Db_Reference, __construct) { - zend_string *_6$$4; - zend_ulong _5$$4; - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval cacheKey, methodName; - zval params; - zval *handler, handler_sub, *params_param = NULL, *cacheKey_param = NULL, *methodName_param = NULL, paramKey, className, boundModel, paramsCache, paramValue, _0, _2, *_3$$4, _4$$4; + zval definition; + zval *name_param = NULL, *definition_param = NULL, columns, schema, referencedTable, referencedSchema, referencedColumns, onDelete, onUpdate; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(¶mKey); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&boundModel); - ZVAL_UNDEF(¶msCache); - ZVAL_UNDEF(¶mValue); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&cacheKey); - ZVAL_UNDEF(&methodName); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&referencedTable); + ZVAL_UNDEF(&referencedSchema); + ZVAL_UNDEF(&referencedColumns); + ZVAL_UNDEF(&onDelete); + ZVAL_UNDEF(&onUpdate); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_OBJECT(handler) - Z_PARAM_ARRAY(params) - Z_PARAM_STR(cacheKey) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(methodName) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &handler, ¶ms_param, &cacheKey_param, &methodName_param); - zephir_get_arrval(¶ms, params_param); - zephir_get_strval(&cacheKey, cacheKey_param); - if (!methodName_param) { - ZEPHIR_INIT_VAR(&methodName); - } else { - if (UNEXPECTED(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be of the type string")); + zephir_fetch_params(1, 2, 0, &name_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(methodName_param) == IS_STRING)) { - zephir_get_strval(&methodName, methodName_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&methodName); - } + ZEPHIR_INIT_VAR(&name); } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("originalValues"), &_0); - _1 = !((zephir_is_instance_of(handler, SL("Closure")))); - if (_1) { - _1 = ZEPHIR_IS_NULL(&methodName); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + ZEPHIR_OBS_VAR(&referencedTable); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&referencedTable, &definition, SL("referencedTable"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Referenced table is required", "phalcon/Db/Reference.zep", 103); + return; } - if (UNEXPECTED(_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "You must specify methodName for handler or pass Closure as handler", "phalcon/Mvc/Model/Binder.zep", 75); + zephir_update_property_zval(this_ptr, ZEND_STRL("referencedTable"), &referencedTable); + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Foreign key columns are required", "phalcon/Db/Reference.zep", 109); return; } - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - zephir_update_property_zval(this_ptr, ZEND_STRL("boundModels"), &_2); - ZEPHIR_CALL_METHOD(¶msCache, this_ptr, "getparamsfromcache", NULL, 0, &cacheKey); - zephir_check_call_status(); - if (Z_TYPE_P(¶msCache) == IS_ARRAY) { - zephir_is_iterable(¶msCache, 0, "phalcon/Mvc/Model/Binder.zep", 90); - if (Z_TYPE_P(¶msCache) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶msCache), _5$$4, _6$$4, _3$$4) - { - ZEPHIR_INIT_NVAR(¶mKey); - if (_6$$4 != NULL) { - ZVAL_STR_COPY(¶mKey, _6$$4); - } else { - ZVAL_LONG(¶mKey, _5$$4); - } - ZEPHIR_INIT_NVAR(&className); - ZVAL_COPY(&className, _3$$4); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 83); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_7, 0, ¶mValue, &className); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, ¶msCache, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4$$4, ¶msCache, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4$$4)) { - break; - } - ZEPHIR_CALL_METHOD(¶mKey, ¶msCache, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&className, ¶msCache, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 83); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_7, 0, ¶mValue, &className); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - ZEPHIR_CALL_METHOD(NULL, ¶msCache, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&className); - ZEPHIR_INIT_NVAR(¶mKey); - RETURN_CTOR(¶ms); + zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); + ZEPHIR_OBS_VAR(&referencedColumns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&referencedColumns, &definition, SL("referencedColumns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Referenced columns of the foreign key are required", "phalcon/Db/Reference.zep", 117); + return; } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparamsfromreflection", NULL, 0, handler, ¶ms, &cacheKey, &methodName); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("referencedColumns"), &referencedColumns); + ZEPHIR_OBS_VAR(&schema); + if (zephir_array_isset_string_fetch(&schema, &definition, SL("schema"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("schemaName"), &schema); + } + ZEPHIR_OBS_VAR(&referencedSchema); + if (zephir_array_isset_string_fetch(&referencedSchema, &definition, SL("referencedSchema"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("referencedSchema"), &referencedSchema); + } + ZEPHIR_OBS_VAR(&onDelete); + if (zephir_array_isset_string_fetch(&onDelete, &definition, SL("onDelete"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("onDelete"), &onDelete); + } + ZEPHIR_OBS_VAR(&onUpdate); + if (zephir_array_isset_string_fetch(&onUpdate, &definition, SL("onUpdate"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("onUpdate"), &onUpdate); + } + if (UNEXPECTED(zephir_fast_count_int(&columns) != zephir_fast_count_int(&referencedColumns))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Number of columns is not equals than the number of columns referenced", "phalcon/Db/Reference.zep", 141); + return; + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, findBoundModel) +static PHP_METHOD(Phalcon_Db_Reference, getColumns) { - zend_class_entry *_0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval className; - zval *paramValue, paramValue_sub, *className_param = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(¶mValue_sub); - ZVAL_UNDEF(&className); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(paramValue) - Z_PARAM_STR(className) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, ¶mValue, &className_param); - zephir_get_strval(&className, className_param); + RETURN_MEMBER(getThis(), "columns"); +} +static PHP_METHOD(Phalcon_Db_Reference, getName) +{ + zval *this_ptr = getThis(); - _0 = zephir_fetch_class(&className); - ZEPHIR_RETURN_CALL_CE_STATIC(_0, "findfirst", NULL, 0, paramValue); - zephir_check_call_status(); - RETURN_MM(); + + + RETURN_MEMBER(getThis(), "name"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getBoundModels) +static PHP_METHOD(Phalcon_Db_Reference, getReferencedColumns) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "boundModels"); + RETURN_MEMBER(getThis(), "referencedColumns"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getOriginalValues) +static PHP_METHOD(Phalcon_Db_Reference, getReferencedSchema) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "originalValues"); + RETURN_MEMBER(getThis(), "referencedSchema"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getCache) +static PHP_METHOD(Phalcon_Db_Reference, getReferencedTable) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "cache"); + RETURN_MEMBER(getThis(), "referencedTable"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromCache) +static PHP_METHOD(Phalcon_Db_Reference, getSchemaName) { - zend_bool _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cacheKey_param = NULL, cache, internalParams, _0, _1, _3; - zval cacheKey; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cacheKey); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&internalParams); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(cacheKey) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &cacheKey_param); - zephir_get_strval(&cacheKey, cacheKey_param); + RETURN_MEMBER(getThis(), "schemaName"); +} +static PHP_METHOD(Phalcon_Db_Reference, getOnDelete) +{ + zval *this_ptr = getThis(); - ZEPHIR_OBS_VAR(&internalParams); - zephir_read_property(&_0, this_ptr, ZEND_STRL("internalCache"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&internalParams, &_0, &cacheKey, 0)) { - RETURN_CCTOR(&internalParams); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_1); - _2 = Z_TYPE_P(&cache) == IS_NULL; - if (!(_2)) { - ZEPHIR_CALL_METHOD(&_3, &cache, "has", NULL, 0, &cacheKey); - zephir_check_call_status(); - _2 = !zephir_is_true(&_3); - } - if (_2) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&internalParams, &cache, "get", NULL, 0, &cacheKey); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("internalCache"), &cacheKey, &internalParams); - RETURN_CCTOR(&internalParams); + + + RETURN_MEMBER(getThis(), "onDelete"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromReflection) +static PHP_METHOD(Phalcon_Db_Reference, getOnUpdate) { - zend_class_entry *_9$$10, *_17$$24; - zend_string *_4; - zend_ulong _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_12 = NULL, *_13 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval cacheKey, methodName; - zval params, paramsCache; - zval *handler, handler_sub, *params_param = NULL, *cacheKey_param = NULL, *methodName_param = NULL, methodParams, reflection, paramKey, methodParam, className, realClasses, boundModel, cache, handlerClass, reflectionClass, paramsKeys, paramValue, _0, *_1, _2, _5$$7, _6$$5, _7$$5, _10$$14, _11$$14, _14$$21, _15$$19, _16$$19, _18$$28, _19$$28; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&methodParams); - ZVAL_UNDEF(&reflection); - ZVAL_UNDEF(¶mKey); - ZVAL_UNDEF(&methodParam); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&realClasses); - ZVAL_UNDEF(&boundModel); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&handlerClass); - ZVAL_UNDEF(&reflectionClass); - ZVAL_UNDEF(¶msKeys); - ZVAL_UNDEF(¶mValue); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_10$$14); - ZVAL_UNDEF(&_11$$14); - ZVAL_UNDEF(&_14$$21); - ZVAL_UNDEF(&_15$$19); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_18$$28); - ZVAL_UNDEF(&_19$$28); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(¶msCache); - ZVAL_UNDEF(&cacheKey); - ZVAL_UNDEF(&methodName); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT(handler) - Z_PARAM_ARRAY(params) - Z_PARAM_STR(cacheKey) - Z_PARAM_STR(methodName) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, &handler, ¶ms_param, &cacheKey_param, &methodName_param); - zephir_get_arrval(¶ms, params_param); - zephir_get_strval(&cacheKey, cacheKey_param); - if (UNEXPECTED(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(methodName_param) == IS_STRING)) { - zephir_get_strval(&methodName, methodName_param); - } else { - ZEPHIR_INIT_VAR(&methodName); - } + RETURN_MEMBER(getThis(), "onUpdate"); +} - ZEPHIR_INIT_VAR(&realClasses); - ZVAL_NULL(&realClasses); - ZEPHIR_INIT_VAR(¶msCache); - array_init(¶msCache); - ZEPHIR_INIT_VAR(&reflection); - if (!ZEPHIR_IS_NULL(&methodName)) { - object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionmethod"))); - ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 438, handler, &methodName); - zephir_check_call_status(); - } else { - object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionfunction"))); - ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 150, handler); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_0); - ZEPHIR_CALL_METHOD(&methodParams, &reflection, "getparameters", NULL, 151); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(¶msKeys); - zephir_array_keys(¶msKeys, ¶ms); - zephir_is_iterable(&methodParams, 0, "phalcon/Mvc/Model/Binder.zep", 243); - if (Z_TYPE_P(&methodParams) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodParams), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(¶mKey); - if (_4 != NULL) { - ZVAL_STR_COPY(¶mKey, _4); - } else { - ZVAL_LONG(¶mKey, _3); - } - ZEPHIR_INIT_NVAR(&methodParam); - ZVAL_COPY(&methodParam, _1); - ZEPHIR_CALL_METHOD(&reflectionClass, &methodParam, "getclass", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&reflectionClass))) { - continue; - } - ZEPHIR_CALL_METHOD(&className, &reflectionClass, "getname", NULL, 0); - zephir_check_call_status(); - if (!(zephir_array_isset(¶ms, ¶mKey))) { - zephir_array_fetch(&_5$$7, ¶msKeys, ¶mKey, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Binder.zep", 195); - ZEPHIR_CPY_WRT(¶mKey, &_5$$7); - } - ZEPHIR_INIT_NVAR(&boundModel); - ZVAL_NULL(&boundModel); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 199); - ZEPHIR_INIT_NVAR(&_6$$5); - ZVAL_STRING(&_6$$5, "Phalcon\\Mvc\\Model"); - ZEPHIR_CALL_FUNCTION(&_7$$5, "is_subclass_of", &_8, 439, &className, &_6$$5); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&className, "Phalcon\\Mvc\\Model")) { - if (Z_TYPE_P(&realClasses) == IS_NULL) { - if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce)) { - ZEPHIR_INIT_NVAR(&handlerClass); - zephir_get_class(&handlerClass, handler, 0); - _9$$10 = zephir_fetch_class(&handlerClass); - ZEPHIR_CALL_CE_STATIC(&realClasses, _9$$10, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce)) { - ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/Mvc/Model/Binder.zep", 211); - return; - } - } - if (Z_TYPE_P(&realClasses) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&className); - if (UNEXPECTED(!(zephir_array_isset_fetch(&className, &realClasses, ¶mKey, 0)))) { - ZEPHIR_INIT_NVAR(&_10$$14); - object_init_ex(&_10$$14, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$14); - ZEPHIR_CONCAT_SVS(&_11$$14, "You should provide model class name for ", ¶mKey, " parameter"); - ZEPHIR_CALL_METHOD(NULL, &_10$$14, "__construct", &_12, 32, &_11$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$14, "phalcon/Mvc/Model/Binder.zep", 219); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else if (Z_TYPE_P(&realClasses) == IS_STRING) { - ZEPHIR_CPY_WRT(&className, &realClasses); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/Mvc/Model/Binder.zep", 229); - return; - } - } else if (zephir_is_true(&_7$$5)) { - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } - if (Z_TYPE_P(&boundModel) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - zephir_array_update_zval(¶msCache, ¶mKey, &className, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methodParams, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &methodParams, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(¶mKey, &methodParams, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&methodParam, &methodParams, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reflectionClass, &methodParam, "getclass", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&reflectionClass))) { - continue; - } - ZEPHIR_CALL_METHOD(&className, &reflectionClass, "getname", NULL, 0); - zephir_check_call_status(); - if (!(zephir_array_isset(¶ms, ¶mKey))) { - zephir_array_fetch(&_14$$21, ¶msKeys, ¶mKey, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Binder.zep", 195); - ZEPHIR_CPY_WRT(¶mKey, &_14$$21); - } - ZEPHIR_INIT_NVAR(&boundModel); - ZVAL_NULL(&boundModel); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 199); - ZEPHIR_INIT_NVAR(&_15$$19); - ZVAL_STRING(&_15$$19, "Phalcon\\Mvc\\Model"); - ZEPHIR_CALL_FUNCTION(&_16$$19, "is_subclass_of", &_8, 439, &className, &_15$$19); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&className, "Phalcon\\Mvc\\Model")) { - if (Z_TYPE_P(&realClasses) == IS_NULL) { - if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce)) { - ZEPHIR_INIT_NVAR(&handlerClass); - zephir_get_class(&handlerClass, handler, 0); - _17$$24 = zephir_fetch_class(&handlerClass); - ZEPHIR_CALL_CE_STATIC(&realClasses, _17$$24, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce)) { - ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/Mvc/Model/Binder.zep", 211); - return; - } - } - if (Z_TYPE_P(&realClasses) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&className); - if (UNEXPECTED(!(zephir_array_isset_fetch(&className, &realClasses, ¶mKey, 0)))) { - ZEPHIR_INIT_NVAR(&_18$$28); - object_init_ex(&_18$$28, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$28); - ZEPHIR_CONCAT_SVS(&_19$$28, "You should provide model class name for ", ¶mKey, " parameter"); - ZEPHIR_CALL_METHOD(NULL, &_18$$28, "__construct", &_12, 32, &_19$$28); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$28, "phalcon/Mvc/Model/Binder.zep", 219); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else if (Z_TYPE_P(&realClasses) == IS_STRING) { - ZEPHIR_CPY_WRT(&className, &realClasses); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/Mvc/Model/Binder.zep", 229); - return; - } - } else if (zephir_is_true(&_16$$19)) { - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } - if (Z_TYPE_P(&boundModel) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - zephir_array_update_zval(¶msCache, ¶mKey, &className, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &methodParams, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&methodParam); - ZEPHIR_INIT_NVAR(¶mKey); - if (Z_TYPE_P(&cache) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &cacheKey, ¶msCache); - zephir_check_call_status(); - } - zephir_update_property_array(this_ptr, SL("internalCache"), &cacheKey, ¶msCache); - RETURN_CTOR(¶ms); -} -static PHP_METHOD(Phalcon_Mvc_Model_Binder, setCache) -{ - zval *cache, cache_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&cache_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(cache, phalcon_cache_adapter_adapterinterface_ce) - ZEND_PARSE_PARAMETERS_END(); +#ifdef HAVE_CONFIG_H #endif - zephir_fetch_params_without_memory_grow(1, 0, &cache); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); - RETURN_THISW(); -} -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Binder(zend_class_entry *class_type) +ZEPHIR_INIT_CLASS(Phalcon_Db_ReferenceInterface) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ReferenceInterface, phalcon, db_referenceinterface, phalcon_db_referenceinterface_method_entry); - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("originalValues"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("originalValues"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("internalCache"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("internalCache"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("boundModels"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("boundModels"), &_5$$5); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getColumns); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getOnDelete); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getOnUpdate); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getReferencedColumns); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getReferencedSchema); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getReferencedTable); +ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getSchemaName); @@ -64482,17 +57961,33 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Binder(zend_class_entry *c -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BinderInterface) +ZEPHIR_INIT_CLASS(Phalcon_Db_ResultInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BinderInterface, phalcon, mvc_model_binderinterface, phalcon_mvc_model_binderinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ResultInterface, phalcon, db_resultinterface, phalcon_db_resultinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, bindToHandler); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, getBoundModels); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, getCache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, setCache); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, dataSeek); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, execute); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, fetch); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, fetchAll); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, fetchArray); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, getInternalResult); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, numRows); +ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, setFetchMode); + + + + +static int phalcon_db_checktype(zval *return_value, zval *placeholder) { + + if (Z_TYPE_P(placeholder) != IS_STRING) { + + } + + return 0; +} @@ -64503,1848 +57998,2505 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, setCache); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Criteria) +ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_Mysql) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Criteria, phalcon, mvc_model_criteria, phalcon_mvc_model_criteria_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("bindParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_criteria_ce, SL("hiddenParamNumber"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("model"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("params"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_criteria_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Criteria; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, Mysql, phalcon, db_dialect_mysql, phalcon_db_dialect_ce, phalcon_db_dialect_mysql_method_entry, 0); - zend_class_implements(phalcon_mvc_model_criteria_ce, 1, phalcon_mvc_model_criteriainterface_ce); - zend_class_implements(phalcon_mvc_model_criteria_ce, 1, phalcon_di_injectionawareinterface_ce); + zend_declare_property_string(phalcon_db_dialect_mysql_ce, SL("escapeChar"), "`", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, andWhere) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, addColumn) { + zend_bool _6$$5, _7$$5, _8$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentConditions, _0, _1$$3; - zval conditions; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, afterPosition, defaultValue, upperDefaultValue, _0, _1, _2, _3, _4, _5, _14, _15, _9$$5, _10$$6, _11$$7, _12$$7, _13$$7, _16$$11; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¤tConditions); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&afterPosition); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&upperDefaultValue); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_16$$11); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(bindParams) - Z_PARAM_ZVAL_OR_NULL(bindTypes) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&conditions); + ZEPHIR_INIT_VAR(&tableName); } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_OBS_VAR(¤tConditions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tConditions, &_0, SL("conditions"), 0)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVSVS(&_1$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); - zephir_get_strval(&conditions, &_1$$3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcolumndefinition", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SVSVSV(&_3, "ALTER TABLE ", &_0, " ADD `", &_1, "` ", &_2); + zephir_get_strval(&sql, &_3); + ZEPHIR_CALL_METHOD(&_4, column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_4)) { + zephir_concat_self_str(&sql, " NOT NULL", sizeof(" NOT NULL") - 1); + } else { + zephir_concat_self_str(&sql, " NULL", sizeof(" NULL") - 1); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, bindParams, bindTypes); + ZEPHIR_CALL_METHOD(&_5, column, "hasdefault", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + if (zephir_is_true(&_5)) { + ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&upperDefaultValue); + zephir_fast_strtoupper(&upperDefaultValue, &defaultValue); + _6$$5 = zephir_memnstr_str(&upperDefaultValue, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Mysql.zep", 54); + if (!(_6$$5)) { + _6$$5 = zephir_memnstr_str(&upperDefaultValue, SL("NULL"), "phalcon/Db/Dialect/Mysql.zep", 54); + } + _7$$5 = _6$$5; + if (!(_7$$5)) { + _7$$5 = Z_TYPE_P(&defaultValue) == IS_LONG; + } + _8$$5 = _7$$5; + if (!(_8$$5)) { + ZEPHIR_CALL_FUNCTION(&_9$$5, "is_float", NULL, 213, &defaultValue); + zephir_check_call_status(); + _8$$5 = zephir_is_true(&_9$$5); + } + if (_8$$5) { + ZEPHIR_INIT_VAR(&_10$$6); + ZEPHIR_CONCAT_SV(&_10$$6, " DEFAULT ", &defaultValue); + zephir_concat_self(&sql, &_10$$6); + } else { + ZEPHIR_INIT_VAR(&_11$$7); + ZVAL_STRING(&_11$$7, "\""); + ZEPHIR_CALL_FUNCTION(&_12$$7, "addcslashes", NULL, 214, &defaultValue, &_11$$7); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_13$$7); + ZEPHIR_CONCAT_SVS(&_13$$7, " DEFAULT \"", &_12$$7, "\""); + zephir_concat_self(&sql, &_13$$7); + } + } + ZEPHIR_CALL_METHOD(&_14, column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_14)) { + zephir_concat_self_str(&sql, " AUTO_INCREMENT", sizeof(" AUTO_INCREMENT") - 1); + } + ZEPHIR_CALL_METHOD(&_15, column, "isfirst", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_15)) { + zephir_concat_self_str(&sql, " FIRST", sizeof(" FIRST") - 1); + } else { + ZEPHIR_CALL_METHOD(&afterPosition, column, "getafterposition", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&afterPosition)) { + ZEPHIR_INIT_VAR(&_16$$11); + ZEPHIR_CONCAT_SVS(&_16$$11, " AFTER `", &afterPosition, "`"); + zephir_concat_self(&sql, &_16$$11); + } + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, betweenWhere) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, addForeignKey) { - zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, minimumKey, nextHiddenParam, maximumKey, _0; - zval expr; + zval *tableName_param = NULL, *schemaName_param = NULL, *reference, reference_sub, onDelete, onUpdate, _0, _1, _2, _5, _6, _7, _8, _9, _10, _11, _12, _3$$3, _4$$3, _13$$4, _14$$5; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&maximumKey); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&reference_sub); + ZVAL_UNDEF(&onDelete); + ZVAL_UNDEF(&onUpdate); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_13$$4); + ZVAL_UNDEF(&_14$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(reference, phalcon_db_referenceinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&expr); + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_OBS_VAR(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&minimumKey); - ZEPHIR_CONCAT_SV(&minimumKey, "ACP", &hiddenParam); - ZEPHIR_INIT_VAR(&maximumKey); - ZEPHIR_CONCAT_SV(&maximumKey, "ACP", &nextHiddenParam); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSVSVS(&_0, &expr, " BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 2, 0); - zephir_array_update_zval(&_1, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_1, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_0, &_1); + ZEPHIR_CONCAT_SVS(&_1, "ALTER TABLE ", &_0, " ADD"); + zephir_get_strval(&sql, &_1); + ZEPHIR_CALL_METHOD(&_2, reference, "getname", NULL, 0); zephir_check_call_status(); - ZEPHIR_SEPARATE(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); + if (zephir_is_true(&_2)) { + ZEPHIR_CALL_METHOD(&_3$$3, reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_SVS(&_4$$3, " CONSTRAINT `", &_3$$3, "`"); + zephir_concat_self(&sql, &_4$$3); + } + ZEPHIR_CALL_METHOD(&_6, reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getcolumnlist", NULL, 57, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8, reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9, reference, "getreferencedschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "preparetable", NULL, 0, &_8, &_9); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_11, reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_10, this_ptr, "getcolumnlist", NULL, 57, &_11); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_12); + ZEPHIR_CONCAT_SVSVSVS(&_12, " FOREIGN KEY (", &_5, ") REFERENCES ", &_7, "(", &_10, ")"); + zephir_concat_self(&sql, &_12); + ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_VAR(&_13$$4); + ZEPHIR_CONCAT_SV(&_13$$4, " ON DELETE ", &onDelete); + zephir_concat_self(&sql, &_13$$4); + } + ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_VAR(&_14$$5); + ZEPHIR_CONCAT_SV(&_14$$5, " ON UPDATE ", &onUpdate); + zephir_concat_self(&sql, &_14$$5); + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bind) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, addIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge, _5; - zval *bindParams_param = NULL, *merge_param = NULL, _0, _3, _4, _1$$3, _2$$3, _6$$4, _7$$4, _8$$4, _9$$4, _10$$5; - zval bindParams; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, indexType, _0, _1, _3, _4, _5, _6, _2$$3; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&indexType); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); - if (!merge_param) { - merge = 0; + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - merge = zephir_get_boolval(merge_param); + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string(&_0, SL("bind")))) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "ALTER TABLE ", &_0); + zephir_get_strval(&sql, &_1); + ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&indexType))) { ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_2$$3, &_1$$3); - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_OBS_VAR(&_4); - zephir_array_fetch_string(&_4, &_3, SL("bind"), PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 129); - _5 = Z_TYPE_P(&_4) == IS_ARRAY; - if (_5) { - _5 = merge; - } - if (_5) { - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_7$$4, &_6$$4, SL("bind"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Criteria.zep", 130); - ZEPHIR_INIT_VAR(&_8$$4); - zephir_add_function(&_8$$4, &_7$$4, &bindParams); - ZEPHIR_INIT_VAR(&_9$$4); - ZVAL_STRING(&_9$$4, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_9$$4, &_8$$4); + ZEPHIR_CONCAT_SVS(&_2$$3, " ADD ", &indexType, " INDEX "); + zephir_concat_self(&sql, &_2$$3); } else { - ZEPHIR_INIT_VAR(&_10$$5); - ZVAL_STRING(&_10$$5, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_10$$5, &bindParams); + zephir_concat_self_str(&sql, " ADD INDEX ", sizeof(" ADD INDEX ") - 1); } - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_3, index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5, index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumnlist", NULL, 57, &_5); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SVSVS(&_6, "`", &_3, "` (", &_4, ")"); + zephir_concat_self(&sql, &_6); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bindTypes) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, addPrimaryKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *bindTypes_param = NULL, _0; - zval bindTypes; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, _0, _1, _2; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &bindTypes_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "bindTypes"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &bindTypes); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcolumnlist", NULL, 57, &_2); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " ADD PRIMARY KEY (", &_1, ")"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, cache) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, createTable) { + zend_bool _9$$10, _10$$10, _11$$10, _28$$19, _29$$19, _30$$19; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *cache_param = NULL, _0; - zval cache; + zephir_fcall_cache_entry *_6 = NULL, *_13 = NULL, *_17 = NULL, *_45 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval definition, createLines; + zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, temporary, options, table, columns, column, indexes, index, reference, references, indexName, columnLine, indexType, onDelete, onUpdate, defaultValue, upperDefaultValue, *_2, _3, _86, _87, _0$$5, _1$$6, _4$$7, _5$$7, _7$$7, _8$$7, _19$$7, _20$$7, _21$$7, _12$$10, _14$$11, _15$$12, _16$$12, _18$$12, _22$$15, _23$$15, _24$$16, _25$$16, _26$$16, _27$$16, _36$$16, _37$$16, _38$$16, _31$$19, _32$$20, _33$$21, _34$$21, _35$$21, _39$$24, _40$$24, *_41$$25, _42$$25, _43$$27, _44$$27, _46$$27, _47$$29, _48$$29, _49$$29, _50$$30, _51$$30, _52$$30, _53$$32, _54$$32, _55$$32, _56$$34, _57$$34, _58$$34, _59$$35, _60$$35, _61$$35, *_62$$36, _63$$36, _64$$37, _65$$37, _66$$37, _67$$37, _68$$37, _69$$37, _70$$37, _71$$37, _72$$37, _73$$38, _74$$39, _75$$40, _76$$40, _77$$40, _78$$40, _79$$40, _80$$40, _81$$40, _82$$40, _83$$40, _84$$41, _85$$42, _88$$43, _89$$43; + zval tableName, schemaName, indexSql, referenceSql, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&indexSql); + ZVAL_UNDEF(&referenceSql); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&temporary); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&indexes); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&indexName); + ZVAL_UNDEF(&columnLine); + ZVAL_UNDEF(&indexType); + ZVAL_UNDEF(&onDelete); + ZVAL_UNDEF(&onUpdate); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&upperDefaultValue); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_86); + ZVAL_UNDEF(&_87); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_19$$7); + ZVAL_UNDEF(&_20$$7); + ZVAL_UNDEF(&_21$$7); + ZVAL_UNDEF(&_12$$10); + ZVAL_UNDEF(&_14$$11); + ZVAL_UNDEF(&_15$$12); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_23$$15); + ZVAL_UNDEF(&_24$$16); + ZVAL_UNDEF(&_25$$16); + ZVAL_UNDEF(&_26$$16); + ZVAL_UNDEF(&_27$$16); + ZVAL_UNDEF(&_36$$16); + ZVAL_UNDEF(&_37$$16); + ZVAL_UNDEF(&_38$$16); + ZVAL_UNDEF(&_31$$19); + ZVAL_UNDEF(&_32$$20); + ZVAL_UNDEF(&_33$$21); + ZVAL_UNDEF(&_34$$21); + ZVAL_UNDEF(&_35$$21); + ZVAL_UNDEF(&_39$$24); + ZVAL_UNDEF(&_40$$24); + ZVAL_UNDEF(&_42$$25); + ZVAL_UNDEF(&_43$$27); + ZVAL_UNDEF(&_44$$27); + ZVAL_UNDEF(&_46$$27); + ZVAL_UNDEF(&_47$$29); + ZVAL_UNDEF(&_48$$29); + ZVAL_UNDEF(&_49$$29); + ZVAL_UNDEF(&_50$$30); + ZVAL_UNDEF(&_51$$30); + ZVAL_UNDEF(&_52$$30); + ZVAL_UNDEF(&_53$$32); + ZVAL_UNDEF(&_54$$32); + ZVAL_UNDEF(&_55$$32); + ZVAL_UNDEF(&_56$$34); + ZVAL_UNDEF(&_57$$34); + ZVAL_UNDEF(&_58$$34); + ZVAL_UNDEF(&_59$$35); + ZVAL_UNDEF(&_60$$35); + ZVAL_UNDEF(&_61$$35); + ZVAL_UNDEF(&_63$$36); + ZVAL_UNDEF(&_64$$37); + ZVAL_UNDEF(&_65$$37); + ZVAL_UNDEF(&_66$$37); + ZVAL_UNDEF(&_67$$37); + ZVAL_UNDEF(&_68$$37); + ZVAL_UNDEF(&_69$$37); + ZVAL_UNDEF(&_70$$37); + ZVAL_UNDEF(&_71$$37); + ZVAL_UNDEF(&_72$$37); + ZVAL_UNDEF(&_73$$38); + ZVAL_UNDEF(&_74$$39); + ZVAL_UNDEF(&_75$$40); + ZVAL_UNDEF(&_76$$40); + ZVAL_UNDEF(&_77$$40); + ZVAL_UNDEF(&_78$$40); + ZVAL_UNDEF(&_79$$40); + ZVAL_UNDEF(&_80$$40); + ZVAL_UNDEF(&_81$$40); + ZVAL_UNDEF(&_82$$40); + ZVAL_UNDEF(&_83$$40); + ZVAL_UNDEF(&_84$$41); + ZVAL_UNDEF(&_85$$42); + ZVAL_UNDEF(&_88$$43); + ZVAL_UNDEF(&_89$$43); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&createLines); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(cache) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &cache_param); - ZEPHIR_OBS_COPY_OR_DUP(&cache, cache_param); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "cache"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &cache); - RETURN_THIS(); + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/Db/Dialect/Mysql.zep", 151); + return; + } + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&temporary); + ZVAL_BOOL(&temporary, 0); + ZEPHIR_OBS_VAR(&options); + if (zephir_array_isset_string_fetch(&options, &definition, SL("options"), 0)) { + ZEPHIR_OBS_NVAR(&temporary); + zephir_array_isset_string_fetch(&temporary, &options, SL("temporary"), 0); + } + if (zephir_is_true(&temporary)) { + ZEPHIR_INIT_VAR(&_0$$5); + ZEPHIR_CONCAT_SVS(&_0$$5, "CREATE TEMPORARY TABLE ", &table, " (\n\t"); + zephir_get_strval(&sql, &_0$$5); + } else { + ZEPHIR_INIT_VAR(&_1$$6); + ZEPHIR_CONCAT_SVS(&_1$$6, "CREATE TABLE ", &table, " (\n\t"); + zephir_get_strval(&sql, &_1$$6); + } + ZEPHIR_INIT_VAR(&createLines); + array_init(&createLines); + zephir_is_iterable(&columns, 0, "phalcon/Db/Dialect/Mysql.zep", 228); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _2) + { + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _2); + ZEPHIR_CALL_METHOD(&_4$$7, &column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$7, this_ptr, "getcolumndefinition", &_6, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&columnLine); + ZEPHIR_CONCAT_SVSV(&columnLine, "`", &_4$$7, "` ", &_5$$7); + ZEPHIR_CALL_METHOD(&_7$$7, &column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_7$$7)) { + zephir_concat_self_str(&columnLine, SL(" NOT NULL")); + } else { + zephir_concat_self_str(&columnLine, SL(" NULL")); + } + ZEPHIR_CALL_METHOD(&_8$$7, &column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_8$$7)) { + ZEPHIR_CALL_METHOD(&defaultValue, &column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&upperDefaultValue); + zephir_fast_strtoupper(&upperDefaultValue, &defaultValue); + _9$$10 = zephir_memnstr_str(&upperDefaultValue, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Mysql.zep", 194); + if (!(_9$$10)) { + _9$$10 = zephir_memnstr_str(&upperDefaultValue, SL("NULL"), "phalcon/Db/Dialect/Mysql.zep", 194); + } + _10$$10 = _9$$10; + if (!(_10$$10)) { + _10$$10 = Z_TYPE_P(&defaultValue) == IS_LONG; + } + _11$$10 = _10$$10; + if (!(_11$$10)) { + ZEPHIR_CALL_FUNCTION(&_12$$10, "is_float", &_13, 213, &defaultValue); + zephir_check_call_status(); + _11$$10 = zephir_is_true(&_12$$10); + } + if (_11$$10) { + ZEPHIR_INIT_NVAR(&_14$$11); + ZEPHIR_CONCAT_SV(&_14$$11, " DEFAULT ", &defaultValue); + zephir_concat_self(&columnLine, &_14$$11); + } else { + ZEPHIR_INIT_NVAR(&_15$$12); + ZVAL_STRING(&_15$$12, "\""); + ZEPHIR_CALL_FUNCTION(&_16$$12, "addcslashes", &_17, 214, &defaultValue, &_15$$12); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_18$$12); + ZEPHIR_CONCAT_SVS(&_18$$12, " DEFAULT \"", &_16$$12, "\""); + zephir_concat_self(&columnLine, &_18$$12); + } + } + ZEPHIR_CALL_METHOD(&_19$$7, &column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_19$$7)) { + zephir_concat_self_str(&columnLine, SL(" AUTO_INCREMENT")); + } + ZEPHIR_CALL_METHOD(&_20$$7, &column, "isprimary", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_20$$7)) { + zephir_concat_self_str(&columnLine, SL(" PRIMARY KEY")); + } + ZEPHIR_CALL_METHOD(&_21$$7, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_21$$7)) { + ZEPHIR_CALL_METHOD(&_22$$15, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_23$$15); + ZEPHIR_CONCAT_SVS(&_23$$15, " COMMENT '", &_22$$15, "'"); + zephir_concat_self(&columnLine, &_23$$15); + } + zephir_array_append(&createLines, &columnLine, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 222); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24$$16, &column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_25$$16, this_ptr, "getcolumndefinition", &_6, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&columnLine); + ZEPHIR_CONCAT_SVSV(&columnLine, "`", &_24$$16, "` ", &_25$$16); + ZEPHIR_CALL_METHOD(&_26$$16, &column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_26$$16)) { + zephir_concat_self_str(&columnLine, SL(" NOT NULL")); + } else { + zephir_concat_self_str(&columnLine, SL(" NULL")); + } + ZEPHIR_CALL_METHOD(&_27$$16, &column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_27$$16)) { + ZEPHIR_CALL_METHOD(&defaultValue, &column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&upperDefaultValue); + zephir_fast_strtoupper(&upperDefaultValue, &defaultValue); + _28$$19 = zephir_memnstr_str(&upperDefaultValue, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Mysql.zep", 194); + if (!(_28$$19)) { + _28$$19 = zephir_memnstr_str(&upperDefaultValue, SL("NULL"), "phalcon/Db/Dialect/Mysql.zep", 194); + } + _29$$19 = _28$$19; + if (!(_29$$19)) { + _29$$19 = Z_TYPE_P(&defaultValue) == IS_LONG; + } + _30$$19 = _29$$19; + if (!(_30$$19)) { + ZEPHIR_CALL_FUNCTION(&_31$$19, "is_float", &_13, 213, &defaultValue); + zephir_check_call_status(); + _30$$19 = zephir_is_true(&_31$$19); + } + if (_30$$19) { + ZEPHIR_INIT_NVAR(&_32$$20); + ZEPHIR_CONCAT_SV(&_32$$20, " DEFAULT ", &defaultValue); + zephir_concat_self(&columnLine, &_32$$20); + } else { + ZEPHIR_INIT_NVAR(&_33$$21); + ZVAL_STRING(&_33$$21, "\""); + ZEPHIR_CALL_FUNCTION(&_34$$21, "addcslashes", &_17, 214, &defaultValue, &_33$$21); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_35$$21); + ZEPHIR_CONCAT_SVS(&_35$$21, " DEFAULT \"", &_34$$21, "\""); + zephir_concat_self(&columnLine, &_35$$21); + } + } + ZEPHIR_CALL_METHOD(&_36$$16, &column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_36$$16)) { + zephir_concat_self_str(&columnLine, SL(" AUTO_INCREMENT")); + } + ZEPHIR_CALL_METHOD(&_37$$16, &column, "isprimary", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_37$$16)) { + zephir_concat_self_str(&columnLine, SL(" PRIMARY KEY")); + } + ZEPHIR_CALL_METHOD(&_38$$16, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_38$$16)) { + ZEPHIR_CALL_METHOD(&_39$$24, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_40$$24); + ZEPHIR_CONCAT_SVS(&_40$$24, " COMMENT '", &_39$$24, "'"); + zephir_concat_self(&columnLine, &_40$$24); + } + zephir_array_append(&createLines, &columnLine, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 222); + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_OBS_VAR(&indexes); + if (zephir_array_isset_string_fetch(&indexes, &definition, SL("indexes"), 0)) { + zephir_is_iterable(&indexes, 0, "phalcon/Db/Dialect/Mysql.zep", 248); + if (Z_TYPE_P(&indexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&indexes), _41$$25) + { + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _41$$25); + ZEPHIR_CALL_METHOD(&indexName, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexType, &index, "gettype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&indexName, "PRIMARY")) { + ZEPHIR_CALL_METHOD(&_44$$27, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_43$$27, this_ptr, "getcolumnlist", &_45, 57, &_44$$27); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_46$$27); + ZEPHIR_CONCAT_SVS(&_46$$27, "PRIMARY KEY (", &_43$$27, ")"); + zephir_get_strval(&indexSql, &_46$$27); + } else { + if (!(ZEPHIR_IS_EMPTY(&indexType))) { + ZEPHIR_CALL_METHOD(&_48$$29, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_47$$29, this_ptr, "getcolumnlist", &_45, 57, &_48$$29); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_49$$29); + ZEPHIR_CONCAT_VSVSVS(&_49$$29, &indexType, " KEY `", &indexName, "` (", &_47$$29, ")"); + zephir_get_strval(&indexSql, &_49$$29); + } else { + ZEPHIR_CALL_METHOD(&_51$$30, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_50$$30, this_ptr, "getcolumnlist", &_45, 57, &_51$$30); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_52$$30); + ZEPHIR_CONCAT_SVSVS(&_52$$30, "KEY `", &indexName, "` (", &_50$$30, ")"); + zephir_get_strval(&indexSql, &_52$$30); + } + } + zephir_array_append(&createLines, &indexSql, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 246); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &indexes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_42$$25, &indexes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_42$$25)) { + break; + } + ZEPHIR_CALL_METHOD(&index, &indexes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexName, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexType, &index, "gettype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&indexName, "PRIMARY")) { + ZEPHIR_CALL_METHOD(&_54$$32, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_53$$32, this_ptr, "getcolumnlist", &_45, 57, &_54$$32); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_55$$32); + ZEPHIR_CONCAT_SVS(&_55$$32, "PRIMARY KEY (", &_53$$32, ")"); + zephir_get_strval(&indexSql, &_55$$32); + } else { + if (!(ZEPHIR_IS_EMPTY(&indexType))) { + ZEPHIR_CALL_METHOD(&_57$$34, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_56$$34, this_ptr, "getcolumnlist", &_45, 57, &_57$$34); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_58$$34); + ZEPHIR_CONCAT_VSVSVS(&_58$$34, &indexType, " KEY `", &indexName, "` (", &_56$$34, ")"); + zephir_get_strval(&indexSql, &_58$$34); + } else { + ZEPHIR_CALL_METHOD(&_60$$35, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_59$$35, this_ptr, "getcolumnlist", &_45, 57, &_60$$35); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_61$$35); + ZEPHIR_CONCAT_SVSVS(&_61$$35, "KEY `", &indexName, "` (", &_59$$35, ")"); + zephir_get_strval(&indexSql, &_61$$35); + } + } + zephir_array_append(&createLines, &indexSql, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 246); + ZEPHIR_CALL_METHOD(NULL, &indexes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&index); + } + ZEPHIR_OBS_VAR(&references); + if (zephir_array_isset_string_fetch(&references, &definition, SL("references"), 0)) { + zephir_is_iterable(&references, 0, "phalcon/Db/Dialect/Mysql.zep", 270); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&references), _62$$36) + { + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _62$$36); + ZEPHIR_CALL_METHOD(&_64$$37, &reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_66$$37, &reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_65$$37, this_ptr, "getcolumnlist", &_45, 57, &_66$$37); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_68$$37, &reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_69$$37, &reference, "getreferencedschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_67$$37, this_ptr, "preparetable", NULL, 0, &_68$$37, &_69$$37); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_71$$37, &reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_70$$37, this_ptr, "getcolumnlist", &_45, 57, &_71$$37); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_72$$37); + ZEPHIR_CONCAT_SVSVSSVSVS(&_72$$37, "CONSTRAINT `", &_64$$37, "` FOREIGN KEY (", &_65$$37, ")", " REFERENCES ", &_67$$37, " (", &_70$$37, ")"); + zephir_get_strval(&referenceSql, &_72$$37); + ZEPHIR_CALL_METHOD(&onDelete, &reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_NVAR(&_73$$38); + ZEPHIR_CONCAT_SV(&_73$$38, " ON DELETE ", &onDelete); + zephir_concat_self(&referenceSql, &_73$$38); + } + ZEPHIR_CALL_METHOD(&onUpdate, &reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_NVAR(&_74$$39); + ZEPHIR_CONCAT_SV(&_74$$39, " ON UPDATE ", &onUpdate); + zephir_concat_self(&referenceSql, &_74$$39); + } + zephir_array_append(&createLines, &referenceSql, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 268); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_63$$36, &references, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_63$$36)) { + break; + } + ZEPHIR_CALL_METHOD(&reference, &references, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_75$$40, &reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_77$$40, &reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_76$$40, this_ptr, "getcolumnlist", &_45, 57, &_77$$40); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_79$$40, &reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_80$$40, &reference, "getreferencedschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_78$$40, this_ptr, "preparetable", NULL, 0, &_79$$40, &_80$$40); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_82$$40, &reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_81$$40, this_ptr, "getcolumnlist", &_45, 57, &_82$$40); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_83$$40); + ZEPHIR_CONCAT_SVSVSSVSVS(&_83$$40, "CONSTRAINT `", &_75$$40, "` FOREIGN KEY (", &_76$$40, ")", " REFERENCES ", &_78$$40, " (", &_81$$40, ")"); + zephir_get_strval(&referenceSql, &_83$$40); + ZEPHIR_CALL_METHOD(&onDelete, &reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_NVAR(&_84$$41); + ZEPHIR_CONCAT_SV(&_84$$41, " ON DELETE ", &onDelete); + zephir_concat_self(&referenceSql, &_84$$41); + } + ZEPHIR_CALL_METHOD(&onUpdate, &reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_NVAR(&_85$$42); + ZEPHIR_CONCAT_SV(&_85$$42, " ON UPDATE ", &onUpdate); + zephir_concat_self(&referenceSql, &_85$$42); + } + zephir_array_append(&createLines, &referenceSql, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 268); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&reference); + } + ZEPHIR_INIT_VAR(&_86); + zephir_fast_join_str(&_86, SL(",\n\t"), &createLines); + ZEPHIR_INIT_VAR(&_87); + ZEPHIR_CONCAT_VS(&_87, &_86, "\n)"); + zephir_concat_self(&sql, &_87); + if (zephir_array_isset_string(&definition, SL("options"))) { + ZEPHIR_CALL_METHOD(&_88$$43, this_ptr, "gettableoptions", NULL, 0, &definition); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_89$$43); + ZEPHIR_CONCAT_SV(&_89$$43, " ", &_88$$43); + zephir_concat_self(&sql, &_89$$43); + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, columns) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, createView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *columns, columns_sub, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval definition; + zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, viewSql, _0; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns_sub); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&viewSql); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(columns) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(viewName) + Z_PARAM_ARRAY(definition) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &columns); + zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); + } else { + ZEPHIR_INIT_VAR(&viewName); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "columns"); - zephir_update_property_array(this_ptr, SL("params"), &_0, columns); - RETURN_THIS(); + ZEPHIR_OBS_VAR(&viewSql); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&viewSql, &definition, SL("sql"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/Db/Dialect/Mysql.zep", 291); + return; + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &viewName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", &_0, " AS ", &viewSql); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, conditions) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, describeColumns) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *conditions_param = NULL, _0; - zval conditions; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, _0; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(conditions) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &conditions_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&conditions); + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "conditions"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &conditions); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &table, &schema); + zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, "SHOW FULL COLUMNS FROM ", &_0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, createBuilder) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, describeIndexes) { - zval container, manager, builder, _1, _2, _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_0 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, _0; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&builder); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) != IS_OBJECT) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, &container); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); } - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "modelsManager"); - ZEPHIR_CALL_METHOD(&_1, &container, "getshared", NULL, 0, &_2); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_1); - zephir_read_property(&_3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&builder, &manager, "createbuilder", NULL, 0, &_3); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_4); - zephir_check_call_status(); - RETURN_CCTOR(&builder); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, distinct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *distinct, distinct_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&distinct_sub); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(distinct) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &distinct); - - - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "distinct"); - zephir_update_property_array(this_ptr, SL("params"), &_0, distinct); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, execute) -{ - zend_class_entry *_1; - zval model, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&model, this_ptr, "getmodelname", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&model) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Model name must be string", "phalcon/Mvc/Model/Criteria.zep", 245); - return; - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getparams", NULL, 0); - zephir_check_call_status(); - _1 = zephir_fetch_class(&model); - ZEPHIR_RETURN_CALL_CE_STATIC(_1, "find", NULL, 0, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &table, &schema); zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, "SHOW INDEXES FROM ", &_0); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, forUpdate) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, describeReferences) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *forUpdate_param = NULL, _0, _1; - zend_bool forUpdate; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema, sql, _0$$3, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(forUpdate) + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &forUpdate_param); - if (!forUpdate_param) { - forUpdate = 1; + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - forUpdate = zephir_get_boolval(forUpdate_param); + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "for_update"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, forUpdate); - zephir_update_property_array(this_ptr, SL("params"), &_0, &_1); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&sql); + ZVAL_STRING(&sql, "SELECT DISTINCT KCU.TABLE_NAME, KCU.COLUMN_NAME, KCU.CONSTRAINT_NAME, KCU.REFERENCED_TABLE_SCHEMA, KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME, RC.UPDATE_RULE, RC.DELETE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON RC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND RC.CONSTRAINT_SCHEMA = KCU.CONSTRAINT_SCHEMA WHERE KCU.REFERENCED_TABLE_NAME IS NOT NULL AND "); + if (!(ZEPHIR_IS_EMPTY(&schema))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SVSVS(&_0$$3, "KCU.CONSTRAINT_SCHEMA = '", &schema, "' AND KCU.TABLE_NAME = '", &table, "'"); + zephir_concat_self(&sql, &_0$$3); + } else { + ZEPHIR_INIT_VAR(&_1$$4); + ZEPHIR_CONCAT_SVS(&_1$$4, "KCU.CONSTRAINT_SCHEMA = DATABASE() AND KCU.TABLE_NAME = '", &table, "'"); + zephir_concat_self(&sql, &_1$$4); + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, fromInput) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropColumn) { - zend_bool _6$$4, _7$$7, _11$$10, _12$$13; - zend_string *_5$$3; - zend_ulong _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval data, conditions, bind, _1$$3; - zval modelName, operator, _17$$16; - zval *container, container_sub, *modelName_param = NULL, *data_param = NULL, *operator_param = NULL, __$null, attribute, field, value, type, metaData, model, dataTypes, criteria, columnMap, _0$$3, *_2$$3, _3$$3, _8$$9, _9$$9, _10$$8, _13$$15, _14$$15, _15$$14, _16$$16; + zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL, _0; + zval tableName, schemaName, columnName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&dataTypes); - ZVAL_UNDEF(&criteria); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_13$$15); - ZVAL_UNDEF(&_14$$15); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bind); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&columnName); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_STR(modelName) - Z_PARAM_ARRAY(data) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(columnName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &container, &modelName_param, &data_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "AND"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&operator); - } - } - - - ZEPHIR_INIT_VAR(&conditions); - array_init(&conditions); - if (zephir_fast_count_int(&data)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&metaData, container, "getshared", NULL, 0, &_0$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 2, 0); - zephir_array_fast_append(&_1$$3, &__$null); - zephir_array_fast_append(&_1$$3, container); - ZEPHIR_INIT_VAR(&model); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_1$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&dataTypes, &metaData, "getdatatypes", NULL, 0, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &model); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&bind); - array_init(&bind); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model/Criteria.zep", 322); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _4$$3, _5$$3, _2$$3) - { - ZEPHIR_INIT_NVAR(&field); - if (_5$$3 != NULL) { - ZVAL_STR_COPY(&field, _5$$3); - } else { - ZVAL_LONG(&field, _4$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2$$3); - _6$$4 = Z_TYPE_P(&columnMap) == IS_ARRAY; - if (_6$$4) { - _6$$4 = ((zephir_fast_count_int(&columnMap)) ? 1 : 0); - } - if (_6$$4) { - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch(&attribute, &columnMap, &field, PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 297); - } else { - ZEPHIR_CPY_WRT(&attribute, &field); - } - ZEPHIR_OBS_NVAR(&type); - if (zephir_array_isset_fetch(&type, &dataTypes, &attribute, 0)) { - _7$$7 = Z_TYPE_P(&value) != IS_NULL; - if (_7$$7) { - _7$$7 = !ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_7$$7) { - if (ZEPHIR_IS_LONG(&type, 2)) { - ZEPHIR_INIT_NVAR(&_8$$9); - ZEPHIR_CONCAT_SVSVS(&_8$$9, "[", &field, "] LIKE :", &field, ":"); - zephir_array_append(&conditions, &_8$$9, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 308); - ZEPHIR_INIT_NVAR(&_9$$9); - ZEPHIR_CONCAT_SVS(&_9$$9, "%", &value, "%"); - zephir_array_update_zval(&bind, &field, &_9$$9, PH_COPY | PH_SEPARATE); - continue; - } - ZEPHIR_INIT_NVAR(&_10$$8); - ZEPHIR_CONCAT_SVSVS(&_10$$8, "[", &field, "] = :", &field, ":"); - zephir_array_append(&conditions, &_10$$8, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 317); - zephir_array_update_zval(&bind, &field, &value, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &data, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); - zephir_check_call_status(); - _11$$10 = Z_TYPE_P(&columnMap) == IS_ARRAY; - if (_11$$10) { - _11$$10 = ((zephir_fast_count_int(&columnMap)) ? 1 : 0); - } - if (_11$$10) { - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch(&attribute, &columnMap, &field, PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 297); - } else { - ZEPHIR_CPY_WRT(&attribute, &field); - } - ZEPHIR_OBS_NVAR(&type); - if (zephir_array_isset_fetch(&type, &dataTypes, &attribute, 0)) { - _12$$13 = Z_TYPE_P(&value) != IS_NULL; - if (_12$$13) { - _12$$13 = !ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_12$$13) { - if (ZEPHIR_IS_LONG(&type, 2)) { - ZEPHIR_INIT_NVAR(&_13$$15); - ZEPHIR_CONCAT_SVSVS(&_13$$15, "[", &field, "] LIKE :", &field, ":"); - zephir_array_append(&conditions, &_13$$15, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 308); - ZEPHIR_INIT_NVAR(&_14$$15); - ZEPHIR_CONCAT_SVS(&_14$$15, "%", &value, "%"); - zephir_array_update_zval(&bind, &field, &_14$$15, PH_COPY | PH_SEPARATE); - continue; - } - ZEPHIR_INIT_NVAR(&_15$$14); - ZEPHIR_CONCAT_SVSVS(&_15$$14, "[", &field, "] = :", &field, ":"); - zephir_array_append(&conditions, &_15$$14, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 317); - zephir_array_update_zval(&bind, &field, &value, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&field); - } - ZEPHIR_INIT_VAR(&criteria); - object_init_ex(&criteria, phalcon_mvc_model_criteria_ce); - if (zephir_has_constructor(&criteria)) { - ZEPHIR_CALL_METHOD(NULL, &criteria, "__construct", NULL, 0); - zephir_check_call_status(); - } - - ZEPHIR_CALL_METHOD(NULL, &criteria, "setdi", NULL, 431, container); - zephir_check_call_status(); - if (zephir_fast_count_int(&conditions)) { - ZEPHIR_INIT_VAR(&_16$$16); - ZEPHIR_INIT_VAR(&_17$$16); - ZEPHIR_CONCAT_SVS(&_17$$16, " ", &operator, " "); - zephir_fast_join(&_16$$16, &_17$$16, &conditions); - ZEPHIR_CALL_METHOD(NULL, &criteria, "where", NULL, 440, &_16$$16); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &criteria, "bind", NULL, 441, &bind); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &criteria, "setmodelname", NULL, 432, &modelName); - zephir_check_call_status(); - RETURN_CCTOR(&criteria); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getColumns) -{ - zval columns, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&columns, &_0, SL("columns"), 1))) { - RETURN_NULL(); - } - RETURN_CTORW(&columns); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getConditions) -{ - zval conditions, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&conditions, &_0, SL("conditions"), 1))) { - RETURN_NULL(); - } - RETURN_CTORW(&conditions); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getDI) -{ - zval _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("di"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Criteria.zep", 379); - RETURN_CTORW(&_1); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getGroupBy) -{ - zval group, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&group, &_0, SL("group"), 1))) { - RETURN_NULL(); - } - RETURN_CTORW(&group); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getHaving) -{ - zval having, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&having, &_0, SL("having"), 1))) { - RETURN_NULL(); - } - RETURN_CTORW(&having); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getLimit) -{ - zval limit, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&limit, &_0, SL("limit"), 1))) { - RETURN_NULL(); + ZEPHIR_INIT_VAR(&schemaName); } - RETURN_CTORW(&limit); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getModelName) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "model"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getOrderBy) -{ - zval order, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&order); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&order, &_0, SL("order"), 1))) { - RETURN_NULL(); + if (UNEXPECTED(Z_TYPE_P(columnName_param) != IS_STRING && Z_TYPE_P(columnName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'columnName' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CTORW(&order); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getParams) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "params"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getWhere) -{ - zval conditions, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&_0); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&conditions, &_0, SL("conditions"), 1))) { - RETURN_NULL(); + if (EXPECTED(Z_TYPE_P(columnName_param) == IS_STRING)) { + zephir_get_strval(&columnName, columnName_param); + } else { + ZEPHIR_INIT_VAR(&columnName); } - RETURN_CTORW(&conditions); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, groupBy) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *group, group_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&group_sub); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(group) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &group); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "group"); - zephir_update_property_array(this_ptr, SL("params"), &_0, group); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " DROP COLUMN `", &columnName, "`"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, having) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *having, having_sub, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL, _0; + zval tableName, schemaName, referenceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&having_sub); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&referenceName); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(having) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(referenceName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &having); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceName_param) == IS_STRING)) { + zephir_get_strval(&referenceName, referenceName_param); + } else { + ZEPHIR_INIT_VAR(&referenceName); + } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "having"); - zephir_update_property_array(this_ptr, SL("params"), &_0, having); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " DROP FOREIGN KEY `", &referenceName, "`"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; - zval model; + zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL, _0; + zval tableName, schemaName, indexName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&indexName); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(indexName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&model); + ZEPHIR_INIT_VAR(&tableName); } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - if (!alias) { - alias = &alias_sub; - alias = &__$null; + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(indexName_param) == IS_STRING)) { + zephir_get_strval(&indexName, indexName_param); + } else { + ZEPHIR_INIT_VAR(&indexName); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "INNER"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " DROP INDEX `", &indexName, "`"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, inWhere) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropPrimaryKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, bindParams, bindKeys; - zval *expr_param = NULL, *values_param = NULL, hiddenParam, value, *_1, _2, _5, _6, _3$$4, _4$$5; - zval expr, key, queryKey, _0$$3; + zval *tableName_param = NULL, *schemaName_param = NULL, _0; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&queryKey); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindKeys); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&expr); + ZEPHIR_INIT_VAR(&tableName); } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - - - if (!(zephir_fast_count_int(&values))) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_VSV(&_0$$3, &expr, " != ", &expr); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_0$$3); - zephir_check_call_status(); - RETURN_THIS(); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_OBS_VAR(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Criteria.zep", 559); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _1) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - ZEPHIR_INIT_NVAR(&_3$$4); - ZEPHIR_CONCAT_SV(&_3$$4, "ACP", &hiddenParam); - zephir_get_strval(&key, &_3$$4); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 549); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_SEPARATE(&hiddenParam); - zephir_increment(&hiddenParam); - } ZEND_HASH_FOREACH_END(); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_4$$5); - ZEPHIR_CONCAT_SV(&_4$$5, "ACP", &hiddenParam); - zephir_get_strval(&key, &_4$$5); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 549); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_SEPARATE(&hiddenParam); - zephir_increment(&hiddenParam); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_5); - zephir_fast_join_str(&_5, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_VSVS(&_6, &expr, " IN (", &_5, ")"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_6, &bindParams); + + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &hiddenParam); - RETURN_THIS(); + ZEPHIR_CONCAT_SVS(return_value, "ALTER TABLE ", &_0, " DROP PRIMARY KEY"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, join) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropTable) { - zval join, _1$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, *type = NULL, type_sub, __$null, mergedJoins, currentJoins, _0, _4, _2$$5, _3$$6; - zval model; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool ifExists; + zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, table; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_UNDEF(&type_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&mergedJoins); - ZVAL_UNDEF(¤tJoins); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&table); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(model) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(tableName) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) - Z_PARAM_ZVAL_OR_NULL(type) + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&model); + ZEPHIR_INIT_VAR(&tableName); } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - if (!alias) { - alias = &alias_sub; - alias = &__$null; + if (!ifExists_param) { + ifExists = 1; + } else { + if (UNEXPECTED(Z_TYPE_P(ifExists_param) != IS_TRUE && Z_TYPE_P(ifExists_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be of the type bool")); + RETURN_MM_NULL(); } - if (!type) { - type = &type_sub; - type = &__$null; + ifExists = (Z_TYPE_P(ifExists_param) == IS_TRUE); } - ZEPHIR_INIT_VAR(&join); - zephir_create_array(&join, 4, 0); - zephir_array_fast_append(&join, &model); - zephir_array_fast_append(&join, conditions); - zephir_array_fast_append(&join, alias); - zephir_array_fast_append(&join, type); - ZEPHIR_OBS_VAR(¤tJoins); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tJoins, &_0, SL("joins"), 0)) { - if (Z_TYPE_P(¤tJoins) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, &join); - ZEPHIR_INIT_VAR(&mergedJoins); - zephir_fast_array_merge(&mergedJoins, ¤tJoins, &_1$$4); - } else { - ZEPHIR_INIT_VAR(&_2$$5); - zephir_create_array(&_2$$5, 1, 0); - zephir_array_fast_append(&_2$$5, &join); - ZEPHIR_CPY_WRT(&mergedJoins, &_2$$5); - } - } else { - ZEPHIR_INIT_VAR(&_3$$6); - zephir_create_array(&_3$$6, 1, 0); - zephir_array_fast_append(&_3$$6, &join); - ZEPHIR_CPY_WRT(&mergedJoins, &_3$$6); + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + if (ifExists) { + ZEPHIR_CONCAT_SV(return_value, "DROP TABLE IF EXISTS ", &table); + RETURN_MM(); } - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "joins"); - zephir_update_property_array(this_ptr, SL("params"), &_4, &mergedJoins); - RETURN_THIS(); + ZEPHIR_CONCAT_SV(return_value, "DROP TABLE ", &table); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, dropView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; - zval model; + zend_bool ifExists; + zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, view; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&view); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) + Z_PARAM_STR(viewName) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - ZEPHIR_INIT_VAR(&model); + ZEPHIR_INIT_VAR(&viewName); } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - if (!alias) { - alias = &alias_sub; - alias = &__$null; + if (!ifExists_param) { + ifExists = 1; + } else { + if (UNEXPECTED(Z_TYPE_P(ifExists_param) != IS_TRUE && Z_TYPE_P(ifExists_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be of the type bool")); + RETURN_MM_NULL(); + } + ifExists = (Z_TYPE_P(ifExists_param) == IS_TRUE); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "LEFT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); + ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, &viewName, &schemaName); zephir_check_call_status(); + if (ifExists) { + ZEPHIR_CONCAT_SV(return_value, "DROP VIEW IF EXISTS ", &view); + RETURN_MM(); + } + ZEPHIR_CONCAT_SV(return_value, "DROP VIEW ", &view); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, limit) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, getColumnDefinition) { - zval _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *limit_param = NULL, *offset_param = NULL, _0, _1, _2, _3$$4, _4$$4, _6$$5; - zend_long limit, offset, ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_41 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column, column_sub, columnType, columnSql, typeValues, _0$$3, _1$$3, _2$$3, _3$$5, _4$$11, _5$$15, _6$$17, _7$$18, _8$$18, _9$$18, _10$$20, _11$$20, _12$$20, _13$$22, _14$$24, _15$$24, _16$$24, _17$$26, _18$$26, _19$$26, _20$$36, _21$$36, _22$$36, _23$$40, _24$$40, _25$$40, _26$$44, _27$$46, _28$$47, _29$$49, _30$$52, _31$$52, _32$$52, _33$$56, _34$$59, _35$$59, _36$$59, value$$61, valueSql$$61, *_37$$61, _38$$61, _46$$61, _47$$61, _48$$61, _49$$61, _39$$62, _40$$62, _42$$62, _43$$63, _44$$63, _45$$63, _50$$64, _51$$64, _52$$64; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&columnType); + ZVAL_UNDEF(&columnSql); + ZVAL_UNDEF(&typeValues); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$11); + ZVAL_UNDEF(&_5$$15); + ZVAL_UNDEF(&_6$$17); + ZVAL_UNDEF(&_7$$18); + ZVAL_UNDEF(&_8$$18); + ZVAL_UNDEF(&_9$$18); + ZVAL_UNDEF(&_10$$20); + ZVAL_UNDEF(&_11$$20); + ZVAL_UNDEF(&_12$$20); + ZVAL_UNDEF(&_13$$22); + ZVAL_UNDEF(&_14$$24); + ZVAL_UNDEF(&_15$$24); + ZVAL_UNDEF(&_16$$24); + ZVAL_UNDEF(&_17$$26); + ZVAL_UNDEF(&_18$$26); + ZVAL_UNDEF(&_19$$26); + ZVAL_UNDEF(&_20$$36); + ZVAL_UNDEF(&_21$$36); + ZVAL_UNDEF(&_22$$36); + ZVAL_UNDEF(&_23$$40); + ZVAL_UNDEF(&_24$$40); + ZVAL_UNDEF(&_25$$40); + ZVAL_UNDEF(&_26$$44); + ZVAL_UNDEF(&_27$$46); + ZVAL_UNDEF(&_28$$47); + ZVAL_UNDEF(&_29$$49); + ZVAL_UNDEF(&_30$$52); + ZVAL_UNDEF(&_31$$52); + ZVAL_UNDEF(&_32$$52); + ZVAL_UNDEF(&_33$$56); + ZVAL_UNDEF(&_34$$59); + ZVAL_UNDEF(&_35$$59); + ZVAL_UNDEF(&_36$$59); + ZVAL_UNDEF(&value$$61); + ZVAL_UNDEF(&valueSql$$61); + ZVAL_UNDEF(&_38$$61); + ZVAL_UNDEF(&_46$$61); + ZVAL_UNDEF(&_47$$61); + ZVAL_UNDEF(&_48$$61); + ZVAL_UNDEF(&_49$$61); + ZVAL_UNDEF(&_39$$62); + ZVAL_UNDEF(&_40$$62); + ZVAL_UNDEF(&_42$$62); + ZVAL_UNDEF(&_43$$63); + ZVAL_UNDEF(&_44$$63); + ZVAL_UNDEF(&_45$$63); + ZVAL_UNDEF(&_50$$64); + ZVAL_UNDEF(&_51$$64); + ZVAL_UNDEF(&_52$$64); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_LONG(limit) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(offset) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &limit_param, &offset_param); - limit = zephir_get_intval(limit_param); - if (!offset_param) { - offset = 0; - } else { - offset = zephir_get_intval(offset_param); - } + zephir_fetch_params(1, 1, 0, &column); - ZVAL_LONG(&_0, limit); - ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 283, &_0); + ZEPHIR_CALL_METHOD(&columnSql, this_ptr, "checkcolumntypesql", NULL, 0, column); zephir_check_call_status(); - limit = zephir_get_numberval(&_1); - ZVAL_LONG(&_0, offset); - ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 283, &_0); + ZEPHIR_CALL_METHOD(&columnType, this_ptr, "checkcolumntype", NULL, 0, column); zephir_check_call_status(); - offset = zephir_get_numberval(&_2); - if (UNEXPECTED(limit == 0)) { - RETURN_THIS(); - } - if (offset == 0) { - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "limit"); - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_LONG(&_4$$4, limit); - zephir_update_property_array(this_ptr, SL("params"), &_3$$4, &_4$$4); + do { + if (ZEPHIR_IS_LONG(&columnType, 14)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("BIGINT")); + } + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_VV(&_2$$3, &_0$$3, &_1$$3); + zephir_concat_self(&columnSql, &_2$$3); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 19)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("BIT")); + } + ZEPHIR_CALL_METHOD(&_3$$5, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_3$$5); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 11)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("BLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 8)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TINYINT(1)")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 5)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("CHAR")); + } + ZEPHIR_CALL_METHOD(&_4$$11, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_4$$11); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 1)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DATE")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 4)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DATETIME")); + } + ZEPHIR_CALL_METHOD(&_5$$15, column, "getsize", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_GT_LONG(&_5$$15, 0)) { + ZEPHIR_CALL_METHOD(&_6$$17, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_6$$17); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 3)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DECIMAL")); + } + ZEPHIR_CALL_METHOD(&_7$$18, this_ptr, "getcolumnsizeandscale", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8$$18, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_9$$18); + ZEPHIR_CONCAT_VV(&_9$$18, &_7$$18, &_8$$18); + zephir_concat_self(&columnSql, &_9$$18); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 9)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DOUBLE")); + } + ZEPHIR_CALL_METHOD(&_10$$20, this_ptr, "checkcolumnsizeandscale", NULL, 216, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_11$$20, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_12$$20); + ZEPHIR_CONCAT_VV(&_12$$20, &_10$$20, &_11$$20); + zephir_concat_self(&columnSql, &_12$$20); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 18)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("ENUM")); + } + ZEPHIR_CALL_METHOD(&_13$$22, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_13$$22); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 7)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("FLOAT")); + } + ZEPHIR_CALL_METHOD(&_14$$24, this_ptr, "checkcolumnsizeandscale", NULL, 216, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_15$$24, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_16$$24); + ZEPHIR_CONCAT_VV(&_16$$24, &_14$$24, &_15$$24); + zephir_concat_self(&columnSql, &_16$$24); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 0)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("INT")); + } + ZEPHIR_CALL_METHOD(&_17$$26, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_18$$26, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_19$$26); + ZEPHIR_CONCAT_VV(&_19$$26, &_17$$26, &_18$$26); + zephir_concat_self(&columnSql, &_19$$26); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 15)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("JSON")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 13)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("LONGBLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 24)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("LONGTEXT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 12)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("MEDIUMBLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 21)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("MEDIUMINT")); + } + ZEPHIR_CALL_METHOD(&_20$$36, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_21$$36, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_22$$36); + ZEPHIR_CONCAT_VV(&_22$$36, &_20$$36, &_21$$36); + zephir_concat_self(&columnSql, &_22$$36); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 23)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("MEDIUMTEXT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 22)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("SMALLINT")); + } + ZEPHIR_CALL_METHOD(&_23$$40, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24$$40, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_25$$40); + ZEPHIR_CONCAT_VV(&_25$$40, &_23$$40, &_24$$40); + zephir_concat_self(&columnSql, &_25$$40); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 6)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TEXT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 20)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TIME")); + } + ZEPHIR_CALL_METHOD(&_26$$44, column, "getsize", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_GT_LONG(&_26$$44, 0)) { + ZEPHIR_CALL_METHOD(&_27$$46, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_27$$46); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 17)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TIMESTAMP")); + } + ZEPHIR_CALL_METHOD(&_28$$47, column, "getsize", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_GT_LONG(&_28$$47, 0)) { + ZEPHIR_CALL_METHOD(&_29$$49, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_29$$49); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 10)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TINYBLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 26)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TINYINT")); + } + ZEPHIR_CALL_METHOD(&_30$$52, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_31$$52, this_ptr, "checkcolumnunsigned", NULL, 215, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_32$$52); + ZEPHIR_CONCAT_VV(&_32$$52, &_30$$52, &_31$$52); + zephir_concat_self(&columnSql, &_32$$52); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 25)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TINYTEXT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 2)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("VARCHAR")); + } + ZEPHIR_CALL_METHOD(&_33$$56, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_33$$56); + break; + } + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&columnSql))) { + ZEPHIR_INIT_VAR(&_34$$59); + object_init_ex(&_34$$59, phalcon_db_exception_ce); + ZEPHIR_CALL_METHOD(&_35$$59, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_36$$59); + ZEPHIR_CONCAT_SV(&_36$$59, "Unrecognized MySQL data type at column ", &_35$$59); + ZEPHIR_CALL_METHOD(NULL, &_34$$59, "__construct", NULL, 32, &_36$$59); + zephir_check_call_status(); + zephir_throw_exception_debug(&_34$$59, "phalcon/Db/Dialect/Mysql.zep", 635); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&typeValues, column, "gettypevalues", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&typeValues))) { + if (Z_TYPE_P(&typeValues) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&valueSql$$61); + ZVAL_STRING(&valueSql$$61, ""); + zephir_is_iterable(&typeValues, 0, "phalcon/Db/Dialect/Mysql.zep", 649); + if (Z_TYPE_P(&typeValues) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&typeValues), _37$$61) + { + ZEPHIR_INIT_NVAR(&value$$61); + ZVAL_COPY(&value$$61, _37$$61); + ZEPHIR_INIT_NVAR(&_39$$62); + ZVAL_STRING(&_39$$62, "\""); + ZEPHIR_CALL_FUNCTION(&_40$$62, "addcslashes", &_41, 214, &value$$61, &_39$$62); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_42$$62); + ZEPHIR_CONCAT_SVS(&_42$$62, "\"", &_40$$62, "\", "); + zephir_concat_self(&valueSql$$61, &_42$$62); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &typeValues, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_38$$61, &typeValues, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_38$$61)) { + break; + } + ZEPHIR_CALL_METHOD(&value$$61, &typeValues, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_43$$63); + ZVAL_STRING(&_43$$63, "\""); + ZEPHIR_CALL_FUNCTION(&_44$$63, "addcslashes", &_41, 214, &value$$61, &_43$$63); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_45$$63); + ZEPHIR_CONCAT_SVS(&_45$$63, "\"", &_44$$63, "\", "); + zephir_concat_self(&valueSql$$61, &_45$$63); + ZEPHIR_CALL_METHOD(NULL, &typeValues, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value$$61); + ZVAL_LONG(&_46$$61, 0); + ZVAL_LONG(&_47$$61, -2); + ZEPHIR_INIT_VAR(&_48$$61); + zephir_substr(&_48$$61, &valueSql$$61, 0 , -2 , 0); + ZEPHIR_INIT_VAR(&_49$$61); + ZEPHIR_CONCAT_SVS(&_49$$61, "(", &_48$$61, ")"); + zephir_concat_self(&columnSql, &_49$$61); + } else { + ZEPHIR_INIT_VAR(&_50$$64); + ZVAL_STRING(&_50$$64, "\""); + ZEPHIR_CALL_FUNCTION(&_51$$64, "addcslashes", &_41, 214, &typeValues, &_50$$64); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_52$$64); + ZEPHIR_CONCAT_SVS(&_52$$64, "(\"", &_51$$64, "\")"); + zephir_concat_self(&columnSql, &_52$$64); + } + } + } while(0); + + RETURN_CCTOR(&columnSql); +} + +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, getForeignKeyChecks) +{ + zval *this_ptr = getThis(); + + + + RETURN_STRING("SELECT @@foreign_key_checks"); +} + +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, listTables) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *schemaName_param = NULL; + zval schemaName; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&schemaName); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); } else { - ZEPHIR_INIT_VAR(&_5$$5); - zephir_create_array(&_5$$5, 2, 0); - ZEPHIR_INIT_VAR(&_6$$5); - ZVAL_LONG(&_6$$5, limit); - zephir_array_update_string(&_5$$5, SL("number"), &_6$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_6$$5); - ZVAL_LONG(&_6$$5, offset); - zephir_array_update_string(&_5$$5, SL("offset"), &_6$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_6$$5); - ZVAL_STRING(&_6$$5, "limit"); - zephir_update_property_array(this_ptr, SL("params"), &_6$$5, &_5$$5); + zephir_get_strval(&schemaName, schemaName_param); } - RETURN_THIS(); + + + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CONCAT_SVS(return_value, "SHOW TABLES FROM `", &schemaName, "`"); + RETURN_MM(); + } + RETURN_MM_STRING("SHOW TABLES"); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notBetweenWhere) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, listViews) { - zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, _0, _1; - zval expr, minimumKey, maximumKey, _2; + zval *schemaName_param = NULL; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&expr); + ZEPHIR_INIT_VAR(&schemaName); + } } - ZEPHIR_OBS_VAR(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_SV(&_0, "ACP", &hiddenParam); - zephir_get_strval(&minimumKey, &_0); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SV(&_1, "ACP", &nextHiddenParam); - zephir_get_strval(&maximumKey, &_1); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSVSVS(&_2, &expr, " NOT BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 2, 0); - zephir_array_update_zval(&_3, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_3, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_SEPARATE(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CONCAT_SVS(return_value, "SELECT `TABLE_NAME` AS view_name FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_SCHEMA` = '", &schemaName, "' ORDER BY view_name"); + RETURN_MM(); + } + RETURN_MM_STRING("SELECT `TABLE_NAME` AS view_name FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_SCHEMA` = DATABASE() ORDER BY view_name"); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notInWhere) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, modifyColumn) { + zend_bool _11$$8, _12$$8, _13$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, bindParams, bindKeys; - zval *expr_param = NULL, *values_param = NULL, hiddenParam, value, *_0, _1, _6, _7, _2$$3, _4$$4; - zval expr, key, _3$$3, _5$$4; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, *currentColumn = NULL, currentColumn_sub, __$null, afterPosition, defaultValue, upperDefaultValue, columnDefinition, _0, _1, _2, _3, _9, _10, _19, _20, _23, _4$$4, _5$$4, _6$$4, _7$$5, _8$$5, _14$$8, _15$$9, _16$$10, _17$$10, _18$$10, _21$$12, _22$$12, _24$$15; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(¤tColumn_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&afterPosition); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&upperDefaultValue); + ZVAL_UNDEF(&columnDefinition); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_19); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_23); ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindKeys); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&_15$$9); + ZVAL_UNDEF(&_16$$10); + ZVAL_UNDEF(&_17$$10); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_21$$12); + ZVAL_UNDEF(&_22$$12); + ZVAL_UNDEF(&_24$$15); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(currentColumn, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&expr); + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + if (!currentColumn) { + currentColumn = ¤tColumn_sub; + ZEPHIR_CPY_WRT(currentColumn, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(currentColumn); } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - ZEPHIR_OBS_VAR(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Criteria.zep", 742); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _0) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_INIT_NVAR(&_2$$3); - ZEPHIR_CONCAT_SV(&_2$$3, "ACP", &hiddenParam); - zephir_get_strval(&key, &_2$$3); - ZEPHIR_INIT_NVAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, ":", &key, ":"); - zephir_array_append(&bindKeys, &_3$$3, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 732); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_SEPARATE(&hiddenParam); - zephir_increment(&hiddenParam); - } ZEND_HASH_FOREACH_END(); + ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "ALTER TABLE ", &_0); + zephir_get_strval(&sql, &_1); + if (Z_TYPE_P(currentColumn) != IS_OBJECT) { + ZEPHIR_CPY_WRT(currentColumn, column); + } + ZEPHIR_CALL_METHOD(&_2, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, currentColumn, "getname", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_2, &_3)) { + ZEPHIR_CALL_METHOD(&_4$$4, currentColumn, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6$$4); + ZEPHIR_CONCAT_SVSVSV(&_6$$4, " CHANGE COLUMN `", &_4$$4, "` `", &_5$$4, "` ", &columnDefinition); + zephir_concat_self(&sql, &_6$$4); } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(&_7$$5, column, "getname", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + ZEPHIR_INIT_VAR(&_8$$5); + ZEPHIR_CONCAT_SVSV(&_8$$5, " MODIFY `", &_7$$5, "` ", &columnDefinition); + zephir_concat_self(&sql, &_8$$5); + } + ZEPHIR_CALL_METHOD(&_9, column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_9)) { + zephir_concat_self_str(&sql, " NOT NULL", sizeof(" NOT NULL") - 1); + } else { + zephir_concat_self_str(&sql, " NULL", sizeof(" NULL") - 1); + } + ZEPHIR_CALL_METHOD(&_10, column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_10)) { + ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&upperDefaultValue); + zephir_fast_strtoupper(&upperDefaultValue, &defaultValue); + _11$$8 = zephir_memnstr_str(&upperDefaultValue, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Mysql.zep", 731); + if (!(_11$$8)) { + _11$$8 = zephir_memnstr_str(&upperDefaultValue, SL("NULL"), "phalcon/Db/Dialect/Mysql.zep", 731); + } + _12$$8 = _11$$8; + if (!(_12$$8)) { + _12$$8 = Z_TYPE_P(&defaultValue) == IS_LONG; + } + _13$$8 = _12$$8; + if (!(_13$$8)) { + ZEPHIR_CALL_FUNCTION(&_14$$8, "is_float", NULL, 213, &defaultValue); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_4$$4); - ZEPHIR_CONCAT_SV(&_4$$4, "ACP", &hiddenParam); - zephir_get_strval(&key, &_4$$4); - ZEPHIR_INIT_NVAR(&_5$$4); - ZEPHIR_CONCAT_SVS(&_5$$4, ":", &key, ":"); - zephir_array_append(&bindKeys, &_5$$4, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 732); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_SEPARATE(&hiddenParam); - zephir_increment(&hiddenParam); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + _13$$8 = zephir_is_true(&_14$$8); + } + if (_13$$8) { + ZEPHIR_INIT_VAR(&_15$$9); + ZEPHIR_CONCAT_SV(&_15$$9, " DEFAULT ", &defaultValue); + zephir_concat_self(&sql, &_15$$9); + } else { + ZEPHIR_INIT_VAR(&_16$$10); + ZVAL_STRING(&_16$$10, "\""); + ZEPHIR_CALL_FUNCTION(&_17$$10, "addcslashes", NULL, 214, &defaultValue, &_16$$10); zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_18$$10); + ZEPHIR_CONCAT_SVS(&_18$$10, " DEFAULT \"", &_17$$10, "\""); + zephir_concat_self(&sql, &_18$$10); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_6); - zephir_fast_join_str(&_6, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_7); - ZEPHIR_CONCAT_VSVS(&_7, &expr, " NOT IN (", &_6, ")"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_7, &bindParams); + ZEPHIR_CALL_METHOD(&_19, column, "isautoincrement", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &hiddenParam); - RETURN_THIS(); + if (zephir_is_true(&_19)) { + zephir_concat_self_str(&sql, " AUTO_INCREMENT", sizeof(" AUTO_INCREMENT") - 1); + } + ZEPHIR_CALL_METHOD(&_20, column, "getcomment", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_20)) { + ZEPHIR_CALL_METHOD(&_21$$12, column, "getcomment", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_22$$12); + ZEPHIR_CONCAT_SVS(&_22$$12, " COMMENT '", &_21$$12, "'"); + zephir_concat_self(&sql, &_22$$12); + } + ZEPHIR_CALL_METHOD(&_23, column, "isfirst", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_23)) { + zephir_concat_self_str(&sql, " FIRST", sizeof(" FIRST") - 1); + } else { + ZEPHIR_CALL_METHOD(&afterPosition, column, "getafterposition", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&afterPosition)) { + ZEPHIR_INIT_VAR(&_24$$15); + ZEPHIR_CONCAT_SVS(&_24$$15, " AFTER `", &afterPosition, "`"); + zephir_concat_self(&sql, &_24$$15); + } + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orderBy) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, sharedLock) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *orderColumns_param = NULL, _0; - zval orderColumns; + zval *sqlQuery_param = NULL; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&orderColumns); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&sqlQuery); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(orderColumns) + Z_PARAM_STR(sqlQuery) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &orderColumns_param); - if (UNEXPECTED(Z_TYPE_P(orderColumns_param) != IS_STRING && Z_TYPE_P(orderColumns_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'orderColumns' must be of the type string")); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(orderColumns_param) == IS_STRING)) { - zephir_get_strval(&orderColumns, orderColumns_param); + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); } else { - ZEPHIR_INIT_VAR(&orderColumns); + ZEPHIR_INIT_VAR(&sqlQuery); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "order"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &orderColumns); - RETURN_THIS(); + ZEPHIR_CONCAT_VS(return_value, &sqlQuery, " LOCK IN SHARE MODE"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, tableExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentConditions, _0, _1$$3; - zval conditions; + zval *tableName_param = NULL, *schemaName_param = NULL; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tableName) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(bindParams) - Z_PARAM_ZVAL_OR_NULL(bindTypes) + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; + ZEPHIR_INIT_VAR(&tableName); } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - ZEPHIR_OBS_VAR(¤tConditions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tConditions, &_0, SL("conditions"), 0)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVSVS(&_1$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); - zephir_get_strval(&conditions, &_1$$3); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CONCAT_SVSVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME`= '", &tableName, "' AND `TABLE_SCHEMA` = '", &schemaName, "'"); + RETURN_MM(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, bindParams, bindTypes); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME` = '", &tableName, "' AND `TABLE_SCHEMA` = DATABASE()"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, tableOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; - zval model; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&sql); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; + ZEPHIR_INIT_VAR(&table); } - if (!alias) { - alias = &alias_sub; - alias = &__$null; + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "RIGHT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&sql); + ZVAL_STRING(&sql, "SELECT TABLES.TABLE_TYPE AS table_type,TABLES.AUTO_INCREMENT AS auto_increment,TABLES.ENGINE AS engine,TABLES.TABLE_COLLATION AS table_collation FROM INFORMATION_SCHEMA.TABLES WHERE "); + if (!(ZEPHIR_IS_EMPTY(&schema))) { + ZEPHIR_CONCAT_VSVSVS(return_value, &sql, "TABLES.TABLE_SCHEMA = '", &schema, "' AND TABLES.TABLE_NAME = '", &table, "'"); + RETURN_MM(); + } + ZEPHIR_CONCAT_VSVS(return_value, &sql, "TABLES.TABLE_SCHEMA = DATABASE() AND TABLES.TABLE_NAME = '", &table, "'"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setDI) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, truncateTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *container, container_sub, _0; + zval *tableName_param = NULL, *schemaName_param = NULL; + zval tableName, schemaName, table; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&table); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &container); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "di"); - zephir_update_property_array(this_ptr, SL("params"), &_0, container); - ZEPHIR_MM_RESTORE(); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_INIT_VAR(&table); + ZEPHIR_CONCAT_SVSVS(&table, "`", &schemaName, "`.`", &tableName, "`"); + } else { + ZEPHIR_INIT_NVAR(&table); + ZEPHIR_CONCAT_SVS(&table, "`", &tableName, "`"); + } + ZEPHIR_CONCAT_SV(return_value, "TRUNCATE TABLE ", &table); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setModelName) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, viewExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *modelName_param = NULL; - zval modelName; + zval *viewName_param = NULL, *schemaName_param = NULL; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(modelName) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(viewName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &modelName_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&viewName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &modelName); - RETURN_THIS(); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CONCAT_SVSVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_NAME`= '", &viewName, "' AND `TABLE_SCHEMA`='", &schemaName, "'"); + RETURN_MM(); + } + ZEPHIR_CONCAT_SVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_NAME`='", &viewName, "' AND `TABLE_SCHEMA` = DATABASE()"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, sharedLock) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, getTableOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *sharedLock_param = NULL, _0, _1; - zend_bool sharedLock; + zval *definition_param = NULL, options, engine, autoIncrement, tableCollation, collationParts, _0$$5, _1$$7, _2$$9, _3$$9, _4$$9; + zval definition, tableOptions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&tableOptions); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&engine); + ZVAL_UNDEF(&autoIncrement); + ZVAL_UNDEF(&tableCollation); + ZVAL_UNDEF(&collationParts); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$7); + ZVAL_UNDEF(&_2$$9); + ZVAL_UNDEF(&_3$$9); + ZVAL_UNDEF(&_4$$9); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(sharedLock) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &sharedLock_param); - if (!sharedLock_param) { - sharedLock = 1; - } else { - sharedLock = zephir_get_boolval(sharedLock_param); - } + zephir_fetch_params(1, 1, 0, &definition_param); + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "shared_lock"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, sharedLock); - zephir_update_property_array(this_ptr, SL("params"), &_0, &_1); - RETURN_THIS(); + ZEPHIR_OBS_VAR(&options); + if (!(zephir_array_isset_string_fetch(&options, &definition, SL("options"), 0))) { + RETURN_MM_STRING(""); + } + ZEPHIR_INIT_VAR(&tableOptions); + array_init(&tableOptions); + ZEPHIR_OBS_VAR(&engine); + if (zephir_array_isset_string_fetch(&engine, &options, SL("ENGINE"), 0)) { + if (zephir_is_true(&engine)) { + ZEPHIR_INIT_VAR(&_0$$5); + ZEPHIR_CONCAT_SV(&_0$$5, "ENGINE=", &engine); + zephir_array_append(&tableOptions, &_0$$5, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 857); + } + } + ZEPHIR_OBS_VAR(&autoIncrement); + if (zephir_array_isset_string_fetch(&autoIncrement, &options, SL("AUTO_INCREMENT"), 0)) { + if (zephir_is_true(&autoIncrement)) { + ZEPHIR_INIT_VAR(&_1$$7); + ZEPHIR_CONCAT_SV(&_1$$7, "AUTO_INCREMENT=", &autoIncrement); + zephir_array_append(&tableOptions, &_1$$7, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 866); + } + } + ZEPHIR_OBS_VAR(&tableCollation); + if (zephir_array_isset_string_fetch(&tableCollation, &options, SL("TABLE_COLLATION"), 0)) { + if (zephir_is_true(&tableCollation)) { + ZEPHIR_INIT_VAR(&collationParts); + zephir_fast_explode_str(&collationParts, SL("_"), &tableCollation, LONG_MAX); + zephir_array_fetch_long(&_2$$9, &collationParts, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect/Mysql.zep", 876); + ZEPHIR_INIT_VAR(&_3$$9); + ZEPHIR_CONCAT_SV(&_3$$9, "DEFAULT CHARSET=", &_2$$9); + zephir_array_append(&tableOptions, &_3$$9, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 876); + ZEPHIR_INIT_VAR(&_4$$9); + ZEPHIR_CONCAT_SV(&_4$$9, "COLLATE=", &tableCollation); + zephir_array_append(&tableOptions, &_4$$9, PH_SEPARATE, "phalcon/Db/Dialect/Mysql.zep", 877); + } + } + zephir_fast_join_str(return_value, SL(" "), &tableOptions); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, where) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, checkColumnSizeAndScale) { + zval columnSql; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentBindParams, currentBindTypes, _0, _1$$3, _2$$4, _3$$4, _4$$5, _5$$6, _6$$7, _7$$7, _8$$8; - zval conditions; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column, column_sub, _0, _1$$3, _2$$3, _3$$3, _4$$4, _5$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(¤tBindTypes); + ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&columnSql); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(bindParams) - Z_PARAM_ZVAL_OR_NULL(bindTypes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; - } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; - } + zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "conditions"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &conditions); - if (Z_TYPE_P(bindParams) == IS_ARRAY) { - ZEPHIR_OBS_VAR(¤tBindParams); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tBindParams, &_1$$3, SL("bind"), 0)) { - ZEPHIR_INIT_VAR(&_2$$4); - zephir_fast_array_merge(&_2$$4, ¤tBindParams, bindParams); - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_3$$4, &_2$$4); - } else { - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_4$$5, bindParams); - } - } - if (Z_TYPE_P(bindTypes) == IS_ARRAY) { - ZEPHIR_OBS_VAR(¤tBindTypes); - zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tBindTypes, &_5$$6, SL("bindTypes"), 0)) { - ZEPHIR_INIT_VAR(&_6$$7); - zephir_fast_array_merge(&_6$$7, ¤tBindTypes, bindTypes); - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_STRING(&_7$$7, "bindTypes"); - zephir_update_property_array(this_ptr, SL("params"), &_7$$7, &_6$$7); + ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_METHOD(&_1$$3, column, "getsize", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SV(&_2$$3, "(", &_1$$3); + zephir_concat_self(&columnSql, &_2$$3); + ZEPHIR_CALL_METHOD(&_3$$3, column, "getscale", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_3$$3)) { + ZEPHIR_CALL_METHOD(&_4$$4, column, "getscale", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_SVS(&_5$$4, ",", &_4$$4, ")"); + zephir_concat_self(&columnSql, &_5$$4); } else { - ZEPHIR_INIT_VAR(&_8$$8); - ZVAL_STRING(&_8$$8, "bindTypes"); - zephir_update_property_array(this_ptr, SL("params"), &_8$$8, bindTypes); + zephir_concat_self_str(&columnSql, ")", sizeof(")") - 1); } } - RETURN_THIS(); + RETURN_CTOR(&columnSql); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Criteria(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Dialect_Mysql, checkColumnUnsigned) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_CriteriaInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, CriteriaInterface, phalcon, mvc_model_criteriainterface, phalcon_mvc_model_criteriainterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, andWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, betweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bind); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, cache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, conditions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, distinct); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, execute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, forUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getColumns); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getConditions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getGroupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getHaving); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getLimit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getModelName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getOrderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, groupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, having); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, innerJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, inWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, leftJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, limit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notBetweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notInWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, rightJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, setModelName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, sharedLock); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, where); - - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column, column_sub, _0; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &column); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Exception, phalcon, mvc_model_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; + ZEPHIR_CALL_METHOD(&_0, column, "isunsigned", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_STRING(" UNSIGNED"); + } + RETURN_MM_STRING(""); } @@ -66357,4120 +60509,4669 @@ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Manager) +ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_Postgresql) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Manager, phalcon, mvc_model_manager, phalcon_mvc_model_manager_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("aliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("behaviors"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsTo"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsToSingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("builder"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("customEventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("dynamicUpdate"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasMany"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManySingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToMany"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToManySingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOne"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneSingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThrough"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThroughSingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("initialized"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("keepSnapshots"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastInitialized"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastQuery"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("modelVisibility"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_model_manager_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("readConnectionServices"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("sources"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("schemas"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("writeConnectionServices"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("reusable"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_manager_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Manager; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, Postgresql, phalcon, db_dialect_postgresql, phalcon_db_dialect_ce, phalcon_db_dialect_postgresql_method_entry, 0); - zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_mvc_model_managerinterface_ce); - zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_events_eventsawareinterface_ce); + zend_declare_property_string(phalcon_db_dialect_postgresql_ce, SL("escapeChar"), "\"", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, __destruct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *this_ptr = getThis(); - - - - ZEPHIR_MM_GROW(); - - phalcon_orm_destroy_cache(); - ZEPHIR_CALL_CE_STATIC(NULL, phalcon_mvc_model_query_ce, "clean", &_0, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBehavior) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, *behavior, behavior_sub, entityName, _0, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&behavior_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(behavior, phalcon_mvc_model_behaviorinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &behavior); - - - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &entityName))) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_array(this_ptr, SL("behaviors"), &entityName, &_1$$3); - } - zephir_update_property_array_multi(this_ptr, SL("behaviors"), behavior, SL("za"), 2, &entityName); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBelongsTo) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, columnDefinition, _0, _1, _2, _3, _4, _7, _5$$3, _6$$3; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&columnDefinition); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&referencedModel); + ZEPHIR_INIT_VAR(&tableName); } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(referencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 296); - return; - } + ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "ALTER TABLE ", &_0, " ADD COLUMN "); + zephir_get_strval(&sql, &_1); + ZEPHIR_CALL_METHOD(&_2, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SVSV(&_3, "\"", &_2, "\" ", &columnDefinition); + zephir_concat_self(&sql, &_3); + ZEPHIR_CALL_METHOD(&_4, column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_4)) { + ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "castdefault", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6$$3); + ZEPHIR_CONCAT_SV(&_6$$3, " DEFAULT ", &_5$$3); + zephir_concat_self(&sql, &_6$$3); } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 442, &_2, &referencedModel, fields, referencedFields, &options); + ZEPHIR_CALL_METHOD(&_7, column, "isnotnull", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_VAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 316); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); + if (zephir_is_true(&_7)) { + zephir_concat_self_str(&sql, " NOT NULL", sizeof(" NOT NULL") - 1); } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); - } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 329); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation); - zephir_update_property_array(this_ptr, SL("belongsTo"), &keyRelation, &relations); - ZEPHIR_OBS_VAR(&singleRelations); - zephir_read_property(&_2, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + zephir_concat_self_str(&sql, " NULL", sizeof(" NULL") - 1); } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 343); - zephir_update_property_array(this_ptr, SL("belongsToSingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasMany, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2; + zval *tableName_param = NULL, *schemaName_param = NULL, *reference, reference_sub, onDelete, onUpdate, _0, _1, _2, _5, _6, _7, _8, _9, _10, _3$$3, _4$$3, _11$$4, _12$$5; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&hasMany); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&reference_sub); + ZVAL_UNDEF(&onDelete); + ZVAL_UNDEF(&onUpdate); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_11$$4); + ZVAL_UNDEF(&_12$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(reference, phalcon_db_referenceinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&referencedModel); + ZEPHIR_INIT_VAR(&tableName); } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hasMany, &_1); - ZEPHIR_OBS_VAR(&relations); - if (!(zephir_array_isset_fetch(&relations, &hasMany, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(referencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 392); - return; - } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "ALTER TABLE ", &_0, " ADD"); + zephir_get_strval(&sql, &_1); + ZEPHIR_CALL_METHOD(&_2, reference, "getname", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_2)) { + ZEPHIR_CALL_METHOD(&_3$$3, reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_SVS(&_4$$3, " CONSTRAINT \"", &_3$$3, "\""); + zephir_concat_self(&sql, &_4$$3); } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_1, 2); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 442, &_1, &referencedModel, fields, referencedFields, &options); + ZEPHIR_CALL_METHOD(&_6, reference, "getcolumns", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_VAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 412); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getcolumnlist", NULL, 57, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7, reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9, reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "getcolumnlist", NULL, 57, &_9); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_CONCAT_SVSSVSVS(&_10, " FOREIGN KEY (", &_5, ")", " REFERENCES \"", &_7, "\" (", &_8, ")"); + zephir_concat_self(&sql, &_10); + ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_VAR(&_11$$4); + ZEPHIR_CONCAT_SV(&_11$$4, " ON DELETE ", &onDelete); + zephir_concat_self(&sql, &_11$$4); } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 425); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); - zephir_update_property_array(this_ptr, SL("hasMany"), &keyRelation, &relations); - ZEPHIR_OBS_VAR(&singleRelations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_VAR(&_12$$5); + ZEPHIR_CONCAT_SV(&_12$$5, " ON UPDATE ", &onUpdate); + zephir_concat_self(&sql, &_12$$5); } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 439); - zephir_update_property_array(this_ptr, SL("hasManySingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasManyToMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval intermediateModel, referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasManyToMany, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, indexType, _0, _2, _3, _4, _5, _6, _7, _1$$4; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&hasManyToMany); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); - ZVAL_UNDEF(&intermediateEntity); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&indexType); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(7, 8) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_ZVAL(intermediateReferencedFields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&intermediateModel); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&intermediateEntity); - zephir_fast_strtolower(&intermediateEntity, &intermediateModel); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hasManyToMany, &_1); - ZEPHIR_OBS_VAR(&relations); - if (!(zephir_array_isset_fetch(&relations, &hasManyToMany, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 496); - return; - } + ZEPHIR_CALL_METHOD(&_0, index, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING_IDENTICAL(&_0, "PRIMARY")) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addprimarykey", NULL, 0, &tableName, &schemaName, index); + zephir_check_call_status(); + RETURN_MM(); } - if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 508); - return; - } + ZEPHIR_INIT_VAR(&sql); + ZVAL_STRING(&sql, "CREATE"); + ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&indexType))) { + ZEPHIR_INIT_VAR(&_1$$4); + ZEPHIR_CONCAT_SV(&_1$$4, " ", &indexType); + zephir_concat_self(&sql, &_1$$4); } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_1, 4); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 442, &_1, &referencedModel, fields, referencedFields, &options); + ZEPHIR_CALL_METHOD(&_2, index, "getname", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 443, intermediateFields, &intermediateModel, intermediateReferencedFields); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); - ZEPHIR_OBS_VAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (Z_TYPE_P(&alias) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 537); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); - } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 548); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); - zephir_update_property_array(this_ptr, SL("hasManyToMany"), &keyRelation, &relations); - ZEPHIR_OBS_VAR(&singleRelations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); - } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 570); - zephir_update_property_array(this_ptr, SL("hasManyToManySingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SVSV(&_4, " INDEX \"", &_2, "\" ON ", &_3); + zephir_concat_self(&sql, &_4); + ZEPHIR_CALL_METHOD(&_6, index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getcolumnlist", NULL, 57, &_6); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_7); + ZEPHIR_CONCAT_SVS(&_7, " (", &_5, ")"); + zephir_concat_self(&sql, &_7); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOne) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addPrimaryKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, _0, _1, _2; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&referencedModel); + ZEPHIR_INIT_VAR(&tableName); } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(referencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 618); - return; - } - } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_2, 1); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 442, &_2, &referencedModel, fields, referencedFields, &options); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); - ZEPHIR_OBS_VAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 638); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); - } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 651); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation); - zephir_update_property_array(this_ptr, SL("hasOne"), &keyRelation, &relations); - ZEPHIR_OBS_VAR(&singleRelations); - zephir_read_property(&_2, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); - } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 665); - zephir_update_property_array(this_ptr, SL("hasOneSingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + ZEPHIR_CALL_METHOD(&_2, index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcolumnlist", NULL, 57, &_2); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVSVS(return_value, "ALTER TABLE ", &_0, " ADD CONSTRAINT \"", &tableName, "_PRIMARY\" PRIMARY KEY (", &_1, ")"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOneThrough) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, createTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval intermediateModel, referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasOneThrough, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2; + zval definition, createLines, primaryColumns; + zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, temporary, options, table, columns, column, indexes, index, reference, references, indexName, indexType, onDelete, onUpdate, columnDefinition, *_2, _3, _82, _83, _0$$5, _1$$6, _5$$7, _6$$7, _7$$7, _11$$7, _12$$7, _14$$7, _8$$8, _10$$8, _13$$11, _15$$12, _16$$12, _17$$12, _18$$13, _19$$13, _20$$13, _23$$13, _24$$13, _26$$13, _21$$14, _22$$14, _25$$17, _27$$18, _28$$18, _29$$18, _30$$19, _31$$19, *_32$$20, _33$$20, _34$$22, _35$$22, _36$$22, _37$$24, _38$$24, _39$$24, _40$$25, _41$$25, _42$$25, _43$$25, _44$$25, _45$$25, _46$$28, _47$$28, _48$$28, _49$$30, _50$$30, _51$$30, _52$$31, _53$$31, _54$$31, _55$$31, _56$$31, _57$$31, *_58$$33, _59$$33, _60$$34, _61$$34, _62$$34, _63$$34, _64$$34, _65$$34, _66$$34, _67$$34, _68$$34, _69$$35, _70$$36, _71$$37, _72$$37, _73$$37, _74$$37, _75$$37, _76$$37, _77$$37, _78$$37, _79$$37, _80$$38, _81$$39, _84$$40, _85$$40; + zval tableName, schemaName, indexSql, indexSqlAfterCreate, columnLine, referenceSql, sql, _86; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&hasOneThrough); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); - ZVAL_UNDEF(&intermediateEntity); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&indexSql); + ZVAL_UNDEF(&indexSqlAfterCreate); + ZVAL_UNDEF(&columnLine); + ZVAL_UNDEF(&referenceSql); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&_86); + ZVAL_UNDEF(&temporary); ZVAL_UNDEF(&options); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&indexes); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&indexName); + ZVAL_UNDEF(&indexType); + ZVAL_UNDEF(&onDelete); + ZVAL_UNDEF(&onUpdate); + ZVAL_UNDEF(&columnDefinition); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_82); + ZVAL_UNDEF(&_83); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_15$$12); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_17$$12); + ZVAL_UNDEF(&_18$$13); + ZVAL_UNDEF(&_19$$13); + ZVAL_UNDEF(&_20$$13); + ZVAL_UNDEF(&_23$$13); + ZVAL_UNDEF(&_24$$13); + ZVAL_UNDEF(&_26$$13); + ZVAL_UNDEF(&_21$$14); + ZVAL_UNDEF(&_22$$14); + ZVAL_UNDEF(&_25$$17); + ZVAL_UNDEF(&_27$$18); + ZVAL_UNDEF(&_28$$18); + ZVAL_UNDEF(&_29$$18); + ZVAL_UNDEF(&_30$$19); + ZVAL_UNDEF(&_31$$19); + ZVAL_UNDEF(&_33$$20); + ZVAL_UNDEF(&_34$$22); + ZVAL_UNDEF(&_35$$22); + ZVAL_UNDEF(&_36$$22); + ZVAL_UNDEF(&_37$$24); + ZVAL_UNDEF(&_38$$24); + ZVAL_UNDEF(&_39$$24); + ZVAL_UNDEF(&_40$$25); + ZVAL_UNDEF(&_41$$25); + ZVAL_UNDEF(&_42$$25); + ZVAL_UNDEF(&_43$$25); + ZVAL_UNDEF(&_44$$25); + ZVAL_UNDEF(&_45$$25); + ZVAL_UNDEF(&_46$$28); + ZVAL_UNDEF(&_47$$28); + ZVAL_UNDEF(&_48$$28); + ZVAL_UNDEF(&_49$$30); + ZVAL_UNDEF(&_50$$30); + ZVAL_UNDEF(&_51$$30); + ZVAL_UNDEF(&_52$$31); + ZVAL_UNDEF(&_53$$31); + ZVAL_UNDEF(&_54$$31); + ZVAL_UNDEF(&_55$$31); + ZVAL_UNDEF(&_56$$31); + ZVAL_UNDEF(&_57$$31); + ZVAL_UNDEF(&_59$$33); + ZVAL_UNDEF(&_60$$34); + ZVAL_UNDEF(&_61$$34); + ZVAL_UNDEF(&_62$$34); + ZVAL_UNDEF(&_63$$34); + ZVAL_UNDEF(&_64$$34); + ZVAL_UNDEF(&_65$$34); + ZVAL_UNDEF(&_66$$34); + ZVAL_UNDEF(&_67$$34); + ZVAL_UNDEF(&_68$$34); + ZVAL_UNDEF(&_69$$35); + ZVAL_UNDEF(&_70$$36); + ZVAL_UNDEF(&_71$$37); + ZVAL_UNDEF(&_72$$37); + ZVAL_UNDEF(&_73$$37); + ZVAL_UNDEF(&_74$$37); + ZVAL_UNDEF(&_75$$37); + ZVAL_UNDEF(&_76$$37); + ZVAL_UNDEF(&_77$$37); + ZVAL_UNDEF(&_78$$37); + ZVAL_UNDEF(&_79$$37); + ZVAL_UNDEF(&_80$$38); + ZVAL_UNDEF(&_81$$39); + ZVAL_UNDEF(&_84$$40); + ZVAL_UNDEF(&_85$$40); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&createLines); + ZVAL_UNDEF(&primaryColumns); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(7, 8) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_ZVAL(intermediateReferencedFields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&intermediateModel); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_INIT_VAR(&schemaName); } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&intermediateEntity); - zephir_fast_strtolower(&intermediateEntity, &intermediateModel); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hasOneThrough, &_1); - ZEPHIR_OBS_VAR(&relations); - if (!(zephir_array_isset_fetch(&relations, &hasOneThrough, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 722); - return; - } - } - if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 734); - return; - } + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/Db/Dialect/Postgresql.zep", 134); + return; } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_1, 3); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 442, &_1, &referencedModel, fields, referencedFields, &options); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 443, intermediateFields, &intermediateModel, intermediateReferencedFields); + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); - ZEPHIR_OBS_VAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (Z_TYPE_P(&alias) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 763); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); + ZEPHIR_INIT_VAR(&temporary); + ZVAL_BOOL(&temporary, 0); + ZEPHIR_OBS_VAR(&options); + if (zephir_array_isset_string_fetch(&options, &definition, SL("options"), 0)) { + ZEPHIR_OBS_NVAR(&temporary); + zephir_array_isset_string_fetch(&temporary, &options, SL("temporary"), 0); + } + if (zephir_is_true(&temporary)) { + ZEPHIR_INIT_VAR(&_0$$5); + ZEPHIR_CONCAT_SVS(&_0$$5, "CREATE TEMPORARY TABLE ", &table, " (\n\t"); + zephir_get_strval(&sql, &_0$$5); } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + ZEPHIR_INIT_VAR(&_1$$6); + ZEPHIR_CONCAT_SVS(&_1$$6, "CREATE TABLE ", &table, " (\n\t"); + zephir_get_strval(&sql, &_1$$6); } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 774); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); - zephir_update_property_array(this_ptr, SL("hasOneThrough"), &keyRelation, &relations); - ZEPHIR_OBS_VAR(&singleRelations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + ZEPHIR_INIT_VAR(&indexSqlAfterCreate); + ZEPHIR_INIT_VAR(&createLines); + array_init(&createLines); + ZEPHIR_INIT_VAR(&primaryColumns); + array_init(&primaryColumns); + zephir_is_iterable(&columns, 0, "phalcon/Db/Dialect/Postgresql.zep", 198); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _2) + { + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _2); + ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", &_4, 0, &column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$7, &column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_6$$7); + ZEPHIR_CONCAT_SVSV(&_6$$7, "\"", &_5$$7, "\" ", &columnDefinition); + zephir_get_strval(&columnLine, &_6$$7); + ZEPHIR_CALL_METHOD(&_7$$7, &column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_7$$7)) { + ZEPHIR_CALL_METHOD(&_8$$8, this_ptr, "castdefault", &_9, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$8); + ZEPHIR_CONCAT_SV(&_10$$8, " DEFAULT ", &_8$$8); + zephir_concat_self(&columnLine, &_10$$8); + } + ZEPHIR_CALL_METHOD(&_11$$7, &column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_11$$7)) { + zephir_concat_self_str(&columnLine, " NOT NULL", sizeof(" NOT NULL") - 1); + } else { + zephir_concat_self_str(&columnLine, " NULL", sizeof(" NULL") - 1); + } + ZEPHIR_CALL_METHOD(&_12$$7, &column, "isprimary", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_12$$7)) { + ZEPHIR_CALL_METHOD(&_13$$11, &column, "getname", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&primaryColumns, &_13$$11, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 185); + } + zephir_array_append(&createLines, &columnLine, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 188); + ZEPHIR_CALL_METHOD(&_14$$7, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_14$$7)) { + ZEPHIR_CALL_METHOD(&_15$$12, &column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_16$$12, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_17$$12); + ZEPHIR_CONCAT_SVSVSVS(&_17$$12, " COMMENT ON COLUMN ", &table, ".\"", &_15$$12, "\" IS '", &_16$$12, "';"); + zephir_concat_self(&indexSqlAfterCreate, &_17$$12); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", &_4, 0, &column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_18$$13, &column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_19$$13); + ZEPHIR_CONCAT_SVSV(&_19$$13, "\"", &_18$$13, "\" ", &columnDefinition); + zephir_get_strval(&columnLine, &_19$$13); + ZEPHIR_CALL_METHOD(&_20$$13, &column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_20$$13)) { + ZEPHIR_CALL_METHOD(&_21$$14, this_ptr, "castdefault", &_9, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_22$$14); + ZEPHIR_CONCAT_SV(&_22$$14, " DEFAULT ", &_21$$14); + zephir_concat_self(&columnLine, &_22$$14); + } + ZEPHIR_CALL_METHOD(&_23$$13, &column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_23$$13)) { + zephir_concat_self_str(&columnLine, " NOT NULL", sizeof(" NOT NULL") - 1); + } else { + zephir_concat_self_str(&columnLine, " NULL", sizeof(" NULL") - 1); + } + ZEPHIR_CALL_METHOD(&_24$$13, &column, "isprimary", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_24$$13)) { + ZEPHIR_CALL_METHOD(&_25$$17, &column, "getname", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&primaryColumns, &_25$$17, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 185); + } + zephir_array_append(&createLines, &columnLine, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 188); + ZEPHIR_CALL_METHOD(&_26$$13, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_26$$13)) { + ZEPHIR_CALL_METHOD(&_27$$18, &column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_28$$18, &column, "getcomment", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_29$$18); + ZEPHIR_CONCAT_SVSVSVS(&_29$$18, " COMMENT ON COLUMN ", &table, ".\"", &_27$$18, "\" IS '", &_28$$18, "';"); + zephir_concat_self(&indexSqlAfterCreate, &_29$$18); + } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 796); - zephir_update_property_array(this_ptr, SL("hasOneThroughSingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, clearReusableObjects) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - - - ZEPHIR_MM_GROW(); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("reusable"), &_0); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&column); + if (!(ZEPHIR_IS_EMPTY(&primaryColumns))) { + ZEPHIR_CALL_METHOD(&_30$$19, this_ptr, "getcolumnlist", NULL, 57, &primaryColumns); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_31$$19); + ZEPHIR_CONCAT_SVS(&_31$$19, "PRIMARY KEY (", &_30$$19, ")"); + zephir_array_append(&createLines, &_31$$19, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 199); + } + ZEPHIR_OBS_VAR(&indexes); + if (zephir_array_isset_string_fetch(&indexes, &definition, SL("indexes"), 0)) { + zephir_is_iterable(&indexes, 0, "phalcon/Db/Dialect/Postgresql.zep", 227); + if (Z_TYPE_P(&indexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&indexes), _32$$20) + { + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _32$$20); + ZEPHIR_CALL_METHOD(&indexName, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexType, &index, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&indexSql); + if (ZEPHIR_IS_STRING(&indexName, "PRIMARY")) { + ZEPHIR_CALL_METHOD(&_35$$22, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_34$$22, this_ptr, "getcolumnlist", NULL, 57, &_35$$22); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_36$$22); + ZEPHIR_CONCAT_SVS(&_36$$22, "CONSTRAINT \"PRIMARY\" PRIMARY KEY (", &_34$$22, ")"); + zephir_get_strval(&indexSql, &_36$$22); + } else { + if (!(ZEPHIR_IS_EMPTY(&indexType))) { + ZEPHIR_CALL_METHOD(&_38$$24, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_37$$24, this_ptr, "getcolumnlist", NULL, 57, &_38$$24); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_39$$24); + ZEPHIR_CONCAT_SVSVSVS(&_39$$24, "CONSTRAINT \"", &indexName, "\" ", &indexType, " (", &_37$$24, ")"); + zephir_get_strval(&indexSql, &_39$$24); + } else { + ZEPHIR_CALL_METHOD(&_40$$25, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_41$$25, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_42$$25); + ZEPHIR_CONCAT_SVSV(&_42$$25, "CREATE INDEX \"", &_40$$25, "\" ON ", &_41$$25); + zephir_concat_self(&indexSqlAfterCreate, &_42$$25); + ZEPHIR_CALL_METHOD(&_44$$25, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_43$$25, this_ptr, "getcolumnlist", NULL, 57, &_44$$25); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_45$$25); + ZEPHIR_CONCAT_SVS(&_45$$25, " (", &_43$$25, ");"); + zephir_concat_self(&indexSqlAfterCreate, &_45$$25); + } + } + if (!(ZEPHIR_IS_EMPTY(&indexSql))) { + zephir_array_append(&createLines, &indexSql, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 224); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &indexes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_33$$20, &indexes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_33$$20)) { + break; + } + ZEPHIR_CALL_METHOD(&index, &indexes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexName, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexType, &index, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&indexSql); + if (ZEPHIR_IS_STRING(&indexName, "PRIMARY")) { + ZEPHIR_CALL_METHOD(&_47$$28, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_46$$28, this_ptr, "getcolumnlist", NULL, 57, &_47$$28); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_48$$28); + ZEPHIR_CONCAT_SVS(&_48$$28, "CONSTRAINT \"PRIMARY\" PRIMARY KEY (", &_46$$28, ")"); + zephir_get_strval(&indexSql, &_48$$28); + } else { + if (!(ZEPHIR_IS_EMPTY(&indexType))) { + ZEPHIR_CALL_METHOD(&_50$$30, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_49$$30, this_ptr, "getcolumnlist", NULL, 57, &_50$$30); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_51$$30); + ZEPHIR_CONCAT_SVSVSVS(&_51$$30, "CONSTRAINT \"", &indexName, "\" ", &indexType, " (", &_49$$30, ")"); + zephir_get_strval(&indexSql, &_51$$30); + } else { + ZEPHIR_CALL_METHOD(&_52$$31, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_53$$31, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_54$$31); + ZEPHIR_CONCAT_SVSV(&_54$$31, "CREATE INDEX \"", &_52$$31, "\" ON ", &_53$$31); + zephir_concat_self(&indexSqlAfterCreate, &_54$$31); + ZEPHIR_CALL_METHOD(&_56$$31, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_55$$31, this_ptr, "getcolumnlist", NULL, 57, &_56$$31); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_57$$31); + ZEPHIR_CONCAT_SVS(&_57$$31, " (", &_55$$31, ");"); + zephir_concat_self(&indexSqlAfterCreate, &_57$$31); + } + } + if (!(ZEPHIR_IS_EMPTY(&indexSql))) { + zephir_array_append(&createLines, &indexSql, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 224); + } + ZEPHIR_CALL_METHOD(NULL, &indexes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&index); + } + ZEPHIR_OBS_VAR(&references); + if (zephir_array_isset_string_fetch(&references, &definition, SL("references"), 0)) { + zephir_is_iterable(&references, 0, "phalcon/Db/Dialect/Postgresql.zep", 255); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&references), _58$$33) + { + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _58$$33); + ZEPHIR_CALL_METHOD(&_60$$34, &reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_62$$34, &reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_61$$34, this_ptr, "getcolumnlist", NULL, 57, &_62$$34); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_63$$34); + ZEPHIR_CONCAT_SVSVS(&_63$$34, "CONSTRAINT \"", &_60$$34, "\" FOREIGN KEY (", &_61$$34, ") REFERENCES "); + zephir_get_strval(&referenceSql, &_63$$34); + ZEPHIR_CALL_METHOD(&_65$$34, &reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_64$$34, this_ptr, "preparetable", NULL, 0, &_65$$34, &schemaName); + zephir_check_call_status(); + zephir_concat_self(&referenceSql, &_64$$34); + ZEPHIR_CALL_METHOD(&_67$$34, &reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_66$$34, this_ptr, "getcolumnlist", NULL, 57, &_67$$34); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_68$$34); + ZEPHIR_CONCAT_SVS(&_68$$34, " (", &_66$$34, ")"); + zephir_concat_self(&referenceSql, &_68$$34); + ZEPHIR_CALL_METHOD(&onDelete, &reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_NVAR(&_69$$35); + ZEPHIR_CONCAT_SV(&_69$$35, " ON DELETE ", &onDelete); + zephir_concat_self(&referenceSql, &_69$$35); + } + ZEPHIR_CALL_METHOD(&onUpdate, &reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_NVAR(&_70$$36); + ZEPHIR_CONCAT_SV(&_70$$36, " ON UPDATE ", &onUpdate); + zephir_concat_self(&referenceSql, &_70$$36); + } + zephir_array_append(&createLines, &referenceSql, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 253); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_59$$33, &references, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_59$$33)) { + break; + } + ZEPHIR_CALL_METHOD(&reference, &references, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_71$$37, &reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_73$$37, &reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_72$$37, this_ptr, "getcolumnlist", NULL, 57, &_73$$37); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_74$$37); + ZEPHIR_CONCAT_SVSVS(&_74$$37, "CONSTRAINT \"", &_71$$37, "\" FOREIGN KEY (", &_72$$37, ") REFERENCES "); + zephir_get_strval(&referenceSql, &_74$$37); + ZEPHIR_CALL_METHOD(&_76$$37, &reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_75$$37, this_ptr, "preparetable", NULL, 0, &_76$$37, &schemaName); + zephir_check_call_status(); + zephir_concat_self(&referenceSql, &_75$$37); + ZEPHIR_CALL_METHOD(&_78$$37, &reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_77$$37, this_ptr, "getcolumnlist", NULL, 57, &_78$$37); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_79$$37); + ZEPHIR_CONCAT_SVS(&_79$$37, " (", &_77$$37, ")"); + zephir_concat_self(&referenceSql, &_79$$37); + ZEPHIR_CALL_METHOD(&onDelete, &reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_NVAR(&_80$$38); + ZEPHIR_CONCAT_SV(&_80$$38, " ON DELETE ", &onDelete); + zephir_concat_self(&referenceSql, &_80$$38); + } + ZEPHIR_CALL_METHOD(&onUpdate, &reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_NVAR(&_81$$39); + ZEPHIR_CONCAT_SV(&_81$$39, " ON UPDATE ", &onUpdate); + zephir_concat_self(&referenceSql, &_81$$39); + } + zephir_array_append(&createLines, &referenceSql, PH_SEPARATE, "phalcon/Db/Dialect/Postgresql.zep", 253); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&reference); + } + ZEPHIR_INIT_VAR(&_82); + zephir_fast_join_str(&_82, SL(",\n\t"), &createLines); + ZEPHIR_INIT_VAR(&_83); + ZEPHIR_CONCAT_VS(&_83, &_82, "\n)"); + zephir_concat_self(&sql, &_83); + if (zephir_array_isset_string(&definition, SL("options"))) { + ZEPHIR_CALL_METHOD(&_84$$40, this_ptr, "gettableoptions", NULL, 0, &definition); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_85$$40); + ZEPHIR_CONCAT_SV(&_85$$40, " ", &_84$$40); + zephir_concat_self(&sql, &_85$$40); + } + ZEPHIR_INIT_VAR(&_86); + ZEPHIR_CONCAT_SV(&_86, ";", &indexSqlAfterCreate); + zephir_concat_self(&sql, &_86); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, createBuilder) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, createView) { - zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params = NULL, params_sub, __$null, container, _0, _1, _3; + zval definition; + zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, viewSql, _0; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(¶ms_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&container); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&viewSql); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(viewName) + Z_PARAM_ARRAY(definition) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, ¶ms); - if (!params) { - params = ¶ms_sub; - params = &__$null; + zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); + } else { + ZEPHIR_INIT_VAR(&viewName); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 828); + ZEPHIR_OBS_VAR(&viewSql); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&viewSql, &definition, SL("sql"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/Db/Dialect/Postgresql.zep", 276); return; } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, params); - zephir_array_fast_append(&_2, &container); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query\\Builder"); - ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &viewName, &schemaName); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("builder"), &_1); - RETURN_MM_MEMBER(getThis(), "builder"); + ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", &_0, " AS ", &viewSql); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, createQuery) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeColumns) { - zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *phql_param = NULL, container, query, _0, _1, _3; - zval phql; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(phql) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &phql_param); - if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { - zephir_get_strval(&phql, phql_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&phql); + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 861); - return; + if (ZEPHIR_IS_NULL(&schema)) { + ZEPHIR_INIT_NVAR(&schema); + ZVAL_STRING(&schema, "public"); } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, &phql); - zephir_array_fast_append(&_2, &container); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query"); - ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("lastQuery"), &query); - RETURN_CCTOR(&query); + ZEPHIR_CONCAT_SVSVS(return_value, "SELECT DISTINCT c.column_name AS Field, c.data_type AS Type, c.character_maximum_length AS Size, c.numeric_precision AS NumericSize, c.numeric_scale AS NumericScale, c.is_nullable AS Null, CASE WHEN pkc.column_name NOTNULL THEN 'PRI' ELSE '' END AS Key, CASE WHEN c.data_type LIKE '%int%' AND c.column_default LIKE '%nextval%' THEN 'auto_increment' ELSE '' END AS Extra, c.ordinal_position AS Position, c.column_default, des.description FROM information_schema.columns c LEFT JOIN ( SELECT kcu.column_name, kcu.table_name, kcu.table_schema FROM information_schema.table_constraints tc INNER JOIN information_schema.key_column_usage kcu on (kcu.constraint_name = tc.constraint_name and kcu.table_name=tc.table_name and kcu.table_schema=tc.table_schema) WHERE tc.constraint_type='PRIMARY KEY') pkc ON (c.column_name=pkc.column_name AND c.table_schema = pkc.table_schema AND c.table_name=pkc.table_name) LEFT JOIN ( SELECT objsubid, description, relname, nspname FROM pg_description JOIN pg_class ON pg_description.objoid = pg_class.oid JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid ) des ON ( des.objsubid = C.ordinal_position AND C.table_schema = des.nspname AND C.TABLE_NAME = des.relname ) WHERE c.table_schema='", &schema, "' AND c.table_name='", &table, "' ORDER BY c.ordinal_position"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, executeQuery) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeIndexes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *phql_param = NULL, *placeholders = NULL, placeholders_sub, *types = NULL, types_sub, __$null, query; - zval phql; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&placeholders_sub); - ZVAL_UNDEF(&types_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&query); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(phql) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(placeholders) - Z_PARAM_ZVAL_OR_NULL(types) + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &phql_param, &placeholders, &types); - if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { - zephir_get_strval(&phql, phql_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&phql); - } - if (!placeholders) { - placeholders = &placeholders_sub; - placeholders = &__$null; + ZEPHIR_INIT_VAR(&table); } - if (!types) { - types = &types_sub; - types = &__$null; + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); } - ZEPHIR_CALL_METHOD(&query, this_ptr, "createquery", NULL, 0, &phql); - zephir_check_call_status(); - if (Z_TYPE_P(placeholders) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, placeholders); - zephir_check_call_status(); - } - if (Z_TYPE_P(types) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, types); - zephir_check_call_status(); - } - ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "SELECT 0 as c0, t.relname as table_name, i.relname as key_name, 3 as c3, a.attname as column_name FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND a.attnum = ANY(ix.indkey) AND t.relkind = 'r' AND t.relname = '", &table, "' ORDER BY t.relname, i.relname;"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsBelongsTo) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeReferences) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&table); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_get_strval(&schema, schema_param); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasbelongsto", NULL, 0, &modelName, &modelRelation); - zephir_check_call_status(); + if (ZEPHIR_IS_NULL(&schema)) { + ZEPHIR_INIT_NVAR(&schema); + ZVAL_STRING(&schema, "public"); + } + ZEPHIR_CONCAT_SVSVS(return_value, "SELECT DISTINCT tc.table_name AS TABLE_NAME, kcu.column_name AS COLUMN_NAME, tc.constraint_name AS CONSTRAINT_NAME, tc.table_catalog AS REFERENCED_TABLE_SCHEMA, ccu.table_name AS REFERENCED_TABLE_NAME, ccu.column_name AS REFERENCED_COLUMN_NAME, rc.update_rule AS UPDATE_RULE, rc.delete_rule AS DELETE_RULE FROM information_schema.table_constraints AS tc JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name JOIN information_schema.referential_constraints rc ON tc.constraint_catalog = rc.constraint_catalog AND tc.constraint_schema = rc.constraint_schema AND tc.constraint_name = rc.constraint_name AND tc.constraint_type = 'FOREIGN KEY' WHERE constraint_type = 'FOREIGN KEY' AND tc.table_schema = '", &schema, "' AND tc.table_name='", &table, "'"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL, _0; + zval tableName, schemaName, columnName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&columnName); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(columnName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(columnName_param) != IS_STRING && Z_TYPE_P(columnName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'columnName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(columnName_param) == IS_STRING)) { + zephir_get_strval(&columnName, columnName_param); + } else { + ZEPHIR_INIT_VAR(&columnName); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasmany", NULL, 0, &modelName, &modelRelation); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " DROP COLUMN \"", &columnName, "\""); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasManyToMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL, _0; + zval tableName, schemaName, referenceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&referenceName); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(referenceName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceName_param) == IS_STRING)) { + zephir_get_strval(&referenceName, referenceName_param); + } else { + ZEPHIR_INIT_VAR(&referenceName); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasmanytomany", NULL, 0, &modelName, &modelRelation); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " DROP CONSTRAINT \"", &referenceName, "\""); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOne) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL; + zval tableName, schemaName, indexName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&indexName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(indexName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(indexName_param) == IS_STRING)) { + zephir_get_strval(&indexName, indexName_param); + } else { + ZEPHIR_INIT_VAR(&indexName); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasone", NULL, 0, &modelName, &modelRelation); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "DROP INDEX \"", &indexName, "\""); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOneThrough) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropPrimaryKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, _0; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasonethrough", NULL, 0, &modelName, &modelRelation); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", &_0, " DROP CONSTRAINT \"", &tableName, "_PRIMARY\""); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsTo) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool ifExists; + zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, table; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&table); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(tableName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } + if (!ifExists_param) { + ifExists = 1; + } else { + if (UNEXPECTED(Z_TYPE_P(ifExists_param) != IS_TRUE && Z_TYPE_P(ifExists_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be of the type bool")); + RETURN_MM_NULL(); + } + ifExists = (Z_TYPE_P(ifExists_param) == IS_TRUE); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) { - array_init(return_value); + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + if (ifExists) { + ZEPHIR_CONCAT_SV(return_value, "DROP TABLE IF EXISTS ", &table); RETURN_MM(); } - RETURN_CTOR(&relations); + ZEPHIR_CONCAT_SV(return_value, "DROP TABLE ", &table); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsToRecords) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; - zval modelName, modelRelation, method, keyRelation; + zend_bool ifExists; + zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, view; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&view); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(viewName) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&viewName); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + zephir_get_strval(&schemaName, schemaName_param); } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + if (!ifExists_param) { + ifExists = 1; } else { - zephir_get_strval(&method, method_param); + if (UNEXPECTED(Z_TYPE_P(ifExists_param) != IS_TRUE && Z_TYPE_P(ifExists_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be of the type bool")); + RETURN_MM_NULL(); + } + ifExists = (Z_TYPE_P(ifExists_param) == IS_TRUE); } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelName); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &modelRelation); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { - RETURN_MM_BOOL(0); - } - zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1030); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); + ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, &viewName, &schemaName); zephir_check_call_status(); + if (ifExists) { + ZEPHIR_CONCAT_SV(return_value, "DROP VIEW IF EXISTS ", &view); + RETURN_MM(); + } + ZEPHIR_CONCAT_SV(return_value, "DROP VIEW ", &view); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBuilder) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "builder"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnectionService) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, getColumnDefinition) { + zval valueSql$$38; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionServices; - zval *model, model_sub, *connectionServices_param = NULL, connection, _0; + zephir_fcall_cache_entry *_12 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column, column_sub, columnType, columnSql, typeValues, _0$$4, _1$$9, _2$$15, _3$$20, _4$$33, _5$$36, _6$$36, _7$$36, value$$38, *_8$$38, _9$$38, _17$$38, _18$$38, _19$$38, _20$$38, _10$$39, _11$$39, _13$$39, _14$$40, _15$$40, _16$$40, _21$$41, _22$$41, _23$$41; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionServices); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&columnType); + ZVAL_UNDEF(&columnSql); + ZVAL_UNDEF(&typeValues); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$9); + ZVAL_UNDEF(&_2$$15); + ZVAL_UNDEF(&_3$$20); + ZVAL_UNDEF(&_4$$33); + ZVAL_UNDEF(&_5$$36); + ZVAL_UNDEF(&_6$$36); + ZVAL_UNDEF(&_7$$36); + ZVAL_UNDEF(&value$$38); + ZVAL_UNDEF(&_9$$38); + ZVAL_UNDEF(&_17$$38); + ZVAL_UNDEF(&_18$$38); + ZVAL_UNDEF(&_19$$38); + ZVAL_UNDEF(&_20$$38); + ZVAL_UNDEF(&_10$$39); + ZVAL_UNDEF(&_11$$39); + ZVAL_UNDEF(&_13$$39); + ZVAL_UNDEF(&_14$$40); + ZVAL_UNDEF(&_15$$40); + ZVAL_UNDEF(&_16$$40); + ZVAL_UNDEF(&_21$$41); + ZVAL_UNDEF(&_22$$41); + ZVAL_UNDEF(&_23$$41); + ZVAL_UNDEF(&valueSql$$38); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(connectionServices) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &connectionServices_param); - zephir_get_arrval(&connectionServices, connectionServices_param); + zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - if (!(zephir_array_isset_fetch(&connection, &connectionServices, &_0, 1))) { - RETURN_MM_STRING("db"); - } - RETURN_CTOR(&connection); + ZEPHIR_CALL_METHOD(&columnSql, this_ptr, "checkcolumntypesql", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnType, this_ptr, "checkcolumntype", NULL, 0, column); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_LONG(&columnType, 14)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + ZEPHIR_CALL_METHOD(&_0$$4, column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0$$4)) { + zephir_concat_self_str(&columnSql, SL("BIGSERIAL")); + } else { + zephir_concat_self_str(&columnSql, SL("BIGINT")); + } + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 8)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("BOOLEAN")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 5)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("CHARACTER")); + } + ZEPHIR_CALL_METHOD(&_1$$9, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_1$$9); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 1)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DATE")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 4)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TIMESTAMP")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 3)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("NUMERIC")); + } + ZEPHIR_CALL_METHOD(&_2$$15, this_ptr, "getcolumnsizeandscale", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_2$$15); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 7)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("FLOAT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 0)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + ZEPHIR_CALL_METHOD(&_3$$20, column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_3$$20)) { + zephir_concat_self_str(&columnSql, SL("SERIAL")); + } else { + zephir_concat_self_str(&columnSql, SL("INT")); + } + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 22)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("SMALLINT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 15)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("JSON")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 16)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("JSONB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 17)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TIMESTAMP")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 6)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TEXT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 2)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("CHARACTER VARYING")); + } + ZEPHIR_CALL_METHOD(&_4$$33, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_4$$33); + break; + } + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&columnSql))) { + ZEPHIR_INIT_VAR(&_5$$36); + object_init_ex(&_5$$36, phalcon_db_exception_ce); + ZEPHIR_CALL_METHOD(&_6$$36, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_7$$36); + ZEPHIR_CONCAT_SV(&_7$$36, "Unrecognized PostgreSQL data type at column ", &_6$$36); + ZEPHIR_CALL_METHOD(NULL, &_5$$36, "__construct", NULL, 32, &_7$$36); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$36, "phalcon/Db/Dialect/Postgresql.zep", 511); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&typeValues, column, "gettypevalues", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&typeValues))) { + if (Z_TYPE_P(&typeValues) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&valueSql$$38); + zephir_is_iterable(&typeValues, 0, "phalcon/Db/Dialect/Postgresql.zep", 526); + if (Z_TYPE_P(&typeValues) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&typeValues), _8$$38) + { + ZEPHIR_INIT_NVAR(&value$$38); + ZVAL_COPY(&value$$38, _8$$38); + ZEPHIR_INIT_NVAR(&_10$$39); + ZVAL_STRING(&_10$$39, "\'"); + ZEPHIR_CALL_FUNCTION(&_11$$39, "addcslashes", &_12, 214, &value$$38, &_10$$39); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_13$$39); + ZEPHIR_CONCAT_SVS(&_13$$39, "'", &_11$$39, "', "); + zephir_concat_self(&valueSql$$38, &_13$$39); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &typeValues, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9$$38, &typeValues, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9$$38)) { + break; + } + ZEPHIR_CALL_METHOD(&value$$38, &typeValues, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$40); + ZVAL_STRING(&_14$$40, "\'"); + ZEPHIR_CALL_FUNCTION(&_15$$40, "addcslashes", &_12, 214, &value$$38, &_14$$40); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$40); + ZEPHIR_CONCAT_SVS(&_16$$40, "'", &_15$$40, "', "); + zephir_concat_self(&valueSql$$38, &_16$$40); + ZEPHIR_CALL_METHOD(NULL, &typeValues, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value$$38); + ZVAL_LONG(&_17$$38, 0); + ZVAL_LONG(&_18$$38, -2); + ZEPHIR_INIT_VAR(&_19$$38); + zephir_substr(&_19$$38, &valueSql$$38, 0 , -2 , 0); + ZEPHIR_INIT_VAR(&_20$$38); + ZEPHIR_CONCAT_SVS(&_20$$38, "(", &_19$$38, ")"); + zephir_concat_self(&columnSql, &_20$$38); + } else { + ZEPHIR_INIT_VAR(&_21$$41); + ZVAL_STRING(&_21$$41, "\'"); + ZEPHIR_CALL_FUNCTION(&_22$$41, "addcslashes", &_12, 214, &typeValues, &_21$$41); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_23$$41); + ZEPHIR_CONCAT_SVS(&_23$$41, "('", &_22$$41, "')"); + zephir_concat_self(&columnSql, &_23$$41); + } + } + } while(0); + + RETURN_CCTOR(&columnSql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getCustomEventsManager) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, listTables) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, eventsManager, _0, _1; + zval *schemaName_param = NULL; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (zephir_array_isset_fetch(&eventsManager, &_0, &_1, 1)) { - RETURN_CTOR(&eventsManager); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getDI) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "container"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getEventsManager) -{ - zval *this_ptr = getThis(); - - RETURN_MEMBER(getThis(), "eventsManager"); + if (ZEPHIR_IS_NULL(&schemaName)) { + ZEPHIR_INIT_NVAR(&schemaName); + ZVAL_STRING(&schemaName, "public"); + } + ZEPHIR_CONCAT_SVS(return_value, "SELECT table_name FROM information_schema.tables WHERE table_schema = '", &schemaName, "' ORDER BY table_name"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, listViews) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; + zval *schemaName_param = NULL; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) { - array_init(return_value); - RETURN_MM(); + if (ZEPHIR_IS_NULL(&schemaName)) { + ZEPHIR_INIT_NVAR(&schemaName); + ZVAL_STRING(&schemaName, "public"); } - RETURN_CTOR(&relations); + ZEPHIR_CONCAT_SVS(return_value, "SELECT viewname AS view_name FROM pg_views WHERE schemaname = '", &schemaName, "' ORDER BY view_name"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyRecords) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, modifyColumn) { + zend_bool _26$$10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; - zval modelName, modelRelation, method, keyRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, *currentColumn = NULL, currentColumn_sub, __$null, defaultValue, columnDefinition, _0, _1, _2, _3, _7, _8, _11, _12, _18, _23, _24, _4$$4, _5$$4, _6$$4, _9$$5, _10$$5, _13$$6, _14$$7, _15$$7, _16$$8, _17$$8, _19$$9, _20$$9, _21$$9, _22$$9, _25$$10, _27$$10, _30$$10, _28$$11, _29$$11, _31$$12, _32$$13, _33$$13, _34$$14, _35$$14; + zval tableName, schemaName, sql, sqlAlterTable; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&sqlAlterTable); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(¤tColumn_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&columnDefinition); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_18); + ZVAL_UNDEF(&_23); + ZVAL_UNDEF(&_24); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$7); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_19$$9); + ZVAL_UNDEF(&_20$$9); + ZVAL_UNDEF(&_21$$9); + ZVAL_UNDEF(&_22$$9); + ZVAL_UNDEF(&_25$$10); + ZVAL_UNDEF(&_27$$10); + ZVAL_UNDEF(&_30$$10); + ZVAL_UNDEF(&_28$$11); + ZVAL_UNDEF(&_29$$11); + ZVAL_UNDEF(&_31$$12); + ZVAL_UNDEF(&_32$$13); + ZVAL_UNDEF(&_33$$13); + ZVAL_UNDEF(&_34$$14); + ZVAL_UNDEF(&_35$$14); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(currentColumn, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + ZEPHIR_INIT_VAR(&schemaName); } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + if (!currentColumn) { + currentColumn = ¤tColumn_sub; + ZEPHIR_CPY_WRT(currentColumn, &__$null); } else { - zephir_get_strval(&method, method_param); + ZEPHIR_SEPARATE_PARAM(currentColumn); } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelName); + ZEPHIR_INIT_VAR(&sql); + ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &modelRelation); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { - RETURN_MM_BOOL(0); + ZEPHIR_CONCAT_SV(&_1, "ALTER TABLE ", &_0); + zephir_get_strval(&sqlAlterTable, &_1); + if (Z_TYPE_P(currentColumn) != IS_OBJECT) { + ZEPHIR_CPY_WRT(currentColumn, column); } - zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1141); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); + ZEPHIR_CALL_METHOD(&_2, column, "getname", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_3, currentColumn, "getname", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_2, &_3)) { + ZEPHIR_CALL_METHOD(&_4$$4, currentColumn, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6$$4); + ZEPHIR_CONCAT_VSVSVS(&_6$$4, &sqlAlterTable, " RENAME COLUMN \"", &_4$$4, "\" TO \"", &_5$$4, "\";"); + zephir_concat_self(&sql, &_6$$4); + } + ZEPHIR_CALL_METHOD(&_7, column, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8, currentColumn, "gettype", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_7, &_8)) { + ZEPHIR_CALL_METHOD(&_9$$5, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_10$$5); + ZEPHIR_CONCAT_VSVSVS(&_10$$5, &sqlAlterTable, " ALTER COLUMN \"", &_9$$5, "\" TYPE ", &columnDefinition, ";"); + zephir_concat_self(&sql, &_10$$5); + } + ZEPHIR_CALL_METHOD(&_11, column, "isnotnull", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_12, currentColumn, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_11, &_12)) { + ZEPHIR_CALL_METHOD(&_13$$6, column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_13$$6)) { + ZEPHIR_CALL_METHOD(&_14$$7, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_15$$7); + ZEPHIR_CONCAT_VSVS(&_15$$7, &sqlAlterTable, " ALTER COLUMN \"", &_14$$7, "\" SET NOT NULL;"); + zephir_concat_self(&sql, &_15$$7); + } else { + ZEPHIR_CALL_METHOD(&_16$$8, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_17$$8); + ZEPHIR_CONCAT_VSVS(&_17$$8, &sqlAlterTable, " ALTER COLUMN \"", &_16$$8, "\" DROP NOT NULL;"); + zephir_concat_self(&sql, &_17$$8); + } + } + ZEPHIR_CALL_METHOD(&_18, column, "getcomment", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_18)) { + ZEPHIR_CALL_METHOD(&_19$$9, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_20$$9, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_21$$9, column, "getcomment", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_22$$9); + ZEPHIR_CONCAT_SVSVSVS(&_22$$9, "COMMENT ON COLUMN ", &_19$$9, ".\"", &_20$$9, "\" IS '", &_21$$9, "';"); + zephir_concat_self(&sql, &_22$$9); + } + ZEPHIR_CALL_METHOD(&_23, column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24, currentColumn, "getdefault", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_23, &_24)) { + ZEPHIR_CALL_METHOD(&_25$$10, column, "getdefault", NULL, 0); + zephir_check_call_status(); + _26$$10 = ZEPHIR_IS_EMPTY(&_25$$10); + if (_26$$10) { + ZEPHIR_CALL_METHOD(&_27$$10, currentColumn, "getdefault", NULL, 0); + zephir_check_call_status(); + _26$$10 = !(ZEPHIR_IS_EMPTY(&_27$$10)); + } + if (_26$$10) { + ZEPHIR_CALL_METHOD(&_28$$11, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_29$$11); + ZEPHIR_CONCAT_VSVS(&_29$$11, &sqlAlterTable, " ALTER COLUMN \"", &_28$$11, "\" DROP DEFAULT;"); + zephir_concat_self(&sql, &_29$$11); + } + ZEPHIR_CALL_METHOD(&_30$$10, column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_30$$10)) { + ZEPHIR_CALL_METHOD(&defaultValue, this_ptr, "castdefault", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_31$$12); + zephir_fast_strtoupper(&_31$$12, &columnDefinition); + if (zephir_memnstr_str(&_31$$12, SL("BOOLEAN"), "phalcon/Db/Dialect/Postgresql.zep", 616)) { + ZEPHIR_CALL_METHOD(&_32$$13, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_33$$13); + ZEPHIR_CONCAT_SVSV(&_33$$13, " ALTER COLUMN \"", &_32$$13, "\" SET DEFAULT ", &defaultValue); + zephir_concat_self(&sql, &_33$$13); + } else { + ZEPHIR_CALL_METHOD(&_34$$14, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_35$$14); + ZEPHIR_CONCAT_VSVSV(&_35$$14, &sqlAlterTable, " ALTER COLUMN \"", &_34$$14, "\" SET DEFAULT ", &defaultValue); + zephir_concat_self(&sql, &_35$$14); + } + } + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyToMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, sharedLock) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; + zval *sqlQuery_param = NULL; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&sqlQuery); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(sqlQuery) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) { - array_init(return_value); - RETURN_MM(); - } - RETURN_CTOR(&relations); + RETURN_CTOR(&sqlQuery); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOne) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, tableExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; + zval *tableName_param = NULL, *schemaName_param = NULL; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tableName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) { - array_init(return_value); - RETURN_MM(); + if (ZEPHIR_IS_NULL(&schemaName)) { + ZEPHIR_INIT_NVAR(&schemaName); + ZVAL_STRING(&schemaName, "public"); } - RETURN_CTOR(&relations); + ZEPHIR_CONCAT_SVSVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM information_schema.tables WHERE table_schema = '", &schemaName, "' AND table_name='", &tableName, "'"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneAndHasMany) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, tableOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0, _1; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); + } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethasone", NULL, 0, model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "gethasmany", NULL, 0, model); - zephir_check_call_status(); - zephir_fast_array_merge(return_value, &_0, &_1); - RETURN_MM(); + RETURN_MM_STRING(""); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneRecords) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, truncateTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; - zval modelName, modelRelation, method, keyRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, table; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&table); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_strval(&method, method_param); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelName); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &modelRelation); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { - RETURN_MM_BOOL(0); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName); + zephir_check_call_status(); } - zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1210); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); - zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, "TRUNCATE TABLE ", &table); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneThrough) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, viewExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; + zval *viewName_param = NULL, *schemaName_param = NULL; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(viewName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 1))) { - array_init(return_value); - RETURN_MM(); + zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); + } else { + ZEPHIR_INIT_VAR(&viewName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - RETURN_CTOR(&relations); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastInitialized) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "lastInitialized"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastQuery) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "lastQuery"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelPrefix) -{ - zval *this_ptr = getThis(); - - RETURN_MEMBER(getThis(), "prefix"); + if (ZEPHIR_IS_NULL(&schemaName)) { + ZEPHIR_INIT_NVAR(&schemaName); + ZVAL_STRING(&schemaName, "public"); + } + ZEPHIR_CONCAT_SVSVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM pg_views WHERE viewname='", &viewName, "' AND schemaname='", &schemaName, "'"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSchema) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, castDefault) { + zend_bool _2, _3, _4, _5; + zval preparedValue, _6$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, schema, _0, _1; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column, column_sub, defaultValue, columnDefinition, columnType, _0, _1, _7$$6, _8$$6, _9$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&columnDefinition); + ZVAL_UNDEF(&columnType); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&preparedValue); + ZVAL_UNDEF(&_6$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &column); - zephir_read_property(&_0, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnType, column, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtoupper(&_0, &columnDefinition); + if (zephir_memnstr_str(&_0, SL("BOOLEAN"), "phalcon/Db/Dialect/Postgresql.zep", 699)) { + RETURN_CCTOR(&defaultValue); + } ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&schema, &_0, &_1, 1))) { - RETURN_MM_NULL(); + zephir_fast_strtoupper(&_1, &defaultValue); + if (zephir_memnstr_str(&_1, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Postgresql.zep", 703)) { + RETURN_MM_STRING("CURRENT_TIMESTAMP"); } - RETURN_CTOR(&schema); + _2 = ZEPHIR_IS_LONG_IDENTICAL(&columnType, 0); + if (!(_2)) { + _2 = ZEPHIR_IS_LONG_IDENTICAL(&columnType, 14); + } + _3 = _2; + if (!(_3)) { + _3 = ZEPHIR_IS_LONG_IDENTICAL(&columnType, 3); + } + _4 = _3; + if (!(_4)) { + _4 = ZEPHIR_IS_LONG_IDENTICAL(&columnType, 7); + } + _5 = _4; + if (!(_5)) { + _5 = ZEPHIR_IS_LONG_IDENTICAL(&columnType, 9); + } + if (_5) { + zephir_cast_to_string(&_6$$5, &defaultValue); + ZEPHIR_CPY_WRT(&preparedValue, &_6$$5); + } else { + ZEPHIR_INIT_VAR(&_7$$6); + ZVAL_STRING(&_7$$6, "\'"); + ZEPHIR_CALL_FUNCTION(&_8$$6, "addcslashes", NULL, 214, &defaultValue, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_9$$6); + ZEPHIR_CONCAT_SVS(&_9$$6, "'", &_8$$6, "'"); + zephir_get_strval(&preparedValue, &_9$$6); + } + RETURN_CTOR(&preparedValue); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSource) +static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, getTableOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, entityName, _0, _3, _4, _5, _1$$3, _2$$3; + zval *definition_param = NULL; + zval definition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &definition_param); + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &entityName))) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - zephir_get_class_ns(&_2$$3, model, 0); - zephir_uncamelize(&_1$$3, &_2$$3, NULL ); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setmodelsource", NULL, 0, model, &_1$$3); - zephir_check_call_status(); - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_5, &_4, &entityName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1287); - ZEPHIR_CONCAT_VV(return_value, &_3, &_5); - RETURN_MM(); + RETURN_MM_STRING(""); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnection) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, model, &_0); - zephir_check_call_status(); - RETURN_MM(); + +ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_Sqlite) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, Sqlite, phalcon, db_dialect_sqlite, phalcon_db_dialect_ce, phalcon_db_dialect_sqlite_method_entry, 0); + + zend_declare_property_string(phalcon_db_dialect_sqlite_ce, SL("escapeChar"), "\"", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnectionService) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, defaultValue, _0, _1, _2, _3, _4, _5, _10, _11, _6$$3, _7$$5, _8$$5, _9$$5; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&defaultValue); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "ALTER TABLE ", &_0, " ADD COLUMN "); + zephir_get_strval(&sql, &_1); + ZEPHIR_CALL_METHOD(&_2, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getcolumndefinition", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SVSV(&_4, "\"", &_2, "\" ", &_3); + zephir_concat_self(&sql, &_4); + ZEPHIR_CALL_METHOD(&_5, column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_5)) { + ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6$$3); + zephir_fast_strtoupper(&_6$$3, &defaultValue); + if (zephir_memnstr_str(&_6$$3, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Sqlite.zep", 46)) { + zephir_concat_self_str(&sql, " DEFAULT CURRENT_TIMESTAMP", sizeof(" DEFAULT CURRENT_TIMESTAMP") - 1); + } else { + ZEPHIR_INIT_VAR(&_7$$5); + ZVAL_STRING(&_7$$5, "\""); + ZEPHIR_CALL_FUNCTION(&_8$$5, "addcslashes", NULL, 214, &defaultValue, &_7$$5); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_9$$5); + ZEPHIR_CONCAT_SVS(&_9$$5, " DEFAULT \"", &_8$$5, "\""); + zephir_concat_self(&sql, &_9$$5); + } + } + ZEPHIR_CALL_METHOD(&_10, column, "isnotnull", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_10)) { + zephir_concat_self_str(&sql, " NOT NULL", sizeof(" NOT NULL") - 1); + } else { + zephir_concat_self_str(&sql, " NULL", sizeof(" NULL") - 1); + } + ZEPHIR_CALL_METHOD(&_11, column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_11)) { + zephir_concat_self_str(&sql, " PRIMARY KEY AUTOINCREMENT", sizeof(" PRIMARY KEY AUTOINCREMENT") - 1); + } + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationByAlias) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *modelName_param = NULL, *alias_param = NULL, relation, _0, _1; - zval modelName, alias, _2; + zval *tableName_param = NULL, *schemaName_param = NULL, *reference, reference_sub; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&reference_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(alias) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(reference, phalcon_db_referenceinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(alias_param) == IS_STRING)) { - zephir_get_strval(&alias, alias_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&alias); + ZEPHIR_INIT_VAR(&schemaName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &modelName, "$", &alias); - zephir_fast_strtolower(&_1, &_2); - if (!(zephir_array_isset_fetch(&relation, &_0, &_1, 1))) { - RETURN_MM_BOOL(0); - } - RETURN_CTOR(&relation); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Adding a foreign key constraint to an existing table is not supported by SQLite", "phalcon/Db/Dialect/Sqlite.zep", 73); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationRecords) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addIndex) { - zend_string *_20$$11; - zend_ulong _19$$11; - zend_bool reusable = 0, _35$$21; - zval placeholders, conditions, joinConditions, _36, _34$$21; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_24 = NULL, *_29 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval method, retrieveMethod; - zval *relation, relation_sub, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, referencedModel, intermediateModel, intermediateFields, fields, builder, extraParameters, refPosition, field, referencedFields, findParams, findArguments, uniqueKey, records, arguments, rows, firstRow, query, _0, _31, _32, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _11$$3, _8$$6, _9$$6, _10$$6, _12$$8, _13$$8, _14$$10, _15$$10, _16$$11, *_17$$11, _18$$11, _21$$12, _22$$12, _23$$12, _25$$12, _26$$13, _27$$13, _28$$13, _30$$13, _33$$16; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, indexType, _5, _6, _7, _0$$3, _1$$5, _2$$5, _3$$6, _4$$6; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&relation_sub); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&intermediateFields); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&builder); - ZVAL_UNDEF(&extraParameters); - ZVAL_UNDEF(&refPosition); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&findParams); - ZVAL_UNDEF(&findArguments); - ZVAL_UNDEF(&uniqueKey); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&rows); - ZVAL_UNDEF(&firstRow); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_31); - ZVAL_UNDEF(&_32); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_13$$8); - ZVAL_UNDEF(&_14$$10); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_16$$11); - ZVAL_UNDEF(&_18$$11); - ZVAL_UNDEF(&_21$$12); - ZVAL_UNDEF(&_22$$12); - ZVAL_UNDEF(&_23$$12); - ZVAL_UNDEF(&_25$$12); - ZVAL_UNDEF(&_26$$13); - ZVAL_UNDEF(&_27$$13); - ZVAL_UNDEF(&_28$$13); - ZVAL_UNDEF(&_30$$13); - ZVAL_UNDEF(&_33$$16); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&retrieveMethod); - ZVAL_UNDEF(&placeholders); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&joinConditions); - ZVAL_UNDEF(&_36); - ZVAL_UNDEF(&_34$$21); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&indexType); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 2, &relation, &record, ¶meters, &method_param); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - zephir_get_strval(&method, method_param); + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - ZEPHIR_CALL_METHOD(&extraParameters, relation, "getparams", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModel, relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, relation, "isthrough", NULL, 0); + ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); - if (zephir_is_true(&_0)) { - ZEPHIR_INIT_VAR(&conditions); - array_init(&conditions); - ZEPHIR_CALL_METHOD(&intermediateModel, relation, "getintermediatemodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&fields) == IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Manager.zep", 1384); - return; - } - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVSVS(&_1$$3, "[", &intermediateModel, "].[", &intermediateFields, "] = :APR0:"); - zephir_array_append(&conditions, &_1$$3, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1387); - ZEPHIR_CALL_METHOD(&_2$$3, record, "readattribute", NULL, 0, &fields); - zephir_check_call_status(); - zephir_array_update_string(&placeholders, SL("APR0"), &_2$$3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&joinConditions); - array_init(&joinConditions); - ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatereferencedfields", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&intermediateFields) == IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Manager.zep", 1398); - return; - } - ZEPHIR_CALL_METHOD(&_3$$3, relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_CONCAT_SVSVSVSVS(&_4$$3, "[", &intermediateModel, "].[", &intermediateFields, "] = [", &referencedModel, "].[", &_3$$3, "]"); - zephir_array_append(&joinConditions, &_4$$3, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1401); - ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "mergefindparameters", NULL, 444, &extraParameters, parameters); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&builder, this_ptr, "createbuilder", NULL, 0, &_5$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &referencedModel); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_6$$3); - zephir_fast_join_str(&_6$$3, SL(" AND "), &joinConditions); - ZEPHIR_CALL_METHOD(NULL, &builder, "innerjoin", NULL, 0, &intermediateModel, &_6$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_7$$3); - zephir_fast_join_str(&_7$$3, SL(" AND "), &conditions); - ZEPHIR_CALL_METHOD(NULL, &builder, "andwhere", NULL, 0, &_7$$3, &placeholders); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&method, "count")) { - ZEPHIR_INIT_VAR(&_8$$6); - ZVAL_STRING(&_8$$6, "COUNT(*) AS rowcount"); - ZEPHIR_CALL_METHOD(NULL, &builder, "columns", NULL, 0, &_8$$6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_9$$6, &builder, "getquery", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&rows, &_9$$6, "execute", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&firstRow, &rows, "getfirst", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$6); - ZVAL_STRING(&_8$$6, "rowcount"); - ZEPHIR_CALL_METHOD(&_10$$6, &firstRow, "readattribute", NULL, 0, &_8$$6); - zephir_check_call_status(); - RETURN_MM_LONG(zephir_get_intval(&_10$$6)); - } - ZEPHIR_CALL_METHOD(&_11$$3, &builder, "getquery", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_11$$3); - ZEPHIR_CALL_METHOD(&_11$$3, relation, "gettype", NULL, 0); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_LONG(&_11$$3, 4)) { - ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_LONG(&_11$$3, 3)) { - ZVAL_BOOL(&_13$$8, 1); - ZEPHIR_CALL_METHOD(&_12$$8, &query, "setuniquerow", NULL, 0, &_13$$8); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_12$$8, "execute", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/Mvc/Model/Manager.zep", 1446); - return; - } while(0); - + if (!(ZEPHIR_IS_EMPTY(&indexType))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SVS(&_0$$3, "CREATE ", &indexType, " INDEX "); + zephir_get_strval(&sql, &_0$$3); + } else { + ZEPHIR_INIT_VAR(&sql); + ZVAL_STRING(&sql, "CREATE INDEX "); } - ZEPHIR_INIT_NVAR(&conditions); - array_init(&conditions); - ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&fields) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_14$$10); - ZEPHIR_CONCAT_SVS(&_14$$10, "[", &referencedFields, "] = :APR0:"); - zephir_array_append(&conditions, &_14$$10, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1463); - ZEPHIR_CALL_METHOD(&_15$$10, record, "readattribute", NULL, 0, &fields); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CALL_METHOD(&_1$$5, index, "getname", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&placeholders, SL("APR0"), &_15$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_2$$5); + ZEPHIR_CONCAT_SVSVS(&_2$$5, "\"", &schemaName, "\".\"", &_1$$5, "\""); + zephir_concat_self(&sql, &_2$$5); } else { - ZEPHIR_CALL_METHOD(&_16$$11, relation, "getfields", NULL, 0); + ZEPHIR_CALL_METHOD(&_3$$6, index, "getname", NULL, 0); zephir_check_call_status(); - zephir_is_iterable(&_16$$11, 0, "phalcon/Mvc/Model/Manager.zep", 1470); - if (Z_TYPE_P(&_16$$11) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_16$$11), _19$$11, _20$$11, _17$$11) - { - ZEPHIR_INIT_NVAR(&refPosition); - if (_20$$11 != NULL) { - ZVAL_STR_COPY(&refPosition, _20$$11); - } else { - ZVAL_LONG(&refPosition, _19$$11); - } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _17$$11); - zephir_array_fetch(&_21$$12, &referencedFields, &refPosition, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1467); - ZEPHIR_INIT_NVAR(&_22$$12); - ZEPHIR_CONCAT_SVSVS(&_22$$12, "[", &_21$$12, "] = :APR", &refPosition, ":"); - zephir_array_append(&conditions, &_22$$12, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1467); - ZEPHIR_CALL_METHOD(&_23$$12, record, "readattribute", &_24, 0, &field); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_25$$12); - ZEPHIR_CONCAT_SV(&_25$$12, "APR", &refPosition); - zephir_array_update_zval(&placeholders, &_25$$12, &_23$$12, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_16$$11, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_18$$11, &_16$$11, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_18$$11)) { - break; - } - ZEPHIR_CALL_METHOD(&refPosition, &_16$$11, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &_16$$11, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch(&_26$$13, &referencedFields, &refPosition, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1467); - ZEPHIR_INIT_NVAR(&_27$$13); - ZEPHIR_CONCAT_SVSVS(&_27$$13, "[", &_26$$13, "] = :APR", &refPosition, ":"); - zephir_array_append(&conditions, &_27$$13, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1467); - ZEPHIR_CALL_METHOD(&_28$$13, record, "readattribute", &_29, 0, &field); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_30$$13); - ZEPHIR_CONCAT_SV(&_30$$13, "APR", &refPosition); - zephir_array_update_zval(&placeholders, &_30$$13, &_28$$13, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &_16$$11, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&refPosition); + ZEPHIR_INIT_VAR(&_4$$6); + ZEPHIR_CONCAT_SVS(&_4$$6, "\"", &_3$$6, "\""); + zephir_concat_self(&sql, &_4$$6); } - ZEPHIR_INIT_VAR(&findParams); - zephir_create_array(&findParams, 3, 0); - ZEPHIR_INIT_VAR(&_31); - zephir_fast_join_str(&_31, SL(" AND "), &conditions); - zephir_array_fast_append(&findParams, &_31); - zephir_array_update_string(&findParams, SL("bind"), &placeholders, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_32, record, "getdi", NULL, 0); + ZEPHIR_CALL_METHOD(&_6, index, "getcolumns", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&findParams, SL("di"), &_32, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&findArguments, this_ptr, "mergefindparameters", NULL, 444, &findParams, parameters); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getcolumnlist", NULL, 57, &_6); zephir_check_call_status(); - if (Z_TYPE_P(&extraParameters) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&findParams, this_ptr, "mergefindparameters", NULL, 444, &extraParameters, &findArguments); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&findParams, &findArguments); - } - if (ZEPHIR_IS_NULL(&method)) { - ZEPHIR_CALL_METHOD(&_33$$16, relation, "gettype", NULL, 0); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_LONG(&_33$$16, 0) || ZEPHIR_IS_LONG(&_33$$16, 1)) { - ZEPHIR_INIT_VAR(&retrieveMethod); - ZVAL_STRING(&retrieveMethod, "findFirst"); - break; - } - if (ZEPHIR_IS_LONG(&_33$$16, 2)) { - ZEPHIR_INIT_NVAR(&retrieveMethod); - ZVAL_STRING(&retrieveMethod, "find"); - break; - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/Mvc/Model/Manager.zep", 1508); - return; - } while(0); + ZEPHIR_INIT_VAR(&_7); + ZEPHIR_CONCAT_SVSVS(&_7, " ON \"", &tableName, "\" (", &_5, ")"); + zephir_concat_self(&sql, &_7); + RETURN_CTOR(&sql); +} + +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addPrimaryKey) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub; + zval tableName, schemaName; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&index_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_CPY_WRT(&retrieveMethod, &method); + ZEPHIR_INIT_VAR(&tableName); } - ZEPHIR_CALL_METHOD(&_32, relation, "isreusable", NULL, 0); - zephir_check_call_status(); - reusable = zephir_get_boolval(&_32); - if (reusable) { - ZEPHIR_INIT_VAR(&_34$$21); - zephir_create_array(&_34$$21, 2, 0); - zephir_array_fast_append(&_34$$21, &findParams); - zephir_array_fast_append(&_34$$21, &retrieveMethod); - ZEPHIR_INIT_VAR(&uniqueKey); - zephir_unique_key(&uniqueKey, &referencedModel, &_34$$21); - ZEPHIR_CALL_METHOD(&records, this_ptr, "getreusablerecords", NULL, 0, &referencedModel, &uniqueKey); - zephir_check_call_status(); - _35$$21 = Z_TYPE_P(&records) == IS_ARRAY; - if (!(_35$$21)) { - _35$$21 = Z_TYPE_P(&records) == IS_OBJECT; - } - if (_35$$21) { - RETURN_CCTOR(&records); - } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&arguments); - zephir_create_array(&arguments, 1, 0); - zephir_array_fast_append(&arguments, &findParams); - ZEPHIR_INIT_VAR(&_36); - zephir_create_array(&_36, 2, 0); - ZEPHIR_CALL_METHOD(&_32, this_ptr, "load", NULL, 0, &referencedModel); - zephir_check_call_status(); - zephir_array_fast_append(&_36, &_32); - zephir_array_fast_append(&_36, &retrieveMethod); - ZEPHIR_INIT_NVAR(&records); - ZEPHIR_CALL_USER_FUNC_ARRAY(&records, &_36, &arguments); - zephir_check_call_status(); - if (reusable) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreusablerecords", NULL, 0, &referencedModel, &uniqueKey, &records); - zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - RETURN_CCTOR(&records); + + + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Adding a primary key after table has been created is not supported by SQLite", "phalcon/Db/Dialect/Sqlite.zep", 110); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelations) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, createTable) { - zval allRelations; + zend_bool hasPrimary = 0, _8$$7, _10$$7, _21$$15, _23$$15, _32$$24, _33$$24, _42$$27, _43$$27; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL, *_15 = NULL, *_37 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, entityName, relations, relation, _0, _3, _6, _9, _12, *_1$$3, _2$$3, *_4$$6, _5$$6, *_7$$9, _8$$9, *_10$$12, _11$$12, *_13$$15, _14$$15; - zval modelName; + zval definition; + zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, columns, table, temporary, options, createLines, columnLine, column, indexes, index, indexName, indexType, references, reference, defaultValue, referenceSql, onDelete, onUpdate, *_2, _3, _69, _70, _0$$5, _1$$6, _4$$7, _5$$7, _7$$7, _9$$7, _11$$7, _17$$7, _12$$10, _13$$12, _14$$12, _16$$12, _18$$15, _19$$15, _20$$15, _22$$15, _24$$15, _29$$15, _25$$18, _26$$20, _27$$20, _28$$20, *_30$$23, _31$$23, _34$$24, _35$$25, _36$$25, _38$$25, _39$$26, _40$$26, _41$$26, _44$$27, _45$$28, _46$$28, _47$$28, _48$$29, _49$$29, _50$$29, *_51$$30, _52$$30, _53$$31, _54$$31, _55$$31, _56$$31, _57$$31, _58$$31, _59$$32, _60$$33, _61$$34, _62$$34, _63$$34, _64$$34, _65$$34, _66$$34, _67$$35, _68$$36; + zval tableName, schemaName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&temporary); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&createLines); + ZVAL_UNDEF(&columnLine); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&indexes); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&indexName); + ZVAL_UNDEF(&indexType); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&referenceSql); + ZVAL_UNDEF(&onDelete); + ZVAL_UNDEF(&onUpdate); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_11$$12); - ZVAL_UNDEF(&_14$$15); - ZVAL_UNDEF(&allRelations); + ZVAL_UNDEF(&_69); + ZVAL_UNDEF(&_70); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_12$$10); + ZVAL_UNDEF(&_13$$12); + ZVAL_UNDEF(&_14$$12); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_18$$15); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_20$$15); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_24$$15); + ZVAL_UNDEF(&_29$$15); + ZVAL_UNDEF(&_25$$18); + ZVAL_UNDEF(&_26$$20); + ZVAL_UNDEF(&_27$$20); + ZVAL_UNDEF(&_28$$20); + ZVAL_UNDEF(&_31$$23); + ZVAL_UNDEF(&_34$$24); + ZVAL_UNDEF(&_35$$25); + ZVAL_UNDEF(&_36$$25); + ZVAL_UNDEF(&_38$$25); + ZVAL_UNDEF(&_39$$26); + ZVAL_UNDEF(&_40$$26); + ZVAL_UNDEF(&_41$$26); + ZVAL_UNDEF(&_44$$27); + ZVAL_UNDEF(&_45$$28); + ZVAL_UNDEF(&_46$$28); + ZVAL_UNDEF(&_47$$28); + ZVAL_UNDEF(&_48$$29); + ZVAL_UNDEF(&_49$$29); + ZVAL_UNDEF(&_50$$29); + ZVAL_UNDEF(&_52$$30); + ZVAL_UNDEF(&_53$$31); + ZVAL_UNDEF(&_54$$31); + ZVAL_UNDEF(&_55$$31); + ZVAL_UNDEF(&_56$$31); + ZVAL_UNDEF(&_57$$31); + ZVAL_UNDEF(&_58$$31); + ZVAL_UNDEF(&_59$$32); + ZVAL_UNDEF(&_60$$33); + ZVAL_UNDEF(&_61$$34); + ZVAL_UNDEF(&_62$$34); + ZVAL_UNDEF(&_63$$34); + ZVAL_UNDEF(&_64$$34); + ZVAL_UNDEF(&_65$$34); + ZVAL_UNDEF(&_66$$34); + ZVAL_UNDEF(&_67$$35); + ZVAL_UNDEF(&_68$$36); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(modelName) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &modelName_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&entityName); - zephir_fast_strtolower(&entityName, &modelName); - ZEPHIR_INIT_VAR(&allRelations); - array_init(&allRelations); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_0, &entityName, 0)) { - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1574); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1$$3) - { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _1$$3); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1572); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&temporary); + ZVAL_BOOL(&temporary, 0); + ZEPHIR_OBS_VAR(&options); + if (zephir_array_isset_string_fetch(&options, &definition, SL("options"), 0)) { + ZEPHIR_OBS_NVAR(&temporary); + zephir_array_isset_string_fetch(&temporary, &options, SL("temporary"), 0); + } + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/Db/Dialect/Sqlite.zep", 134); + return; + } + if (zephir_is_true(&temporary)) { + ZEPHIR_INIT_VAR(&_0$$5); + ZEPHIR_CONCAT_SV(&_0$$5, "CREATE TEMPORARY TABLE ", &table); + zephir_get_strval(&sql, &_0$$5); + } else { + ZEPHIR_INIT_VAR(&_1$$6); + ZEPHIR_CONCAT_SV(&_1$$6, "CREATE TABLE ", &table); + zephir_get_strval(&sql, &_1$$6); + } + zephir_concat_self_str(&sql, " (\n\t", sizeof(" (\n\t") - 1); + hasPrimary = 0; + ZEPHIR_INIT_VAR(&createLines); + array_init(&createLines); + zephir_is_iterable(&columns, 0, "phalcon/Db/Dialect/Sqlite.zep", 197); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _2) + { + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _2); + ZEPHIR_CALL_METHOD(&_4$$7, &column, "getname", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$3, &relations, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_5$$7, this_ptr, "getcolumndefinition", &_6, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&columnLine); + ZEPHIR_CONCAT_SVSV(&columnLine, "`", &_4$$7, "` ", &_5$$7); + ZEPHIR_CALL_METHOD(&_7$$7, &column, "isprimary", NULL, 0); + zephir_check_call_status(); + _8$$7 = zephir_is_true(&_7$$7); + if (_8$$7) { + _8$$7 = !hasPrimary; + } + if (_8$$7) { + zephir_concat_self_str(&columnLine, SL(" PRIMARY KEY")); + hasPrimary = 1; + } + ZEPHIR_CALL_METHOD(&_9$$7, &column, "isautoincrement", NULL, 0); + zephir_check_call_status(); + _10$$7 = zephir_is_true(&_9$$7); + if (_10$$7) { + _10$$7 = hasPrimary; + } + if (_10$$7) { + zephir_concat_self_str(&columnLine, SL(" AUTOINCREMENT")); + } + ZEPHIR_CALL_METHOD(&_11$$7, &column, "hasdefault", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_11$$7)) { + ZEPHIR_CALL_METHOD(&defaultValue, &column, "getdefault", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2$$3)) { - break; + ZEPHIR_INIT_NVAR(&_12$$10); + zephir_fast_strtoupper(&_12$$10, &defaultValue); + if (zephir_memnstr_str(&_12$$10, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Sqlite.zep", 175)) { + zephir_concat_self_str(&columnLine, SL(" DEFAULT CURRENT_TIMESTAMP")); + } else { + ZEPHIR_INIT_NVAR(&_13$$12); + ZVAL_STRING(&_13$$12, "\""); + ZEPHIR_CALL_FUNCTION(&_14$$12, "addcslashes", &_15, 214, &defaultValue, &_13$$12); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$12); + ZEPHIR_CONCAT_SVS(&_16$$12, " DEFAULT \"", &_14$$12, "\""); + zephir_concat_self(&columnLine, &_16$$12); } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1572); - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); - zephir_check_call_status(); } - } - ZEPHIR_INIT_NVAR(&relation); - } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_3, &entityName, 0)) { - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1583); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _4$$6) - { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _4$$6); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1581); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(&_17$$7, &column, "isnotnull", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$6, &relations, "valid", NULL, 0); + if (zephir_is_true(&_17$$7)) { + zephir_concat_self_str(&columnLine, SL(" NOT NULL")); + } else { + zephir_concat_self_str(&columnLine, SL(" NULL")); + } + zephir_array_append(&createLines, &columnLine, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 191); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_18$$15, &column, "getname", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_5$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&_19$$15, this_ptr, "getcolumndefinition", &_6, 0, &column); zephir_check_call_status(); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1581); - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&columnLine); + ZEPHIR_CONCAT_SVSV(&columnLine, "`", &_18$$15, "` ", &_19$$15); + ZEPHIR_CALL_METHOD(&_20$$15, &column, "isprimary", NULL, 0); zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&relation); - } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_6, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_6, &entityName, 0)) { - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1592); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _7$$9) - { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _7$$9); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1590); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8$$9, &relations, "valid", NULL, 0); + _21$$15 = zephir_is_true(&_20$$15); + if (_21$$15) { + _21$$15 = !hasPrimary; + } + if (_21$$15) { + zephir_concat_self_str(&columnLine, SL(" PRIMARY KEY")); + hasPrimary = 1; + } + ZEPHIR_CALL_METHOD(&_22$$15, &column, "isautoincrement", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_8$$9)) { - break; + _23$$15 = zephir_is_true(&_22$$15); + if (_23$$15) { + _23$$15 = hasPrimary; } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + if (_23$$15) { + zephir_concat_self_str(&columnLine, SL(" AUTOINCREMENT")); + } + ZEPHIR_CALL_METHOD(&_24$$15, &column, "hasdefault", NULL, 0); zephir_check_call_status(); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1590); - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + if (zephir_is_true(&_24$$15)) { + ZEPHIR_CALL_METHOD(&defaultValue, &column, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$18); + zephir_fast_strtoupper(&_25$$18, &defaultValue); + if (zephir_memnstr_str(&_25$$18, SL("CURRENT_TIMESTAMP"), "phalcon/Db/Dialect/Sqlite.zep", 175)) { + zephir_concat_self_str(&columnLine, SL(" DEFAULT CURRENT_TIMESTAMP")); + } else { + ZEPHIR_INIT_NVAR(&_26$$20); + ZVAL_STRING(&_26$$20, "\""); + ZEPHIR_CALL_FUNCTION(&_27$$20, "addcslashes", &_15, 214, &defaultValue, &_26$$20); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_28$$20); + ZEPHIR_CONCAT_SVS(&_28$$20, " DEFAULT \"", &_27$$20, "\""); + zephir_concat_self(&columnLine, &_28$$20); + } + } + ZEPHIR_CALL_METHOD(&_29$$15, &column, "isnotnull", NULL, 0); zephir_check_call_status(); - } + if (zephir_is_true(&_29$$15)) { + zephir_concat_self_str(&columnLine, SL(" NOT NULL")); + } else { + zephir_concat_self_str(&columnLine, SL(" NULL")); + } + zephir_array_append(&createLines, &columnLine, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 191); + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(&relation); } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_9, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_9, &entityName, 0)) { - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1601); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _10$$12) + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_OBS_VAR(&indexes); + if (zephir_array_isset_string_fetch(&indexes, &definition, SL("indexes"), 0)) { + zephir_is_iterable(&indexes, 0, "phalcon/Db/Dialect/Sqlite.zep", 211); + if (Z_TYPE_P(&indexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&indexes), _30$$23) { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _10$$12); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1599); + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _30$$23); + ZEPHIR_CALL_METHOD(&indexName, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexType, &index, "gettype", NULL, 0); + zephir_check_call_status(); + _32$$24 = ZEPHIR_IS_STRING(&indexName, "PRIMARY"); + if (_32$$24) { + _32$$24 = !hasPrimary; + } + _33$$24 = !(ZEPHIR_IS_EMPTY(&indexType)); + if (_33$$24) { + ZEPHIR_INIT_NVAR(&_34$$24); + zephir_fast_strtoupper(&_34$$24, &indexType); + _33$$24 = zephir_memnstr_str(&_34$$24, SL("UNIQUE"), "phalcon/Db/Dialect/Sqlite.zep", 207); + } + if (_32$$24) { + ZEPHIR_CALL_METHOD(&_36$$25, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_35$$25, this_ptr, "getcolumnlist", &_37, 57, &_36$$25); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_38$$25); + ZEPHIR_CONCAT_SVS(&_38$$25, "PRIMARY KEY (", &_35$$25, ")"); + zephir_array_append(&createLines, &_38$$25, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 206); + } else if (_33$$24) { + ZEPHIR_CALL_METHOD(&_40$$26, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_39$$26, this_ptr, "getcolumnlist", &_37, 57, &_40$$26); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_41$$26); + ZEPHIR_CONCAT_SVS(&_41$$26, "UNIQUE (", &_39$$26, ")"); + zephir_array_append(&createLines, &_41$$26, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 208); + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &indexes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_11$$12, &relations, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_31$$23, &indexes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_11$$12)) { + if (!zend_is_true(&_31$$23)) { break; } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&index, &indexes, "current", NULL, 0); zephir_check_call_status(); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1599); - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&indexName, &index, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexType, &index, "gettype", NULL, 0); + zephir_check_call_status(); + _42$$27 = ZEPHIR_IS_STRING(&indexName, "PRIMARY"); + if (_42$$27) { + _42$$27 = !hasPrimary; + } + _43$$27 = !(ZEPHIR_IS_EMPTY(&indexType)); + if (_43$$27) { + ZEPHIR_INIT_NVAR(&_44$$27); + zephir_fast_strtoupper(&_44$$27, &indexType); + _43$$27 = zephir_memnstr_str(&_44$$27, SL("UNIQUE"), "phalcon/Db/Dialect/Sqlite.zep", 207); + } + if (_42$$27) { + ZEPHIR_CALL_METHOD(&_46$$28, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_45$$28, this_ptr, "getcolumnlist", &_37, 57, &_46$$28); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_47$$28); + ZEPHIR_CONCAT_SVS(&_47$$28, "PRIMARY KEY (", &_45$$28, ")"); + zephir_array_append(&createLines, &_47$$28, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 206); + } else if (_43$$27) { + ZEPHIR_CALL_METHOD(&_49$$29, &index, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_48$$29, this_ptr, "getcolumnlist", &_37, 57, &_49$$29); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_50$$29); + ZEPHIR_CONCAT_SVS(&_50$$29, "UNIQUE (", &_48$$29, ")"); + zephir_array_append(&createLines, &_50$$29, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 208); + } + ZEPHIR_CALL_METHOD(NULL, &indexes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&relation); + ZEPHIR_INIT_NVAR(&index); } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_12, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_12, &entityName, 0)) { - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1610); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _13$$15) + ZEPHIR_OBS_VAR(&references); + if (zephir_array_isset_string_fetch(&references, &definition, SL("references"), 0)) { + zephir_is_iterable(&references, 0, "phalcon/Db/Dialect/Sqlite.zep", 233); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&references), _51$$30) { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _13$$15); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1608); + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _51$$30); + ZEPHIR_CALL_METHOD(&_53$$31, &reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_55$$31, &reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_54$$31, this_ptr, "getcolumnlist", &_37, 57, &_55$$31); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_56$$31, &reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_58$$31, &reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_57$$31, this_ptr, "getcolumnlist", &_37, 57, &_58$$31); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&referenceSql); + ZEPHIR_CONCAT_SVSVSSVSVS(&referenceSql, "CONSTRAINT `", &_53$$31, "` FOREIGN KEY (", &_54$$31, ")", " REFERENCES `", &_56$$31, "`(", &_57$$31, ")"); + ZEPHIR_CALL_METHOD(&onDelete, &reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_NVAR(&_59$$32); + ZEPHIR_CONCAT_SV(&_59$$32, " ON DELETE ", &onDelete); + zephir_concat_self(&referenceSql, &_59$$32); + } + ZEPHIR_CALL_METHOD(&onUpdate, &reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_NVAR(&_60$$33); + ZEPHIR_CONCAT_SV(&_60$$33, " ON UPDATE ", &onUpdate); + zephir_concat_self(&referenceSql, &_60$$33); + } + zephir_array_append(&createLines, &referenceSql, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 231); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_14$$15, &relations, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_52$$30, &references, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_14$$15)) { + if (!zend_is_true(&_52$$30)) { break; } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&reference, &references, "current", NULL, 0); zephir_check_call_status(); - zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1608); - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&_61$$34, &reference, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_63$$34, &reference, "getcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_62$$34, this_ptr, "getcolumnlist", &_37, 57, &_63$$34); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_64$$34, &reference, "getreferencedtable", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_66$$34, &reference, "getreferencedcolumns", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_65$$34, this_ptr, "getcolumnlist", &_37, 57, &_66$$34); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&referenceSql); + ZEPHIR_CONCAT_SVSVSSVSVS(&referenceSql, "CONSTRAINT `", &_61$$34, "` FOREIGN KEY (", &_62$$34, ")", " REFERENCES `", &_64$$34, "`(", &_65$$34, ")"); + ZEPHIR_CALL_METHOD(&onDelete, &reference, "getondelete", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onDelete))) { + ZEPHIR_INIT_NVAR(&_67$$35); + ZEPHIR_CONCAT_SV(&_67$$35, " ON DELETE ", &onDelete); + zephir_concat_self(&referenceSql, &_67$$35); + } + ZEPHIR_CALL_METHOD(&onUpdate, &reference, "getonupdate", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&onUpdate))) { + ZEPHIR_INIT_NVAR(&_68$$36); + ZEPHIR_CONCAT_SV(&_68$$36, " ON UPDATE ", &onUpdate); + zephir_concat_self(&referenceSql, &_68$$36); + } + zephir_array_append(&createLines, &referenceSql, PH_SEPARATE, "phalcon/Db/Dialect/Sqlite.zep", 231); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&relation); + ZEPHIR_INIT_NVAR(&reference); } - RETURN_CTOR(&allRelations); + ZEPHIR_INIT_VAR(&_69); + zephir_fast_join_str(&_69, SL(",\n\t"), &createLines); + ZEPHIR_INIT_VAR(&_70); + ZEPHIR_CONCAT_VS(&_70, &_69, "\n)"); + zephir_concat_self(&sql, &_70); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationsBetween) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, createView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *first_param = NULL, *second_param = NULL, relations, _0, _1, _2, _3, _4, _5, _6, _7; - zval first, second, keyRelation; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval definition; + zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, viewSql, _0; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&first); - ZVAL_UNDEF(&second); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&viewSql); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(first) - Z_PARAM_STR(second) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(viewName) + Z_PARAM_ARRAY(definition) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &first_param, &second_param); - if (UNEXPECTED(Z_TYPE_P(first_param) != IS_STRING && Z_TYPE_P(first_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'first' must be of the type string")); + zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(first_param) == IS_STRING)) { - zephir_get_strval(&first, first_param); + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - ZEPHIR_INIT_VAR(&first); - } - if (UNEXPECTED(Z_TYPE_P(second_param) != IS_STRING && Z_TYPE_P(second_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'second' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&viewName); } - if (EXPECTED(Z_TYPE_P(second_param) == IS_STRING)) { - zephir_get_strval(&second, second_param); + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); } else { - ZEPHIR_INIT_VAR(&second); + zephir_get_strval(&schemaName, schemaName_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &first); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &second); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - ZEPHIR_OBS_VAR(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0)) { - RETURN_CCTOR(&relations); - } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_4, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_4, &keyRelation, 0)) { - RETURN_CCTOR(&relations); - } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_5, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_5, &keyRelation, 0)) { - RETURN_CCTOR(&relations); - } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_6, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_6, &keyRelation, 0)) { - RETURN_CCTOR(&relations); - } - ZEPHIR_OBS_NVAR(&relations); - zephir_read_property(&_7, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&relations, &_7, &keyRelation, 0)) { - RETURN_CCTOR(&relations); + ZEPHIR_OBS_VAR(&viewSql); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&viewSql, &definition, SL("sql"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/Db/Dialect/Sqlite.zep", 250); + return; } - RETURN_MM_BOOL(0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, &viewName, &schemaName); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", &_0, " AS ", &viewSql); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReusableRecords) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeColumns) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *modelName_param = NULL, *key_param = NULL, records, _0; - zval modelName, key; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &key_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&table); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - ZEPHIR_INIT_VAR(&key); + zephir_get_strval(&schema, schema_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&records, &_0, &key, 1))) { - RETURN_MM_NULL(); - } - RETURN_CTOR(&records); + ZEPHIR_CONCAT_SVS(return_value, "PRAGMA table_info('", &table, "')"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnection) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; + zval *index_param = NULL; + zval index; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&index); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(index) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &index_param); + if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { + zephir_get_strval(&index, index_param); + } else { + ZEPHIR_INIT_VAR(&index); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, model, &_0); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "PRAGMA index_info('", &index, "')"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnectionService) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeIndexes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "PRAGMA index_list('", &table, "')"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasBelongsTo) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeReferences) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&table); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_get_strval(&schema, schema_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "belongsTo"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 445, &_0, &modelName, &modelRelation); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "PRAGMA foreign_key_list('", &table, "')"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasMany) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL; + zval tableName, schemaName, columnName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&columnName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(columnName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(columnName_param) != IS_STRING && Z_TYPE_P(columnName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'columnName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(columnName_param) == IS_STRING)) { + zephir_get_strval(&columnName, columnName_param); + } else { + ZEPHIR_INIT_VAR(&columnName); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasMany"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 445, &_0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Dropping DB column is not supported by SQLite", "phalcon/Db/Dialect/Sqlite.zep", 299); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasManyToMany) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL; + zval tableName, schemaName, referenceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&referenceName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(referenceName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceName_param) == IS_STRING)) { + zephir_get_strval(&referenceName, referenceName_param); + } else { + ZEPHIR_INIT_VAR(&referenceName); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasManyToMany"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 445, &_0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Dropping a foreign key constraint is not supported by SQLite", "phalcon/Db/Dialect/Sqlite.zep", 309); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasOne) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL; + zval tableName, schemaName, indexName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&indexName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(indexName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(indexName_param) == IS_STRING)) { + zephir_get_strval(&indexName, indexName_param); + } else { + ZEPHIR_INIT_VAR(&indexName); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasOne"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 445, &_0, &modelName, &modelRelation); - zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_CONCAT_SVSVS(return_value, "DROP INDEX \"", &schemaName, "\".\"", &indexName, "\""); + RETURN_MM(); + } + ZEPHIR_CONCAT_SVS(return_value, "DROP INDEX \"", &indexName, "\""); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasOneThrough) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropPrimaryKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *tableName_param = NULL, *schemaName_param = NULL; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&tableName); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasOneThrough"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 445, &_0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Removing a primary key after table has been created is not supported by SQLite", "phalcon/Db/Dialect/Sqlite.zep", 331); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, initialize) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, __$true, className, eventsManager, _0, _1, _2$$5; + zend_bool ifExists; + zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, table; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&table); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(tableName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &className)) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); } - zephir_update_property_array(this_ptr, SL("initialized"), &className, &__$true); - if ((zephir_method_exists_ex(model, ZEND_STRL("initialize")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); - zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); } - zephir_update_property_zval(this_ptr, ZEND_STRL("lastInitialized"), model); - zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_1); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_2$$5); - ZVAL_STRING(&_2$$5, "modelsManager:afterInitialize"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_2$$5, this_ptr, model); - zephir_check_call_status(); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - RETURN_MM_BOOL(1); + if (!ifExists_param) { + ifExists = 1; + } else { + if (UNEXPECTED(Z_TYPE_P(ifExists_param) != IS_TRUE && Z_TYPE_P(ifExists_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be of the type bool")); + RETURN_MM_NULL(); + } + ifExists = (Z_TYPE_P(ifExists_param) == IS_TRUE); + } + + + ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + if (ifExists) { + ZEPHIR_CONCAT_SV(return_value, "DROP TABLE IF EXISTS ", &table); + RETURN_MM(); + } + ZEPHIR_CONCAT_SV(return_value, "DROP TABLE ", &table); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isInitialized) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *className_param = NULL, _0, _1; - zval className; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool ifExists; + zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, view; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&view); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(className) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(viewName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &className_param); - if (UNEXPECTED(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be of the type string")); + zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(className_param) == IS_STRING)) { - zephir_get_strval(&className, className_param); + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - ZEPHIR_INIT_VAR(&className); + ZEPHIR_INIT_VAR(&viewName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } + if (!ifExists_param) { + ifExists = 1; + } else { + if (UNEXPECTED(Z_TYPE_P(ifExists_param) != IS_TRUE && Z_TYPE_P(ifExists_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be of the type bool")); + RETURN_MM_NULL(); + } + ifExists = (Z_TYPE_P(ifExists_param) == IS_TRUE); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &className); - RETURN_MM_BOOL(zephir_array_isset(&_0, &_1)); + ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, &viewName, &schemaName); + zephir_check_call_status(); + if (ifExists) { + ZEPHIR_CONCAT_SV(return_value, "DROP VIEW IF EXISTS ", &view); + RETURN_MM(); + } + ZEPHIR_CONCAT_SV(return_value, "DROP VIEW ", &view); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isKeepingSnapshots) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, forUpdate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, isKeeping, _0, _1; + zval *sqlQuery_param = NULL; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&isKeeping); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&sqlQuery); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(sqlQuery) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - if (ZEPHIR_GLOBAL(orm).dynamic_update) { - RETURN_MM_BOOL(1); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&isKeeping, &_0, &_1, 1))) { - RETURN_MM_BOOL(0); + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); } - RETURN_CTOR(&isKeeping); + + + RETURN_CTOR(&sqlQuery); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isUsingDynamicUpdate) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, getColumnDefinition) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, isUsing, _0, _1; + zephir_fcall_cache_entry *_12 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *column, column_sub, columnType, columnSql, typeValues, _0$$3, _1$$10, _2$$16, _3$$18, _4$$35, _5$$38, _6$$38, _7$$38, value$$40, valueSql$$40, *_8$$40, _9$$40, _17$$40, _18$$40, _19$$40, _20$$40, _10$$41, _11$$41, _13$$41, _14$$42, _15$$42, _16$$42, _21$$43, _22$$43, _23$$43; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&isUsing); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&columnType); + ZVAL_UNDEF(&columnSql); + ZVAL_UNDEF(&typeValues); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$10); + ZVAL_UNDEF(&_2$$16); + ZVAL_UNDEF(&_3$$18); + ZVAL_UNDEF(&_4$$35); + ZVAL_UNDEF(&_5$$38); + ZVAL_UNDEF(&_6$$38); + ZVAL_UNDEF(&_7$$38); + ZVAL_UNDEF(&value$$40); + ZVAL_UNDEF(&valueSql$$40); + ZVAL_UNDEF(&_9$$40); + ZVAL_UNDEF(&_17$$40); + ZVAL_UNDEF(&_18$$40); + ZVAL_UNDEF(&_19$$40); + ZVAL_UNDEF(&_20$$40); + ZVAL_UNDEF(&_10$$41); + ZVAL_UNDEF(&_11$$41); + ZVAL_UNDEF(&_13$$41); + ZVAL_UNDEF(&_14$$42); + ZVAL_UNDEF(&_15$$42); + ZVAL_UNDEF(&_16$$42); + ZVAL_UNDEF(&_21$$43); + ZVAL_UNDEF(&_22$$43); + ZVAL_UNDEF(&_23$$43); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &column); - if (ZEPHIR_GLOBAL(orm).dynamic_update) { - RETURN_MM_BOOL(1); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&isUsing, &_0, &_1, 1))) { - RETURN_MM_BOOL(0); - } - RETURN_CTOR(&isUsing); + ZEPHIR_CALL_METHOD(&columnSql, this_ptr, "checkcolumntypesql", NULL, 0, column); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnType, this_ptr, "checkcolumntype", NULL, 0, column); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_LONG(&columnType, 14)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("BIGINT")); + } + ZEPHIR_CALL_METHOD(&_0$$3, column, "isunsigned", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0$$3)) { + zephir_concat_self_str(&columnSql, SL(" UNSIGNED")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 11)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("BLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 8)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TINYINT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 5)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("CHARACTER")); + } + ZEPHIR_CALL_METHOD(&_1$$10, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_1$$10); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 1)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DATE")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 4)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DATETIME")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 3)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("NUMERIC")); + } + ZEPHIR_CALL_METHOD(&_2$$16, this_ptr, "getcolumnsizeandscale", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_2$$16); + break; + } + if (ZEPHIR_IS_LONG(&columnType, 9)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("DOUBLE")); + } + ZEPHIR_CALL_METHOD(&_3$$18, column, "isunsigned", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_3$$18)) { + zephir_concat_self_str(&columnSql, SL(" UNSIGNED")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 7)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("FLOAT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 0)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("INTEGER")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 13)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("LONGBLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 12)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("MEDIUMBLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 6)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TEXT")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 17)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TIMESTAMP")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 10)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("TINYBLOB")); + } + break; + } + if (ZEPHIR_IS_LONG(&columnType, 2)) { + if (ZEPHIR_IS_EMPTY(&columnSql)) { + zephir_concat_self_str(&columnSql, SL("VARCHAR")); + } + ZEPHIR_CALL_METHOD(&_4$$35, this_ptr, "getcolumnsize", NULL, 0, column); + zephir_check_call_status(); + zephir_concat_self(&columnSql, &_4$$35); + break; + } + if (ZEPHIR_IS_EMPTY(&columnSql)) { + ZEPHIR_INIT_VAR(&_5$$38); + object_init_ex(&_5$$38, phalcon_db_exception_ce); + ZEPHIR_CALL_METHOD(&_6$$38, column, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_7$$38); + ZEPHIR_CONCAT_SV(&_7$$38, "Unrecognized SQLite data type at column ", &_6$$38); + ZEPHIR_CALL_METHOD(NULL, &_5$$38, "__construct", NULL, 32, &_7$$38); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$38, "phalcon/Db/Dialect/Sqlite.zep", 520); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&typeValues, column, "gettypevalues", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&typeValues))) { + if (Z_TYPE_P(&typeValues) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&valueSql$$40); + ZVAL_STRING(&valueSql$$40, ""); + zephir_is_iterable(&typeValues, 0, "phalcon/Db/Dialect/Sqlite.zep", 534); + if (Z_TYPE_P(&typeValues) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&typeValues), _8$$40) + { + ZEPHIR_INIT_NVAR(&value$$40); + ZVAL_COPY(&value$$40, _8$$40); + ZEPHIR_INIT_NVAR(&_10$$41); + ZVAL_STRING(&_10$$41, "\""); + ZEPHIR_CALL_FUNCTION(&_11$$41, "addcslashes", &_12, 214, &value$$40, &_10$$41); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_13$$41); + ZEPHIR_CONCAT_SVS(&_13$$41, "\"", &_11$$41, "\", "); + zephir_concat_self(&valueSql$$40, &_13$$41); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &typeValues, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9$$40, &typeValues, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9$$40)) { + break; + } + ZEPHIR_CALL_METHOD(&value$$40, &typeValues, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$42); + ZVAL_STRING(&_14$$42, "\""); + ZEPHIR_CALL_FUNCTION(&_15$$42, "addcslashes", &_12, 214, &value$$40, &_14$$42); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$42); + ZEPHIR_CONCAT_SVS(&_16$$42, "\"", &_15$$42, "\", "); + zephir_concat_self(&valueSql$$40, &_16$$42); + ZEPHIR_CALL_METHOD(NULL, &typeValues, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value$$40); + ZVAL_LONG(&_17$$40, 0); + ZVAL_LONG(&_18$$40, -2); + ZEPHIR_INIT_VAR(&_19$$40); + zephir_substr(&_19$$40, &valueSql$$40, 0 , -2 , 0); + ZEPHIR_INIT_VAR(&_20$$40); + ZEPHIR_CONCAT_SVS(&_20$$40, "(", &_19$$40, ")"); + zephir_concat_self(&columnSql, &_20$$40); + } else { + ZEPHIR_INIT_VAR(&_21$$43); + ZVAL_STRING(&_21$$43, "\""); + ZEPHIR_CALL_FUNCTION(&_22$$43, "addcslashes", &_12, 214, &typeValues, &_21$$43); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_23$$43); + ZEPHIR_CONCAT_SVS(&_23$$43, "(\"", &_22$$43, "\")"); + zephir_concat_self(&columnSql, &_23$$43); + } + } + } while(0); + + RETURN_CCTOR(&columnSql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isVisibleModelProperty) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, listIndexesSql) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval property; - zval *model, model_sub, *property_param = NULL, __$true, properties, className, publicProperties, classReflection, reflectionProperties, reflectionProperty, _0, _6, _1$$3, *_2$$3, _3$$3, _4$$4, _5$$5; + zval *table_param = NULL, *schema_param = NULL, *keyName_param = NULL, _0, _1, _2$$3, _3$$3; + zval table, schema, keyName, sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&properties); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&publicProperties); - ZVAL_UNDEF(&classReflection); - ZVAL_UNDEF(&reflectionProperties); - ZVAL_UNDEF(&reflectionProperty); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&sql); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&property); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + Z_PARAM_STR_OR_NULL(keyName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &property_param); - zephir_get_strval(&property, property_param); + zephir_fetch_params(1, 1, 2, &table_param, &schema_param, &keyName_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); + } + if (!keyName_param) { + ZEPHIR_INIT_VAR(&keyName); + } else { + zephir_get_strval(&keyName, keyName_param); + } - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &className))) { - ZEPHIR_INIT_VAR(&publicProperties); - array_init(&publicProperties); - ZEPHIR_INIT_VAR(&classReflection); - object_init_ex(&classReflection, zephir_get_internal_ce(SL("reflectionclass"))); - ZEPHIR_CALL_METHOD(NULL, &classReflection, "__construct", NULL, 153, &className); - zephir_check_call_status(); - ZVAL_LONG(&_1$$3, 1); - ZEPHIR_CALL_METHOD(&reflectionProperties, &classReflection, "getproperties", NULL, 164, &_1$$3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "escape", NULL, 56, &table); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "SELECT sql FROM sqlite_master WHERE type = 'index' AND tbl_name = ", &_0, " COLLATE NOCASE"); + zephir_get_strval(&sql, &_1); + if (!(ZEPHIR_IS_EMPTY(&keyName))) { + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "escape", NULL, 56, &keyName); zephir_check_call_status(); - zephir_is_iterable(&reflectionProperties, 0, "phalcon/Mvc/Model/Manager.zep", 1913); - if (Z_TYPE_P(&reflectionProperties) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&reflectionProperties), _2$$3) - { - ZEPHIR_INIT_NVAR(&reflectionProperty); - ZVAL_COPY(&reflectionProperty, _2$$3); - ZEPHIR_OBS_NVAR(&_4$$4); - zephir_read_property(&_4$$4, &reflectionProperty, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&publicProperties, &_4$$4, &__$true, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &reflectionProperties, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&reflectionProperty, &reflectionProperties, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&_5$$5); - zephir_read_property(&_5$$5, &reflectionProperty, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&publicProperties, &_5$$5, &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&reflectionProperty); - zephir_update_property_array(this_ptr, SL("modelVisibility"), &className, &publicProperties); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, " AND name = ", &_2$$3, " COLLATE NOCASE"); + zephir_concat_self(&sql, &_3$$3); } - zephir_read_property(&_6, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_OBS_VAR(&properties); - zephir_array_fetch(&properties, &_6, &className, PH_NOISY, "phalcon/Mvc/Model/Manager.zep", 1916); - RETURN_MM_BOOL(zephir_array_key_exists(&properties, &property)); + RETURN_CTOR(&sql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, keepSnapshots) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, listTables) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool keepSnapshots; - zval *model, model_sub, *keepSnapshots_param = NULL, _0, _1; + zval *schemaName_param = NULL; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_BOOL(keepSnapshots) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &keepSnapshots_param); - keepSnapshots = zephir_get_boolval(keepSnapshots_param); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, keepSnapshots); - zephir_update_property_array(this_ptr, SL("keepSnapshots"), &_0, &_1); - ZEPHIR_MM_RESTORE(); + RETURN_MM_STRING("SELECT tbl_name FROM sqlite_master WHERE type = 'table' ORDER BY tbl_name"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, load) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, listViews) { - zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, __$null, model, _3, _0$$3; - zval modelName, _1$$3; + zval *schemaName_param = NULL; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&_1$$3); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(modelName) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &modelName_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&schemaName); + } } - if (UNEXPECTED(!(zephir_class_exists(&modelName, 1)))) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVS(&_1$$3, "Model '", &modelName, "' could not be loaded"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 32, &_1$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/Manager.zep", 1951); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 3, 0); - zephir_array_fast_append(&_2, &__$null); - ZEPHIR_OBS_VAR(&_3); - zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC); - zephir_array_fast_append(&_2, &_3); - zephir_array_fast_append(&_2, this_ptr); - ZEPHIR_INIT_VAR(&model); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_2); - zephir_check_call_status(); - RETURN_CCTOR(&model); + RETURN_MM_STRING("SELECT tbl_name FROM sqlite_master WHERE type = 'view' ORDER BY tbl_name"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, modifyColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, *model, model_sub, status, behavior, modelsBehaviors, eventsManager, customEventsManager, _0, _1, _4, _6, *_2$$3, _3$$3; - zval eventName, _5$$8, _7$$10; - zval *this_ptr = getThis(); + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, *currentColumn = NULL, currentColumn_sub, __$null; + zval tableName, schemaName; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_5$$8); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&behavior); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&customEventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(¤tColumn_sub); + ZVAL_NULL(&__$null); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(eventName) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(currentColumn, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &eventName_param, &model); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); + zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&eventName); + ZEPHIR_INIT_VAR(&tableName); } - - - ZEPHIR_INIT_VAR(&status); - ZVAL_BOOL(&status, 1); - ZEPHIR_OBS_VAR(&modelsBehaviors); - zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) { - zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 1998); - if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3) - { - ZEPHIR_INIT_NVAR(&behavior); - ZVAL_COPY(&behavior, _2$$3); - ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&behavior); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_4); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_5$$8); - ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName); - ZEPHIR_CALL_METHOD(&status, &eventsManager, "fire", NULL, 0, &_5$$8, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_CCTOR(&status); - } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_OBS_VAR(&customEventsManager); - zephir_read_property(&_4, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_6); - zephir_get_class(&_6, model, 1); - if (zephir_array_isset_fetch(&customEventsManager, &_4, &_6, 0)) { - ZEPHIR_INIT_VAR(&_7$$10); - ZEPHIR_CONCAT_SV(&_7$$10, "model:", &eventName); - ZEPHIR_CALL_METHOD(&status, &customEventsManager, "fire", NULL, 0, &_7$$10, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } + if (!currentColumn) { + currentColumn = ¤tColumn_sub; + currentColumn = &__$null; } - RETURN_CCTOR(&status); + + + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Altering a DB column is not supported by SQLite", "phalcon/Db/Dialect/Sqlite.zep", 593); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, missingMethod) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, sharedLock) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval eventName, _5$$8; - zval *model, model_sub, *eventName_param = NULL, *data, data_sub, modelsBehaviors, result, eventsManager, behavior, _0, _1, _4, *_2$$3, _3$$3; + zval *sqlQuery_param = NULL; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&behavior); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&sqlQuery); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(eventName) - Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sqlQuery) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); } else { - ZEPHIR_INIT_VAR(&eventName); + ZEPHIR_INIT_VAR(&sqlQuery); } - ZEPHIR_OBS_VAR(&modelsBehaviors); - zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) { - zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 2060); - if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3) - { - ZEPHIR_INIT_NVAR(&behavior); - ZVAL_COPY(&behavior, _2$$3); - ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_NULL) { - RETURN_CCTOR(&result); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_NULL) { - RETURN_CCTOR(&result); - } - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&behavior); - } - zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_4); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_5$$8); - ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName); - ZEPHIR_RETURN_CALL_METHOD(&eventsManager, "fire", NULL, 0, &_5$$8, model, data); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_MM_NULL(); + RETURN_CTOR(&sqlQuery); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setConnectionService) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, tableExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL; + zval *tableName_param = NULL, *schemaName_param = NULL; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(connectionService) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tableName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_INIT_VAR(&connectionService); + ZEPHIR_INIT_VAR(&tableName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreadconnectionservice", NULL, 0, model, &connectionService); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwriteconnectionservice", NULL, 0, model, &connectionService); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM sqlite_master WHERE type='table' AND tbl_name='", &tableName, "'"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setCustomEventsManager) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, tableOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, *eventsManager, eventsManager_sub, _0; + zval *table_param = NULL, *schema_param = NULL; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&eventsManager_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &eventsManager); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); + } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("customEventsManager"), &_0, eventsManager); - ZEPHIR_MM_RESTORE(); + RETURN_MM_STRING(""); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setDI) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, truncateTable) { - zval *container, container_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *tableName_param = NULL, *schemaName_param = NULL; + zval tableName, schemaName, table; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&table); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &container); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + if (!(ZEPHIR_IS_EMPTY(&schemaName))) { + ZEPHIR_INIT_VAR(&table); + ZEPHIR_CONCAT_SVSVS(&table, "\"", &schemaName, "\".\"", &tableName, "\""); + } else { + ZEPHIR_INIT_NVAR(&table); + ZEPHIR_CONCAT_SVS(&table, "\"", &tableName, "\""); + } + ZEPHIR_CONCAT_SV(return_value, "DELETE FROM ", &table); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setEventsManager) +static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, viewExists) { - zval *eventsManager, eventsManager_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *viewName_param = NULL, *schemaName_param = NULL; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(viewName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); + } else { + ZEPHIR_INIT_VAR(&viewName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM sqlite_master WHERE type='view' AND tbl_name='", &viewName, "'"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelPrefix) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *prefix_param = NULL; - zval prefix; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); - ZEPHIR_MM_RESTORE(); + + + +ZEPHIR_INIT_CLASS(Phalcon_Db_Result_PdoResult) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Db\\Result, PdoResult, phalcon, db_result_pdoresult, phalcon_db_result_pdoresult_method_entry, 0); + + zend_declare_property_null(phalcon_db_result_pdoresult_ce, SL("bindParams"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_result_pdoresult_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_result_pdoresult_ce, SL("connection"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_result_pdoresult_ce, SL("fetchMode"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_result_pdoresult_ce, SL("pdoStatement"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_result_pdoresult_ce, SL("result"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_result_pdoresult_ce, SL("rowCount"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_result_pdoresult_ce, SL("sqlStatement"), ZEND_ACC_PROTECTED); + phalcon_db_result_pdoresult_ce->create_object = zephir_init_properties_Phalcon_Db_Result_PdoResult; + + zend_class_implements(phalcon_db_result_pdoresult_ce, 1, phalcon_db_resultinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSchema) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, __construct) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval schema; - zval *model, model_sub, *schema_param = NULL, _0; + zval *connection, connection_sub, *result, result_sub, *sqlStatement = NULL, sqlStatement_sub, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&result_sub); + ZVAL_UNDEF(&sqlStatement_sub); + ZVAL_UNDEF(&bindParams_sub); + ZVAL_UNDEF(&bindTypes_sub); + ZVAL_NULL(&__$null); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(schema) + ZEND_PARSE_PARAMETERS_START(2, 5) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(result, zephir_get_internal_ce(SL("pdostatement"))) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(sqlStatement) + Z_PARAM_ZVAL_OR_NULL(bindParams) + Z_PARAM_ZVAL_OR_NULL(bindTypes) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &schema_param); - if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params_without_memory_grow(2, 3, &connection, &result, &sqlStatement, &bindParams, &bindTypes); + if (!sqlStatement) { + sqlStatement = &sqlStatement_sub; + sqlStatement = &__$null; } - if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { - zephir_get_strval(&schema, schema_param); - } else { - ZEPHIR_INIT_VAR(&schema); + if (!bindParams) { + bindParams = &bindParams_sub; + bindParams = &__$null; + } + if (!bindTypes) { + bindTypes = &bindTypes_sub; + bindTypes = &__$null; } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("schemas"), &_0, &schema); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("connection"), connection); + zephir_update_property_zval(this_ptr, ZEND_STRL("pdoStatement"), result); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlStatement"), sqlStatement); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), bindTypes); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSource) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, dataSeek) { + long n = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval source; - zval *model, model_sub, *source_param = NULL, _0; + zephir_fcall_cache_entry *_4 = NULL; + zval *number_param = NULL, connection, pdo, sqlStatement, bindParams, statement, _0, _1$$4, _2$$4, _3$$6; + zend_long number, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&pdo); + ZVAL_UNDEF(&sqlStatement); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&statement); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&source); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(source) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(number) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &source_param); - if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) { - zephir_get_strval(&source, source_param); - } else { - ZEPHIR_INIT_VAR(&source); - } + zephir_fetch_params(1, 1, 0, &number_param); + number = zephir_get_intval(number_param); - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("sources"), &_0, &source); + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&connection, &_0); + ZEPHIR_CALL_METHOD(&pdo, &connection, "getinternalhandler", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlStatement"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlStatement, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&bindParams, &_0); + if (Z_TYPE_P(&bindParams) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&statement, &pdo, "prepare", NULL, 0, &sqlStatement); + zephir_check_call_status(); + if (Z_TYPE_P(&statement) == IS_OBJECT) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1$$4, &connection, "executeprepared", NULL, 0, &statement, &bindParams, &_2$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&statement, &_1$$4); + } + } else { + ZEPHIR_CALL_METHOD(&statement, &pdo, "query", NULL, 0, &sqlStatement); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("pdoStatement"), &statement); + n = -1; + number--; + while (1) { + if (!(n != number)) { + break; + } + zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("fetchMode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &statement, "fetch", &_4, 0, &_3$$6); + zephir_check_call_status(); + n++; + } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReadConnectionService) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, execute) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionService); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(connectionService) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - } - - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("readConnectionServices"), &_0, &connectionService); - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "execute", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReusableRecords) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, fetch) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *modelName_param = NULL, *key_param = NULL, *records, records_sub; - zval modelName, key; + zval *fetchStyle_param = NULL, *cursorOrientation_param = NULL, *cursorOffset_param = NULL, mode, _0, _1, _2; + zend_long fetchStyle, cursorOrientation, cursorOffset, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&records_sub); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(modelName) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(records) + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(fetchStyle, is_null_true) + Z_PARAM_LONG(cursorOrientation) + Z_PARAM_LONG(cursorOffset) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &modelName_param, &key_param, &records); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + zephir_fetch_params(1, 0, 3, &fetchStyle_param, &cursorOrientation_param, &cursorOffset_param); + if (!fetchStyle_param) { + fetchStyle = 0; } else { - ZEPHIR_INIT_VAR(&modelName); + fetchStyle = zephir_get_intval(fetchStyle_param); } - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + if (!cursorOrientation_param) { + cursorOrientation = 0; + } else { + cursorOrientation = zephir_get_intval(cursorOrientation_param); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (!cursorOffset_param) { + cursorOffset = 0; } else { - ZEPHIR_INIT_VAR(&key); + cursorOffset = zephir_get_intval(cursorOffset_param); } - zephir_update_property_array(this_ptr, SL("reusable"), &key, records); - ZEPHIR_MM_RESTORE(); + if (1 == 1) { + ZEPHIR_INIT_VAR(&mode); + ZVAL_LONG(&mode, fetchStyle); + } else { + ZEPHIR_OBS_NVAR(&mode); + zephir_read_property(&mode, this_ptr, ZEND_STRL("fetchMode"), PH_NOISY_CC); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, cursorOrientation); + ZVAL_LONG(&_2, cursorOffset); + ZEPHIR_RETURN_CALL_METHOD(&_0, "fetch", NULL, 0, &mode, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setWriteConnectionService) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, fetchAll) { + zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL, _0; + zval *mode_param = NULL, *fetchArgument = NULL, fetchArgument_sub, *constructorArgs = NULL, constructorArgs_sub, __$null, _0$$3, _1$$3, _5, _6, _3$$4, _4$$4; + zend_long mode, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&fetchArgument_sub); + ZVAL_UNDEF(&constructorArgs_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(connectionService) + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(mode) + Z_PARAM_ZVAL(fetchArgument) + Z_PARAM_ZVAL_OR_NULL(constructorArgs) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); + zephir_fetch_params(1, 0, 3, &mode_param, &fetchArgument, &constructorArgs); + if (!mode_param) { + mode = 0; } else { - ZEPHIR_INIT_VAR(&connectionService); + mode = zephir_get_intval(mode_param); + } + if (!fetchArgument) { + fetchArgument = &fetchArgument_sub; + ZEPHIR_INIT_VAR(fetchArgument); + ZVAL_LONG(fetchArgument, 0); + } + if (!constructorArgs) { + constructorArgs = &constructorArgs_sub; + constructorArgs = &__$null; } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("writeConnectionServices"), &_0, &connectionService); - ZEPHIR_MM_RESTORE(); + if (mode == 8) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1$$3, mode); + ZEPHIR_RETURN_CALL_METHOD(&_0$$3, "fetchall", NULL, 0, &_1$$3, fetchArgument, constructorArgs); + zephir_check_call_status(); + RETURN_MM(); + } + _2 = mode == 7; + if (!(_2)) { + _2 = mode == 10; + } + if (_2) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_4$$4, mode); + ZEPHIR_RETURN_CALL_METHOD(&_3$$4, "fetchall", NULL, 0, &_4$$4, fetchArgument); + zephir_check_call_status(); + RETURN_MM(); + } + zephir_read_property(&_5, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6, mode); + ZEPHIR_RETURN_CALL_METHOD(&_5, "fetchall", NULL, 0, &_6); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, useDynamicUpdate) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, fetchArray) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool dynamicUpdate; - zval *model, model_sub, *dynamicUpdate_param = NULL, entityName, _0, _1; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&entityName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_BOOL(dynamicUpdate) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &dynamicUpdate_param); - dynamicUpdate = zephir_get_boolval(dynamicUpdate_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("fetchMode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "fetch", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Result_PdoResult, getInternalResult) +{ + zval *this_ptr = getThis(); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&_0); - ZVAL_BOOL(&_0, dynamicUpdate); - zephir_update_property_array(this_ptr, SL("dynamicUpdate"), &entityName, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, dynamicUpdate); - zephir_update_property_array(this_ptr, SL("keepSnapshots"), &entityName, &_1); - ZEPHIR_MM_RESTORE(); + + + RETURN_MEMBER(getThis(), "pdoStatement"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnection) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, numRows) { + zend_bool _2$$3; + zval sqlStatement, rowCount, connection, type, pdoStatement, matches, result, row, _0, _1$$3, _3$$4, _4$$5, _5$$6, _6$$6, _7$$6, _8$$7, _9$$7, _10$$7, _11$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval connectionServices; - zval *model, model_sub, *connectionServices_param = NULL, container, service, connection, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&service); + ZVAL_UNDEF(&sqlStatement); + ZVAL_UNDEF(&rowCount); ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&pdoStatement); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&row); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&connectionServices); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(connectionServices) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_11$$7); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &connectionServices_param); - zephir_get_arrval(&connectionServices, connectionServices_param); - - ZEPHIR_CALL_METHOD(&service, this_ptr, "getconnectionservice", NULL, 0, model, &connectionServices); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 2265); - return; - } - ZEPHIR_CALL_METHOD(&_1, &container, "getshared", NULL, 0, &service); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&connection, &_1); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid injected connection service", "phalcon/Mvc/Model/Manager.zep", 2274); - return; + zephir_read_property(&_0, this_ptr, ZEND_STRL("rowCount"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&rowCount, &_0); + if (ZEPHIR_IS_FALSE_IDENTICAL(&rowCount)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&connection, &_1$$3); + ZEPHIR_CALL_METHOD(&type, &connection, "gettype", NULL, 0); + zephir_check_call_status(); + _2$$3 = ZEPHIR_IS_STRING_IDENTICAL(&type, "mysql"); + if (!(_2$$3)) { + _2$$3 = ZEPHIR_IS_STRING_IDENTICAL(&type, "pgsql"); + } + if (_2$$3) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&pdoStatement, &_3$$4); + ZEPHIR_CALL_METHOD(&rowCount, &pdoStatement, "rowcount", NULL, 0); + zephir_check_call_status(); + } + if (ZEPHIR_IS_FALSE_IDENTICAL(&rowCount)) { + zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("sqlStatement"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlStatement, &_4$$5); + if (!(zephir_start_with_str(&sqlStatement, SL("SELECT COUNT(*) ")))) { + ZEPHIR_INIT_VAR(&matches); + ZVAL_NULL(&matches); + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "/^SELECT\\s+(.*)/i"); + ZEPHIR_INIT_VAR(&_6$$6); + ZEPHIR_INIT_VAR(&_7$$6); + ZVAL_STRING(&_7$$6, "/^SELECT\\s+(.*)/i"); + zephir_preg_match(&_6$$6, &_7$$6, &sqlStatement, &matches, 0, 0 , 0 ); + if (zephir_is_true(&_6$$6)) { + zephir_array_fetch_long(&_8$$7, &matches, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Result/PdoResult.zep", 315); + ZEPHIR_INIT_VAR(&_9$$7); + ZEPHIR_CONCAT_SVS(&_9$$7, "SELECT COUNT(*) \"numrows\" FROM (SELECT ", &_8$$7, ")"); + zephir_read_property(&_10$$7, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_11$$7, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &connection, "query", NULL, 0, &_9$$7, &_10$$7, &_11$$7); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&row, &result, "fetch", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&rowCount); + zephir_array_fetch_string(&rowCount, &row, SL("numrows"), PH_NOISY, "phalcon/Db/Result/PdoResult.zep", 321); + } + } else { + ZEPHIR_INIT_NVAR(&rowCount); + ZVAL_LONG(&rowCount, 1); + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("rowCount"), &rowCount); } - RETURN_CCTOR(&connection); + RETURN_CCTOR(&rowCount); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, mergeFindParameters) +static PHP_METHOD(Phalcon_Db_Result_PdoResult, setFetchMode) { - zend_bool _6$$6, _9$$11, _16$$17, _17$$17, _22$$26, _23$$26; - zend_string *_5$$5, *_15$$16; - zend_ulong _4$$5, _14$$16; - zval findParams; + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *findParamsOne = NULL, findParamsOne_sub, *findParamsTwo = NULL, findParamsTwo_sub, key, value, _0$$3, _1$$4, *_2$$5, _3$$5, _7$$9, _8$$9, _10$$14, _11$$14, *_12$$16, _13$$16, _18$$20, _19$$20, _20$$24, _21$$24, _24$$29, _25$$29, _26$$33, _27$$33; + zval *fetchMode_param = NULL, *colNoOrClassNameOrObject = NULL, colNoOrClassNameOrObject_sub, *ctorargs = NULL, ctorargs_sub, __$null, pdoStatement, _0, _2$$3, _3$$3, _4$$5, _5$$5, _6$$7, _7$$7; + zend_long fetchMode, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&findParamsOne_sub); - ZVAL_UNDEF(&findParamsTwo_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_10$$14); - ZVAL_UNDEF(&_11$$14); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_18$$20); - ZVAL_UNDEF(&_19$$20); - ZVAL_UNDEF(&_20$$24); - ZVAL_UNDEF(&_21$$24); - ZVAL_UNDEF(&_24$$29); - ZVAL_UNDEF(&_25$$29); - ZVAL_UNDEF(&_26$$33); - ZVAL_UNDEF(&_27$$33); - ZVAL_UNDEF(&findParams); + ZVAL_UNDEF(&colNoOrClassNameOrObject_sub); + ZVAL_UNDEF(&ctorargs_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&pdoStatement); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(findParamsOne) - Z_PARAM_ZVAL(findParamsTwo) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_LONG(fetchMode) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(colNoOrClassNameOrObject) + Z_PARAM_ZVAL_OR_NULL(ctorargs) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &findParamsOne, &findParamsTwo); - ZEPHIR_SEPARATE_PARAM(findParamsOne); - ZEPHIR_SEPARATE_PARAM(findParamsTwo); + zephir_fetch_params(1, 1, 2, &fetchMode_param, &colNoOrClassNameOrObject, &ctorargs); + fetchMode = zephir_get_intval(fetchMode_param); + if (!colNoOrClassNameOrObject) { + colNoOrClassNameOrObject = &colNoOrClassNameOrObject_sub; + colNoOrClassNameOrObject = &__$null; + } + if (!ctorargs) { + ctorargs = &ctorargs_sub; + ctorargs = &__$null; + } - ZEPHIR_INIT_VAR(&findParams); - array_init(&findParams); - if (Z_TYPE_P(findParamsOne) == IS_STRING) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_update_string(&_0$$3, SL("conditions"), findParamsOne, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(findParamsOne, &_0$$3); - } - if (Z_TYPE_P(findParamsTwo) == IS_STRING) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_update_string(&_1$$4, SL("conditions"), findParamsTwo, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(findParamsTwo, &_1$$4); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdoStatement"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&pdoStatement, &_0); + _1 = fetchMode == 8; + if (!(_1)) { + _1 = fetchMode == 9; } - if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { - zephir_is_iterable(findParamsOne, 0, "phalcon/Mvc/Model/Manager.zep", 2319); - if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsOne), _4$$5, _5$$5, _2$$5) - { - ZEPHIR_INIT_NVAR(&key); - if (_5$$5 != NULL) { - ZVAL_STR_COPY(&key, _5$$5); - } else { - ZVAL_LONG(&key, _4$$5); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2$$5); - _6$$6 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_6$$6)) { - _6$$6 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); - } - if (_6$$6) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } else { - zephir_array_fetch_long(&_7$$9, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2313); - ZEPHIR_INIT_NVAR(&_8$$9); - ZEPHIR_CONCAT_SVSVS(&_8$$9, "(", &_7$$9, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_8$$9, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } - } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, findParamsOne, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, findParamsOne, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&key, findParamsOne, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, findParamsOne, "current", NULL, 0); - zephir_check_call_status(); - _9$$11 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_9$$11)) { - _9$$11 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); - } - if (_9$$11) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } else { - zephir_array_fetch_long(&_10$$14, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2313); - ZEPHIR_INIT_NVAR(&_11$$14); - ZEPHIR_CONCAT_SVSVS(&_11$$14, "(", &_10$$14, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_11$$14, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } - } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, findParamsOne, "next", NULL, 0); - zephir_check_call_status(); - } + if (_1) { + ZVAL_LONG(&_3$$3, fetchMode); + ZEPHIR_CALL_METHOD(&_2$$3, &pdoStatement, "setfetchmode", NULL, 0, &_3$$3, colNoOrClassNameOrObject, ctorargs); + zephir_check_call_status(); + if (!(zephir_is_true(&_2$$3))) { + RETURN_MM_BOOL(0); + } + } else if (fetchMode == 7) { + ZVAL_LONG(&_5$$5, fetchMode); + ZEPHIR_CALL_METHOD(&_4$$5, &pdoStatement, "setfetchmode", NULL, 0, &_5$$5, colNoOrClassNameOrObject); + zephir_check_call_status(); + if (!(zephir_is_true(&_4$$5))) { + RETURN_MM_BOOL(0); + } + } else { + ZVAL_LONG(&_7$$7, fetchMode); + ZEPHIR_CALL_METHOD(&_6$$7, &pdoStatement, "setfetchmode", NULL, 0, &_7$$7); + zephir_check_call_status(); + if (!(zephir_is_true(&_6$$7))) { + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); } - if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { - zephir_is_iterable(findParamsTwo, 0, "phalcon/Mvc/Model/Manager.zep", 2344); - if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsTwo), _14$$16, _15$$16, _12$$16) - { - ZEPHIR_INIT_NVAR(&key); - if (_15$$16 != NULL) { - ZVAL_STR_COPY(&key, _15$$16); - } else { - ZVAL_LONG(&key, _14$$16); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _12$$16); - _16$$17 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_16$$17)) { - _16$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); - } - _17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind"); - if (!(_17$$17)) { - _17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes"); - } - if (_16$$17) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } else { - zephir_array_fetch_long(&_18$$20, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2327); - ZEPHIR_INIT_NVAR(&_19$$20); - ZEPHIR_CONCAT_SVSVS(&_19$$20, "(", &_18$$20, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_19$$20, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } - } else if (_17$$17) { - if (Z_TYPE_P(&value) == IS_ARRAY) { - if (!(zephir_array_isset(&findParams, &key))) { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_20$$24); - zephir_array_fetch(&_21$$24, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2335); - zephir_fast_array_merge(&_20$$24, &_21$$24, &value); - zephir_array_update_zval(&findParams, &key, &_20$$24, PH_COPY | PH_SEPARATE); - } - } - } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_13$$16, findParamsTwo, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_13$$16)) { - break; - } - ZEPHIR_CALL_METHOD(&key, findParamsTwo, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, findParamsTwo, "current", NULL, 0); - zephir_check_call_status(); - _22$$26 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_22$$26)) { - _22$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); - } - _23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind"); - if (!(_23$$26)) { - _23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes"); - } - if (_22$$26) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } else { - zephir_array_fetch_long(&_24$$29, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2327); - ZEPHIR_INIT_NVAR(&_25$$29); - ZEPHIR_CONCAT_SVSVS(&_25$$29, "(", &_24$$29, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_25$$29, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } - } else if (_23$$26) { - if (Z_TYPE_P(&value) == IS_ARRAY) { - if (!(zephir_array_isset(&findParams, &key))) { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_26$$33); - zephir_array_fetch(&_27$$33, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2335); - zephir_fast_array_merge(&_26$$33, &_27$$33, &value); - zephir_array_update_zval(&findParams, &key, &_26$$33, PH_COPY | PH_SEPARATE); - } - } - } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } - RETURN_CTOR(&findParams); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, checkHasRelationship) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3; - zval collection, modelName, modelRelation, keyRelation; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(collection) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &collection_param, &modelName_param, &modelRelation_param); - zephir_get_strval(&collection, collection_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - - - ZEPHIR_INIT_VAR(&entityName); - zephir_fast_strtolower(&entityName, &modelName); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelRelation); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0); - zephir_get_strval(&keyRelation, &_1); - zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_2, &entityName))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&_3); - zephir_read_property_zval(&_3, this_ptr, &collection, PH_NOISY_CC); - RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation)); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, fetchMode); + zephir_update_property_zval(this_ptr, ZEND_STRL("fetchMode"), &_0); + RETURN_MM_BOOL(1); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Manager(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Db_Result_PdoResult(zend_class_entry *class_type) { - zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _18, _20, _22, _24, _26, _28, _30, _32, _34, _36, _38, _40, _42, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11, _19$$12, _21$$13, _23$$14, _25$$15, _27$$16, _29$$17, _31$$18, _33$$19, _35$$20, _37$$21, _39$$22, _41$$23, _43$$24; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_22); - ZVAL_UNDEF(&_24); - ZVAL_UNDEF(&_26); - ZVAL_UNDEF(&_28); - ZVAL_UNDEF(&_30); - ZVAL_UNDEF(&_32); - ZVAL_UNDEF(&_34); - ZVAL_UNDEF(&_36); - ZVAL_UNDEF(&_38); - ZVAL_UNDEF(&_40); - ZVAL_UNDEF(&_42); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_17$$11); - ZVAL_UNDEF(&_19$$12); - ZVAL_UNDEF(&_21$$13); - ZVAL_UNDEF(&_23$$14); - ZVAL_UNDEF(&_25$$15); - ZVAL_UNDEF(&_27$$16); - ZVAL_UNDEF(&_29$$17); - ZVAL_UNDEF(&_31$$18); - ZVAL_UNDEF(&_33$$19); - ZVAL_UNDEF(&_35$$20); - ZVAL_UNDEF(&_37$$21); - ZVAL_UNDEF(&_39$$22); - ZVAL_UNDEF(&_41$$23); - ZVAL_UNDEF(&_43$$24); ZEPHIR_MM_GROW(); @@ -70478,137 +65179,17 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Manager(zend_class_entry * { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("reusable"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("writeConnectionServices"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("schemas"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sources"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("readConnectionServices"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelVisibility"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keepSnapshots"), &_13$$9); - } - zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_14) == IS_NULL) { - ZEPHIR_INIT_VAR(&_15$$10); - array_init(&_15$$10); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("initialized"), &_15$$10); - } - zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_16) == IS_NULL) { - ZEPHIR_INIT_VAR(&_17$$11); - array_init(&_17$$11); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThroughSingle"), &_17$$11); - } - zephir_read_property_ex(&_18, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_18) == IS_NULL) { - ZEPHIR_INIT_VAR(&_19$$12); - array_init(&_19$$12); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThrough"), &_19$$12); - } - zephir_read_property_ex(&_20, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_20) == IS_NULL) { - ZEPHIR_INIT_VAR(&_21$$13); - array_init(&_21$$13); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneSingle"), &_21$$13); - } - zephir_read_property_ex(&_22, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_22) == IS_NULL) { - ZEPHIR_INIT_VAR(&_23$$14); - array_init(&_23$$14); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOne"), &_23$$14); - } - zephir_read_property_ex(&_24, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_24) == IS_NULL) { - ZEPHIR_INIT_VAR(&_25$$15); - array_init(&_25$$15); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToManySingle"), &_25$$15); - } - zephir_read_property_ex(&_26, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_26) == IS_NULL) { - ZEPHIR_INIT_VAR(&_27$$16); - array_init(&_27$$16); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToMany"), &_27$$16); - } - zephir_read_property_ex(&_28, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_28) == IS_NULL) { - ZEPHIR_INIT_VAR(&_29$$17); - array_init(&_29$$17); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManySingle"), &_29$$17); - } - zephir_read_property_ex(&_30, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_30) == IS_NULL) { - ZEPHIR_INIT_VAR(&_31$$18); - array_init(&_31$$18); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasMany"), &_31$$18); - } - zephir_read_property_ex(&_32, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_32) == IS_NULL) { - ZEPHIR_INIT_VAR(&_33$$19); - array_init(&_33$$19); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dynamicUpdate"), &_33$$19); - } - zephir_read_property_ex(&_34, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_34) == IS_NULL) { - ZEPHIR_INIT_VAR(&_35$$20); - array_init(&_35$$20); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("customEventsManager"), &_35$$20); - } - zephir_read_property_ex(&_36, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_36) == IS_NULL) { - ZEPHIR_INIT_VAR(&_37$$21); - array_init(&_37$$21); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsToSingle"), &_37$$21); - } - zephir_read_property_ex(&_38, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_38) == IS_NULL) { - ZEPHIR_INIT_VAR(&_39$$22); - array_init(&_39$$22); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsTo"), &_39$$22); - } - zephir_read_property_ex(&_40, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_40) == IS_NULL) { - ZEPHIR_INIT_VAR(&_41$$23); - array_init(&_41$$23); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("behaviors"), &_41$$23); - } - zephir_read_property_ex(&_42, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_42) == IS_NULL) { - ZEPHIR_INIT_VAR(&_43$$24); - array_init(&_43$$24); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("aliases"), &_43$$24); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -70625,10092 +65206,9520 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Manager(zend_class_entry * -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ManagerInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ManagerInterface, phalcon, mvc_model_managerinterface, phalcon_mvc_model_managerinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBehavior); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBelongsTo); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOne); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOneThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasManyToMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createBuilder); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, executeQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsTo); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsToRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBuilder); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyToMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOne); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneAndHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastInitialized); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSchema); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSource); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationByAlias); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelations); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationsBetween); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasBelongsTo); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasOne); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasOneThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasManyToMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, load); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, initialize); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isInitialized); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isKeepingSnapshots); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isUsingDynamicUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isVisibleModelProperty); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, keepSnapshots); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, missingMethod); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, notifyEvent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSchema); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSource); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, useDynamicUpdate); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData) +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_AbstractAdapter) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, MetaData, phalcon, mvc_model_metadata, phalcon_mvc_model_metadata_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("adapter"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("columnMap"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("metaData"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("strategy"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_metadata_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_MetaData; - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_ATTRIBUTES"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_INSERT"), 10); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_UPDATE"), 11); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_COLUMN_MAP"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_AT"), 6); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_IN"), 7); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES"), 4); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_BIND"), 9); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_NUMERIC"), 5); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DEFAULT_VALUES"), 12); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_EMPTY_STRING_VALUES"), 13); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_IDENTITY_COLUMN"), 8); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NON_PRIMARY_KEY"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NOT_NULL"), 3); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_PRIMARY_KEY"), 1); + ZEPHIR_REGISTER_CLASS(Phalcon\\Db\\Adapter, AbstractAdapter, phalcon, db_adapter_abstractadapter, phalcon_db_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_REVERSE_COLUMN_MAP"), 1); + zend_declare_property_long(phalcon_db_adapter_abstractadapter_ce, SL("connectionConsecutive"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("connectionId"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("descriptor"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("dialect"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("dialectType"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("realSqlStatement"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("sqlBindTypes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("sqlStatement"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("sqlVariables"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_db_adapter_abstractadapter_ce, SL("transactionLevel"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_db_adapter_abstractadapter_ce, SL("transactionsWithSavepoints"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_abstractadapter_ce, SL("type"), ZEND_ACC_PROTECTED); + phalcon_db_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Db_Adapter_AbstractAdapter; - zend_class_implements(phalcon_mvc_model_metadata_ce, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_mvc_model_metadata_ce, 1, phalcon_mvc_model_metadatainterface_ce); + zend_class_implements(phalcon_db_adapter_abstractadapter_ce, 1, phalcon_db_adapter_adapterinterface_ce); + zend_class_implements(phalcon_db_adapter_abstractadapter_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAdapter) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "adapter"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *descriptor_param = NULL, dialectClass, connectionId, _0, _1$$3, _2$$4; + zval descriptor; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&descriptor); + ZVAL_UNDEF(&dialectClass); + ZVAL_UNDEF(&connectionId); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(descriptor) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &descriptor_param); + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 110); - return; + ZEPHIR_OBS_VAR(&connectionId); + zephir_read_static_property_ce(&connectionId, phalcon_db_adapter_abstractadapter_ce, SL("connectionConsecutive"), PH_NOISY_CC); + zephir_update_property_zval(this_ptr, ZEND_STRL("connectionId"), &connectionId); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, (zephir_get_numberval(&connectionId) + 1)); + zephir_update_static_property_ce(phalcon_db_adapter_abstractadapter_ce, ZEND_STRL("connectionConsecutive"), &_0); + ZEPHIR_OBS_VAR(&dialectClass); + if (!(zephir_array_isset_string_fetch(&dialectClass, &descriptor, SL("dialectClass"), 0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("dialectType"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&dialectClass); + ZEPHIR_CONCAT_SV(&dialectClass, "phalcon\\db\\dialect\\", &_1$$3); } - RETURN_CCTOR(&data); + if (Z_TYPE_P(&dialectClass) == IS_STRING) { + ZEPHIR_INIT_VAR(&_2$$4); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&_2$$4, &dialectClass); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("dialect"), &_2$$4); + } else if (Z_TYPE_P(&dialectClass) == IS_OBJECT) { + zephir_update_property_zval(this_ptr, ZEND_STRL("dialect"), &dialectClass); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("descriptor"), &descriptor); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticCreateAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, addColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZVAL_LONG(&_0, 10); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "addcolumn", NULL, 0, &tableName, &schemaName, column); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 137); - return; - } - RETURN_CCTOR(&data); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticUpdateAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, addForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *reference, reference_sub, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&reference_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(reference, phalcon_db_referenceinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZVAL_LONG(&_0, 11); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "addforeignkey", NULL, 0, &tableName, &schemaName, reference); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 164); - return; - } - RETURN_CCTOR(&data); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getBindTypes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, addIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZVAL_LONG(&_0, 9); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "addindex", NULL, 0, &tableName, &schemaName, index); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 191); - return; - } - RETURN_CCTOR(&data); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMap) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, addPrimaryKey) { - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *index, index_sub, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(index, phalcon_db_indexinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 24, model, &_0); - zephir_check_call_status(); - _1 = Z_TYPE_P(&data) != IS_NULL; - if (_1) { - _1 = Z_TYPE_P(&data) != IS_ARRAY; + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); } - if (UNEXPECTED(_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 215); - return; + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - RETURN_CCTOR(&data); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDefaultValues) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 12); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "addprimarykey", NULL, 0, &tableName, &schemaName, index); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 239); - return; - } - RETURN_CCTOR(&data); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, createSavepoint) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *name_param = NULL, dialect, _0, _1, _2; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&dialect); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } - ZVAL_LONG(&_0, 4); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dialect, &_0); + ZEPHIR_CALL_METHOD(&_1, &dialect, "supportssavepoints", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 263); + if (UNEXPECTED(!zephir_is_true(&_1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter.", "phalcon/Db/Adapter/AbstractAdapter.zep", 231); return; } - RETURN_CCTOR(&data); + ZEPHIR_CALL_METHOD(&_2, &dialect, "createsavepoint", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypesNumeric) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, createTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval definition; + zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, columns, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&columns); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZVAL_LONG(&_0, 5); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 290); + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/Db/Adapter/AbstractAdapter.zep", 247); return; } - RETURN_CCTOR(&data); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDI) -{ - zval container, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Mvc/Model/MetaData.zep", 308); + if (UNEXPECTED(!(zephir_fast_count_int(&columns)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/Db/Adapter/AbstractAdapter.zep", 251); return; } - RETURN_CCTOR(&container); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "createtable", NULL, 0, &tableName, &schemaName, &definition); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getEmptyStringAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, createView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval definition; + zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, _0, _1; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(viewName) + Z_PARAM_ARRAY(definition) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); + } else { + ZEPHIR_INIT_VAR(&viewName); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - ZVAL_LONG(&_0, 13); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 335); + if (UNEXPECTED(!(zephir_array_isset_string(&definition, SL("sql"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/Db/Adapter/AbstractAdapter.zep", 269); return; } - RETURN_CCTOR(&data); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "createview", NULL, 0, &viewName, &definition, &schemaName); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getIdentityField) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, delete) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; + zval placeholders, dataTypes; + zval whereCondition, _0$$3; + zval *table, table_sub, *whereCondition_param = NULL, *placeholders_param = NULL, *dataTypes_param = NULL, sql, escapedTable; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&table_sub); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&escapedTable); + ZVAL_UNDEF(&whereCondition); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&dataTypes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_ZVAL(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(whereCondition) + Z_PARAM_ARRAY(placeholders) + Z_PARAM_ARRAY(dataTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 3, &table, &whereCondition_param, &placeholders_param, &dataTypes_param); + if (!whereCondition_param) { + ZEPHIR_INIT_VAR(&whereCondition); + } else { + zephir_get_strval(&whereCondition, whereCondition_param); + } + if (!placeholders_param) { + ZEPHIR_INIT_VAR(&placeholders); + array_init(&placeholders); + } else { + zephir_get_arrval(&placeholders, placeholders_param); + } + if (!dataTypes_param) { + ZEPHIR_INIT_VAR(&dataTypes); + array_init(&dataTypes); + } else { + zephir_get_arrval(&dataTypes, dataTypes_param); + } - ZVAL_LONG(&_0, 8); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "readmetadataindex", NULL, 23, model, &_0); + ZEPHIR_CALL_METHOD(&escapedTable, this_ptr, "escapeidentifier", NULL, 0, table); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&sql); + ZEPHIR_CONCAT_SV(&sql, "DELETE FROM ", &escapedTable); + if (!(ZEPHIR_IS_EMPTY(&whereCondition))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SV(&_0$$3, " WHERE ", &whereCondition); + zephir_concat_self(&sql, &_0$$3); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &sql, &placeholders, &dataTypes); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNonPrimaryKeyAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, describeIndexes) { + zend_string *_11; + zend_ulong _10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_13 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *table_param = NULL, *schema_param = NULL, indexes, index, keyName, indexObjects, name, indexColumns, columns, _0, _1, _2, _3, *_4, _5, *_8, _9, _6$$3, _7$$6, _12$$9, _14$$10; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&indexes); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&indexObjects); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&indexColumns); + ZVAL_UNDEF(&columns); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_12$$9); + ZVAL_UNDEF(&_14$$10); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + zephir_get_strval(&schema, schema_param); + } - ZVAL_LONG(&_0, 2); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + ZEPHIR_INIT_VAR(&indexes); + array_init(&indexes); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describeindexes", NULL, 0, &table, &schema); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 375); - return; + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); + zephir_check_call_status(); + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 348); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _4) + { + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _4); + zephir_array_fetch_long(&keyName, &index, 2, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 336); + if (!(zephir_array_isset(&indexes, &keyName))) { + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + } else { + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch(&columns, &indexes, &keyName, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 341); + } + zephir_array_fetch_long(&_6$$3, &index, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 344); + zephir_array_append(&columns, &_6$$3, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 344); + zephir_array_update_zval(&indexes, &keyName, &columns, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&index, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&keyName); + zephir_array_fetch_long(&keyName, &index, 2, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 336); + if (!(zephir_array_isset(&indexes, &keyName))) { + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + } else { + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch(&columns, &indexes, &keyName, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 341); + } + zephir_array_fetch_long(&_7$$6, &index, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 344); + zephir_array_append(&columns, &_7$$6, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 344); + zephir_array_update_zval(&indexes, &keyName, &columns, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&data); + ZEPHIR_INIT_NVAR(&index); + ZEPHIR_INIT_VAR(&indexObjects); + array_init(&indexObjects); + zephir_is_iterable(&indexes, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 357); + if (Z_TYPE_P(&indexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&indexes), _10, _11, _8) + { + ZEPHIR_INIT_NVAR(&name); + if (_11 != NULL) { + ZVAL_STR_COPY(&name, _11); + } else { + ZVAL_LONG(&name, _10); + } + ZEPHIR_INIT_NVAR(&indexColumns); + ZVAL_COPY(&indexColumns, _8); + ZEPHIR_INIT_NVAR(&_12$$9); + object_init_ex(&_12$$9, phalcon_db_index_ce); + ZEPHIR_CALL_METHOD(NULL, &_12$$9, "__construct", &_13, 33, &name, &indexColumns); + zephir_check_call_status(); + zephir_array_update_zval(&indexObjects, &name, &_12$$9, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &indexes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9, &indexes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &indexes, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexColumns, &indexes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$10); + object_init_ex(&_14$$10, phalcon_db_index_ce); + ZEPHIR_CALL_METHOD(NULL, &_14$$10, "__construct", &_13, 33, &name, &indexColumns); + zephir_check_call_status(); + zephir_array_update_zval(&indexObjects, &name, &_14$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &indexes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&indexColumns); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&indexObjects); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNotNullAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, describeReferences) { + zval _12$$3, _19$$6, _25$$9, _29$$10; + zend_string *_23; + zend_ulong _22; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_27 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *table_param = NULL, *schema_param = NULL, references, reference, arrayReference, constraintName, referenceObjects, name, referencedSchema, referencedTable, columns, referencedColumns, _0, _1, _2, _3, *_4, _5, *_20, _21, _6$$5, _7$$5, _8$$5, _9$$5, _10$$3, _11$$3, _13$$8, _14$$8, _15$$8, _16$$8, _17$$6, _18$$6, _24$$9, _26$$9, _28$$10, _30$$10; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&arrayReference); + ZVAL_UNDEF(&constraintName); + ZVAL_UNDEF(&referenceObjects); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&referencedSchema); + ZVAL_UNDEF(&referencedTable); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&referencedColumns); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_21); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_13$$8); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$6); + ZVAL_UNDEF(&_18$$6); + ZVAL_UNDEF(&_24$$9); + ZVAL_UNDEF(&_26$$9); + ZVAL_UNDEF(&_28$$10); + ZVAL_UNDEF(&_30$$10); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_19$$6); + ZVAL_UNDEF(&_25$$9); + ZVAL_UNDEF(&_29$$10); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); + } + } - ZVAL_LONG(&_0, 3); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + ZEPHIR_INIT_VAR(&references); + array_init(&references); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describereferences", NULL, 0, &table, &schema); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 399); - return; + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); + zephir_check_call_status(); + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 403); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _4) + { + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _4); + zephir_array_fetch_long(&constraintName, &reference, 2, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 378); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_long(&referencedSchema, &reference, 3, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 381); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 4, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 382); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); + } else { + zephir_array_fetch(&_6$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 386); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_6$$5, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 386); + zephir_array_fetch(&_7$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 387); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_7$$5, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 387); + zephir_array_fetch(&_8$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 388); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_8$$5, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 388); + zephir_array_fetch(&_9$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 389); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_9$$5, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 389); + } + zephir_array_fetch_long(&_10$$3, &reference, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 392); + zephir_array_append(&columns, &_10$$3, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 392); + zephir_array_fetch_long(&_11$$3, &reference, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 393); + zephir_array_append(&referencedColumns, &_11$$3, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 393); + ZEPHIR_INIT_NVAR(&_12$$3); + zephir_create_array(&_12$$3, 4, 0); + zephir_array_update_string(&_12$$3, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_12$$3, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_12$$3, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_12$$3, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_12$$3, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&reference, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&constraintName); + zephir_array_fetch_long(&constraintName, &reference, 2, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 378); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_long(&referencedSchema, &reference, 3, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 381); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 4, PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 382); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); + } else { + zephir_array_fetch(&_13$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 386); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_13$$8, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 386); + zephir_array_fetch(&_14$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 387); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_14$$8, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 387); + zephir_array_fetch(&_15$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 388); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_15$$8, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 388); + zephir_array_fetch(&_16$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 389); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_16$$8, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 389); + } + zephir_array_fetch_long(&_17$$6, &reference, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 392); + zephir_array_append(&columns, &_17$$6, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 392); + zephir_array_fetch_long(&_18$$6, &reference, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 393); + zephir_array_append(&referencedColumns, &_18$$6, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 393); + ZEPHIR_INIT_NVAR(&_19$$6); + zephir_create_array(&_19$$6, 4, 0); + zephir_array_update_string(&_19$$6, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_19$$6, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_19$$6, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_19$$6, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_19$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&data); + ZEPHIR_INIT_NVAR(&reference); + ZEPHIR_INIT_VAR(&referenceObjects); + array_init(&referenceObjects); + zephir_is_iterable(&references, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 417); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&references), _22, _23, _20) + { + ZEPHIR_INIT_NVAR(&name); + if (_23 != NULL) { + ZVAL_STR_COPY(&name, _23); + } else { + ZVAL_LONG(&name, _22); + } + ZEPHIR_INIT_NVAR(&arrayReference); + ZVAL_COPY(&arrayReference, _20); + ZEPHIR_INIT_NVAR(&_24$$9); + object_init_ex(&_24$$9, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_25$$9); + zephir_create_array(&_25$$9, 4, 0); + ZEPHIR_OBS_NVAR(&_26$$9); + zephir_array_fetch_string(&_26$$9, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 409); + zephir_array_update_string(&_25$$9, SL("referencedSchema"), &_26$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_26$$9); + zephir_array_fetch_string(&_26$$9, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 410); + zephir_array_update_string(&_25$$9, SL("referencedTable"), &_26$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_26$$9); + zephir_array_fetch_string(&_26$$9, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 411); + zephir_array_update_string(&_25$$9, SL("columns"), &_26$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_26$$9); + zephir_array_fetch_string(&_26$$9, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 413); + zephir_array_update_string(&_25$$9, SL("referencedColumns"), &_26$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_24$$9, "__construct", &_27, 34, &name, &_25$$9); + zephir_check_call_status(); + zephir_array_update_zval(&referenceObjects, &name, &_24$$9, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_21, &references, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_21)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &references, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&arrayReference, &references, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_28$$10); + object_init_ex(&_28$$10, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_29$$10); + zephir_create_array(&_29$$10, 4, 0); + ZEPHIR_OBS_NVAR(&_30$$10); + zephir_array_fetch_string(&_30$$10, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 409); + zephir_array_update_string(&_29$$10, SL("referencedSchema"), &_30$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$10); + zephir_array_fetch_string(&_30$$10, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 410); + zephir_array_update_string(&_29$$10, SL("referencedTable"), &_30$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$10); + zephir_array_fetch_string(&_30$$10, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 411); + zephir_array_update_string(&_29$$10, SL("columns"), &_30$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$10); + zephir_array_fetch_string(&_30$$10, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/AbstractAdapter.zep", 413); + zephir_array_update_string(&_29$$10, SL("referencedColumns"), &_30$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_28$$10, "__construct", &_27, 34, &name, &_29$$10); + zephir_check_call_status(); + zephir_array_update_zval(&referenceObjects, &name, &_28$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&arrayReference); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&referenceObjects); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getPrimaryKeyAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, dropColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL, _0, _1; + zval tableName, schemaName, columnName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&columnName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(columnName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + zephir_get_strval(&columnName, columnName_param); - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 23, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "dropcolumn", NULL, 0, &tableName, &schemaName, &columnName); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 423); - return; - } - RETURN_CCTOR(&data); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getReverseColumnMap) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, dropForeignKey) { - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL, _0, _1; + zval tableName, schemaName, referenceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&referenceName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_STR(referenceName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + if (UNEXPECTED(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceName_param) == IS_STRING)) { + zephir_get_strval(&referenceName, referenceName_param); + } else { + ZEPHIR_INIT_VAR(&referenceName); + } - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 24, model, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "dropforeignkey", NULL, 0, &tableName, &schemaName, &referenceName); zephir_check_call_status(); - _1 = Z_TYPE_P(&data) != IS_NULL; - if (_1) { - _1 = Z_TYPE_P(&data) != IS_ARRAY; - } - if (UNEXPECTED(_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 450); - return; - } - RETURN_CCTOR(&data); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getStrategy) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, dropIndex) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, *indexName, indexName_sub, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&indexName_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_ZVAL(indexName) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("strategy"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_metadata_strategy_introspection_ce); - if (zephir_has_constructor(&_1$$3)) { - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); - zephir_check_call_status(); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("strategy"), &_1$$3); - } - RETURN_MM_MEMBER(getThis(), "strategy"); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "dropindex", NULL, 0, &tableName, &schemaName, indexName); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, hasAttribute) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, dropPrimaryKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attribute; - zval *model, model_sub, *attribute_param = NULL, columnMap, _0, _1; + zval *tableName_param = NULL, *schemaName_param = NULL, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attribute); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(attribute) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &attribute_param); - zephir_get_strval(&attribute, attribute_param); + zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZEPHIR_CALL_METHOD(&columnMap, this_ptr, "getreversecolumnmap", NULL, 0, model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "dropprimarykey", NULL, 0, &tableName, &schemaName); zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - RETURN_MM_BOOL(zephir_array_isset(&columnMap, &attribute)); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "readmetadata", NULL, 25, model); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); zephir_check_call_status(); - zephir_array_fetch_long(&_1, &_0, 4, PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 490); - RETURN_MM_BOOL(zephir_array_isset(&_1, &attribute)); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, isEmpty) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, dropTable) { - zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool ifExists; + zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, _0, _1, _2; + zval tableName, schemaName; zval *this_ptr = getThis(); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(tableName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + } + if (!ifExists_param) { + ifExists = 1; + } else { + ifExists = zephir_get_boolval(ifExists_param); + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_fast_count_int(&_0) == 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + if (ifExists) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_CALL_METHOD(&_1, &_0, "droptable", NULL, 0, &tableName, &schemaName, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, read) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, dropView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0; - zval key; + zend_bool ifExists; + zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, _0, _1, _2; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(viewName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) + Z_PARAM_BOOL(ifExists) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&viewName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + } + if (!ifExists_param) { + ifExists = 1; + } else { + ifExists = zephir_get_boolval(ifExists_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &key); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + if (ifExists) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_CALL_METHOD(&_1, &_0, "dropview", NULL, 0, &viewName, &schemaName, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMap) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, escapeIdentifier) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, keyName, _0$$4, _1$$4; + zval *identifier, identifier_sub, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&keyName); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&identifier_sub); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(identifier) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &identifier); - if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { - RETURN_MM_NULL(); + if (Z_TYPE_P(identifier) == IS_ARRAY) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_long(&_2$$3, identifier, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 522); + ZEPHIR_CALL_METHOD(&_1$$3, &_0$$3, "escape", NULL, 0, &_2$$3); + zephir_check_call_status(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_long(&_5$$3, identifier, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 522); + ZEPHIR_CALL_METHOD(&_4$$3, &_3$$3, "escape", NULL, 0, &_5$$3); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &_1$$3, ".", &_4$$3); + RETURN_MM(); } - ZEPHIR_CALL_METHOD(&keyName, this_ptr, "getcolumnmapuniquekey", NULL, 26, model); + zephir_read_property(&_6, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_6, "escape", NULL, 0, identifier); zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&keyName) != IS_NULL)) { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$4, &_0$$4, &keyName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 535); - RETURN_CTOR(&_1$$4); - } - RETURN_MM_NULL(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, fetchAll) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long index, ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *index_param = NULL, keyName, _0$$4, _1$$4, _2$$4; + zval bindParams, bindTypes; + zend_long fetchMode, ZEPHIR_LAST_CALL_STATUS; + zval *sqlQuery_param = NULL, *fetchMode_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, result, _1, _0$$4; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_LONG(index) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(sqlQuery) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(fetchMode) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &index_param); - index = zephir_get_intval(index_param); + zephir_fetch_params(1, 1, 3, &sqlQuery_param, &fetchMode_param, &bindParams_param, &bindTypes_param); + zephir_get_strval(&sqlQuery, sqlQuery_param); + if (!fetchMode_param) { + fetchMode = 2; + } else { + fetchMode = zephir_get_intval(fetchMode_param); + } + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); + } + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + zephir_get_arrval(&bindTypes, bindTypes_param); + } - if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&keyName, this_ptr, "getcolumnmapuniquekey", NULL, 26, model); + ZEPHIR_CALL_METHOD(&result, this_ptr, "query", NULL, 0, &sqlQuery, &bindParams, &bindTypes); zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&keyName) != IS_NULL)) { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$4, &_0$$4, &keyName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 561); - zephir_array_fetch_long(&_2$$4, &_1$$4, index, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 561); - RETURN_CTOR(&_2$$4); + if (Z_TYPE_P(&result) != IS_OBJECT) { + array_init(return_value); + RETURN_MM(); } - RETURN_MM_NULL(); + if (UNEXPECTED(fetchMode == 7)) { + ZVAL_LONG(&_0$$4, 7); + ZEPHIR_RETURN_CALL_METHOD(&result, "fetchall", NULL, 0, &_0$$4); + zephir_check_call_status(); + RETURN_MM(); + } + ZVAL_LONG(&_1, fetchMode); + ZEPHIR_CALL_METHOD(NULL, &result, "setfetchmode", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&result, "fetchall", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaData) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, fetchColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, key, _0$$3, _1$$3; + zval placeholders; + zval *sqlQuery_param = NULL, *placeholders_param = NULL, *column = NULL, column_sub, row, columnValue, _0; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&columnValue); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&placeholders); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(sqlQuery) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(placeholders) + Z_PARAM_ZVAL(column) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 2, &sqlQuery_param, &placeholders_param, &column); + zephir_get_strval(&sqlQuery, sqlQuery_param); + if (!placeholders_param) { + ZEPHIR_INIT_VAR(&placeholders); + array_init(&placeholders); + } else { + zephir_get_arrval(&placeholders, placeholders_param); + } + if (!column) { + column = &column_sub; + ZEPHIR_INIT_VAR(column); + ZVAL_LONG(column, 0); + } - ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 27, model); + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_METHOD(&row, this_ptr, "fetchone", NULL, 0, &sqlQuery, &_0, &placeholders); zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$3, &_0$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 582); - RETURN_CTOR(&_1$$3); + if (!(zephir_array_isset_fetch(&columnValue, &row, column, 1))) { + RETURN_MM_BOOL(0); } - RETURN_MM_NULL(); + RETURN_CTOR(&columnValue); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, fetchOne) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long index, ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *index_param = NULL, key, _0$$3, _1$$3, _2$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval bindParams, bindTypes; + zval *sqlQuery_param = NULL, *fetchMode = NULL, fetchMode_sub, *bindParams_param = NULL, *bindTypes_param = NULL, result; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&fetchMode_sub); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_LONG(index) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(sqlQuery) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL(fetchMode) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &index_param); - index = zephir_get_intval(index_param); + zephir_fetch_params(1, 1, 3, &sqlQuery_param, &fetchMode, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); + } + if (!fetchMode) { + fetchMode = &fetchMode_sub; + ZEPHIR_INIT_VAR(fetchMode); + ZVAL_LONG(fetchMode, 2); + } + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); + } + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + zephir_get_arrval(&bindTypes, bindTypes_param); + } - ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 27, model); + ZEPHIR_CALL_METHOD(&result, this_ptr, "query", NULL, 0, &sqlQuery, &bindParams, &bindTypes); zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$3, &_0$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 604); - zephir_array_fetch_long(&_2$$3, &_1$$3, index, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 604); - RETURN_CTOR(&_2$$3); + if (Z_TYPE_P(&result) != IS_OBJECT) { + array_init(return_value); + RETURN_MM(); } - RETURN_MM_NULL(); + if (Z_TYPE_P(fetchMode) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &result, "setfetchmode", NULL, 0, fetchMode); + zephir_check_call_status(); + } + ZEPHIR_RETURN_CALL_METHOD(&result, "fetch", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, reset) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, forUpdate) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sqlQuery_param = NULL, _0; + zval sqlQuery; zval *this_ptr = getThis(); + ZVAL_UNDEF(&sqlQuery); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sqlQuery) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); + } - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_1); - ZEPHIR_MM_RESTORE(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "forupdate", NULL, 0, &sqlQuery); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticCreateAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getColumnDefinition) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *model, model_sub, *attributes_param = NULL, _0; + zval *column, column_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); + zephir_fetch_params(1, 1, 0, &column); - ZVAL_LONG(&_0, 10); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 28, model, &_0, &attributes); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticUpdateAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getColumnList) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *model, model_sub, *attributes_param = NULL, _0; + zval *columnList, columnList_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&columnList_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(columnList) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); + zephir_fetch_params(1, 1, 0, &columnList); - ZVAL_LONG(&_0, 11); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 28, model, &_0, &attributes); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getcolumnlist", NULL, 0, columnList); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setEmptyStringAttributes) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getConnectionId) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "connectionId"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getDefaultIdValue) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *model, model_sub, *attributes_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); + object_init_ex(return_value, phalcon_db_rawvalue_ce); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "null"); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 35, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getDefaultValue) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_LONG(&_0, 13); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 28, model, &_0, &attributes); + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + object_init_ex(return_value, phalcon_db_rawvalue_ce); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "DEFAULT"); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 35, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setDI) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getDescriptor) { - zval *container, container_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - zephir_fetch_params_without_memory_grow(1, 0, &container); + RETURN_MEMBER(getThis(), "descriptor"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getDialect) +{ + zval *this_ptr = getThis(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + + RETURN_MEMBER(getThis(), "dialect"); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setStrategy) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getDialectType) { - zval *strategy, strategy_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&strategy_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(strategy, phalcon_mvc_model_metadata_strategy_strategyinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - zephir_fetch_params_without_memory_grow(1, 0, &strategy); + RETURN_MEMBER(getThis(), "dialectType"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getEventsManager) +{ + zval *this_ptr = getThis(); - zephir_update_property_zval(this_ptr, ZEND_STRL("strategy"), strategy); + + RETURN_MEMBER(getThis(), "eventsManager"); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, write) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getNestedTransactionSavepointName) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CONCAT_SV(return_value, "PHALCON_SAVEPOINT_", &_0); + return; +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getRealSQLStatement) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "realSqlStatement"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getSQLBindTypes) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "sqlBindTypes"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getSQLStatement) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "sqlStatement"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getSQLVariables) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "sqlVariables"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, getType) { + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, insert) +{ + zend_bool _6$$4, _11$$12; + zend_string *_5; + zend_ulong _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval data; - zval *key_param = NULL, *data_param = NULL, result, option, _1, _2, _0$$3; - zval key; + zval values; + zval *table_param = NULL, *values_param = NULL, *fields = NULL, fields_sub, *dataTypes = NULL, dataTypes_sub, __$null, bindDataTypes, bindType, escapedTable, escapedFields, field, insertSql, insertValues, joinedValues, placeholders, position, tableName, value, *_2, _3, _16, _17, _0$$3, _9$$8, _10$$9, _14$$16, _15$$17, *_18$$22, _19$$22, _22$$22, _20$$23, _21$$24; + zval table, _1$$3, _7$$5, _8$$7, _12$$13, _13$$15; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_12$$13); + ZVAL_UNDEF(&_13$$15); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&dataTypes_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&bindDataTypes); + ZVAL_UNDEF(&bindType); + ZVAL_UNDEF(&escapedTable); + ZVAL_UNDEF(&escapedFields); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&insertSql); + ZVAL_UNDEF(&insertValues); + ZVAL_UNDEF(&joinedValues); + ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_17); ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_14$$16); + ZVAL_UNDEF(&_15$$17); + ZVAL_UNDEF(&_19$$22); + ZVAL_UNDEF(&_22$$22); + ZVAL_UNDEF(&_20$$23); + ZVAL_UNDEF(&_21$$24); + ZVAL_UNDEF(&values); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(table) + Z_PARAM_ARRAY(values) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(fields) + Z_PARAM_ZVAL_OR_NULL(dataTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &key_param, &data_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 2, &table_param, &values_param, &fields, &dataTypes); + zephir_get_strval(&table, table_param); + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + if (!fields) { + fields = &fields_sub; + fields = &__$null; } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); + if (!dataTypes) { + dataTypes = &dataTypes_sub; + dataTypes = &__$null; } - zephir_get_arrval(&data, data_param); - - /* try_start_1: */ - - ZEPHIR_INIT_VAR(&option); - ZVAL_BOOL(&option, ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save); - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_0$$3, "set", NULL, 0, &key, &data); - zephir_check_call_status_or_jump(try_end_1); - if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwwriteexception", NULL, 29, &option); - zephir_check_call_status_or_jump(try_end_1); + if (UNEXPECTED(!(zephir_fast_count_int(&values)))) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_db_exception_ce); + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVS(&_1$$3, "Unable to insert into ", &table, " without data"); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 32, &_1$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_0$$3, "phalcon/Db/Adapter/AbstractAdapter.zep", 826); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&placeholders); + array_init(&placeholders); + ZEPHIR_INIT_VAR(&insertValues); + array_init(&insertValues); + ZEPHIR_INIT_VAR(&bindDataTypes); + array_init(&bindDataTypes); + zephir_is_iterable(&values, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 864); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&position); + if (_5 != NULL) { + ZVAL_STR_COPY(&position, _5); + } else { + ZVAL_LONG(&position, _4); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + _6$$4 = Z_TYPE_P(&value) == IS_OBJECT; + if (_6$$4) { + _6$$4 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); + } + if (_6$$4) { + zephir_cast_to_string(&_7$$5, &value); + zephir_array_append(&placeholders, &_7$$5, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 839); + } else { + if (Z_TYPE_P(&value) == IS_OBJECT) { + zephir_cast_to_string(&_8$$7, &value); + ZEPHIR_CPY_WRT(&value, &_8$$7); + } + if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_9$$8); + ZVAL_STRING(&_9$$8, "null"); + zephir_array_append(&placeholders, &_9$$8, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 846); + } else { + ZEPHIR_INIT_NVAR(&_10$$9); + ZVAL_STRING(&_10$$9, "?"); + zephir_array_append(&placeholders, &_10$$9, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 848); + zephir_array_append(&insertValues, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 849); + if (Z_TYPE_P(dataTypes) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, dataTypes, &position, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Incomplete number of bind types", "phalcon/Db/Adapter/AbstractAdapter.zep", 855); + return; + } + zephir_array_append(&bindDataTypes, &bindType, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 858); + } + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &values, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&position, &values, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + zephir_check_call_status(); + _11$$12 = Z_TYPE_P(&value) == IS_OBJECT; + if (_11$$12) { + _11$$12 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); + } + if (_11$$12) { + zephir_cast_to_string(&_12$$13, &value); + zephir_array_append(&placeholders, &_12$$13, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 839); + } else { + if (Z_TYPE_P(&value) == IS_OBJECT) { + zephir_cast_to_string(&_13$$15, &value); + ZEPHIR_CPY_WRT(&value, &_13$$15); + } + if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_14$$16); + ZVAL_STRING(&_14$$16, "null"); + zephir_array_append(&placeholders, &_14$$16, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 846); + } else { + ZEPHIR_INIT_NVAR(&_15$$17); + ZVAL_STRING(&_15$$17, "?"); + zephir_array_append(&placeholders, &_15$$17, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 848); + zephir_array_append(&insertValues, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 849); + if (Z_TYPE_P(dataTypes) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, dataTypes, &position, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Incomplete number of bind types", "phalcon/Db/Adapter/AbstractAdapter.zep", 855); + return; + } + zephir_array_append(&bindDataTypes, &bindType, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 858); + } + } + } + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + zephir_check_call_status(); } - - try_end_1: - - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_1); - ZVAL_OBJ(&_1, EG(exception)); - Z_ADDREF_P(&_1); - ZEPHIR_INIT_VAR(&_2); - if (zephir_is_instance_of(&_1, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&_2, &_1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwwriteexception", NULL, 29, &option); + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_VAR(&_16); + ZVAL_STRING(&_16, "."); + ZEPHIR_INIT_VAR(&_17); + zephir_fast_strpos(&_17, &table, &_16, 0 ); + if (ZEPHIR_GT_LONG(&_17, 0)) { + ZEPHIR_INIT_VAR(&tableName); + zephir_fast_explode_str(&tableName, SL("."), &table, LONG_MAX); + } else { + ZEPHIR_CPY_WRT(&tableName, &table); + } + ZEPHIR_CALL_METHOD(&escapedTable, this_ptr, "escapeidentifier", NULL, 0, &tableName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&joinedValues); + zephir_fast_join_str(&joinedValues, SL(", "), &placeholders); + ZEPHIR_INIT_VAR(&insertSql); + if (Z_TYPE_P(fields) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&escapedFields); + array_init(&escapedFields); + zephir_is_iterable(fields, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 884); + if (Z_TYPE_P(fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(fields), _18$$22) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _18$$22); + ZEPHIR_CALL_METHOD(&_20$$23, this_ptr, "escapeidentifier", NULL, 0, &field); + zephir_check_call_status(); + zephir_array_append(&escapedFields, &_20$$23, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 881); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, fields, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_19$$22, fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_19$$22)) { + break; + } + ZEPHIR_CALL_METHOD(&field, fields, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_21$$24, this_ptr, "escapeidentifier", NULL, 0, &field); + zephir_check_call_status(); + zephir_array_append(&escapedFields, &_21$$24, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 881); + ZEPHIR_CALL_METHOD(NULL, fields, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_VAR(&_22$$22); + zephir_fast_join_str(&_22$$22, SL(", "), &escapedFields); + ZEPHIR_CONCAT_SVSVSVS(&insertSql, "INSERT INTO ", &escapedTable, " (", &_22$$22, ") VALUES (", &joinedValues, ")"); + } else { + ZEPHIR_CONCAT_SVSVS(&insertSql, "INSERT INTO ", &escapedTable, " VALUES (", &joinedValues, ")"); } - ZEPHIR_MM_RESTORE(); + if (!(zephir_fast_count_int(&bindDataTypes))) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &insertSql, &insertValues); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &insertSql, &insertValues, &bindDataTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, insertAsDict) { + zend_string *_4; + zend_ulong _3; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long index, ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *index_param = NULL, *data, data_sub, key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *data, data_sub, *dataTypes = NULL, dataTypes_sub, __$null, values, fields, field, value, *_1, _2; + zval table; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&table); ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&dataTypes_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_LONG(index) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(table) Z_PARAM_ZVAL(data) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(dataTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &model, &index_param, &data); - index = zephir_get_intval(index_param); + zephir_fetch_params(1, 2, 1, &table_param, &data, &dataTypes); + zephir_get_strval(&table, table_param); + if (!dataTypes) { + dataTypes = &dataTypes_sub; + dataTypes = &__$null; + } - ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 27, model); - zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { - zephir_update_property_array_multi(this_ptr, SL("metaData"), data, SL("zl"), 2, &key, index); + ZEPHIR_INIT_VAR(&values); + array_init(&values); + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + _0 = Z_TYPE_P(data) != IS_ARRAY; + if (!(_0)) { + _0 = ZEPHIR_IS_EMPTY(data); } - ZEPHIR_MM_RESTORE(); + if (_0) { + RETURN_MM_BOOL(0); + } + zephir_is_iterable(data, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 930); + if (Z_TYPE_P(data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(data), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&field); + if (_4 != NULL) { + ZVAL_STR_COPY(&field, _4); + } else { + ZVAL_LONG(&field, _3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _1); + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 926); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 927); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&field, data, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, data, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 926); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 927); + ZEPHIR_CALL_METHOD(NULL, data, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "insert", NULL, 0, &table, &values, &fields, dataTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initialize) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, isNestedTransactionsWithSavepoints) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *key, key_sub, *table, table_sub, *schema, schema_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&table_sub); - ZVAL_UNDEF(&schema_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(key) - Z_PARAM_ZVAL(table) - Z_PARAM_ZVAL(schema) - ZEND_PARSE_PARAMETERS_END(); -#endif - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initializemetadata", NULL, 30, model, key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initializecolumnmap", NULL, 31, model, key); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "transactionsWithSavepoints"); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initializeMetaData) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, limit) { - zval prefixKey; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *key, key_sub, strategy, metaData, data, modelMetadata, container, _0$$3, _1$$4, _2$$8, _3$$8, _4$$8; + zend_long number, ZEPHIR_LAST_CALL_STATUS; + zval *sqlQuery_param = NULL, *number_param = NULL, _0, _1; + zval sqlQuery; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&strategy); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&modelMetadata); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$8); - ZVAL_UNDEF(&_3$$8); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&prefixKey); + ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(key) + Z_PARAM_STR(sqlQuery) + Z_PARAM_LONG(number) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &key); + zephir_fetch_params(1, 2, 0, &sqlQuery_param, &number_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); + } + number = zephir_get_intval(number_param); - ZEPHIR_INIT_VAR(&strategy); - ZVAL_NULL(&strategy); - if (EXPECTED(Z_TYPE_P(key) != IS_NULL)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_0$$3); - if (0 == zephir_array_isset(&metaData, key)) { - ZEPHIR_INIT_VAR(&_1$$4); - ZEPHIR_CONCAT_SV(&_1$$4, "meta-", key); - zephir_get_strval(&prefixKey, &_1$$4); - ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); - zephir_check_call_status(); - if (Z_TYPE_P(&data) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("metaData"), key, &data); - } else { - if ((zephir_method_exists_ex(model, ZEND_STRL("metadata")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&modelMetadata) != IS_ARRAY)) { - ZEPHIR_INIT_VAR(&_2$$8); - object_init_ex(&_2$$8, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_3$$8); - zephir_get_class(&_3$$8, model, 0); - ZEPHIR_INIT_VAR(&_4$$8); - ZEPHIR_CONCAT_SV(&_4$$8, "Invalid meta-data for model ", &_3$$8); - ZEPHIR_CALL_METHOD(NULL, &_2$$8, "__construct", NULL, 32, &_4$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$8, "phalcon/Mvc/Model/MetaData.zep", 785); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&modelMetadata, &strategy, "getmetadata", NULL, 0, model, &container); - zephir_check_call_status(); - } - zephir_update_property_array(this_ptr, SL("metaData"), key, &modelMetadata); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelMetadata); - zephir_check_call_status(); - } - } - RETURN_MM_BOOL(1); - } - RETURN_MM_BOOL(0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, number); + ZEPHIR_RETURN_CALL_METHOD(&_0, "limit", NULL, 0, &sqlQuery, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initializeColumnMap) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, listTables) { - zval prefixKey; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *key, key_sub, strategy, data, modelColumnMap, container, _0, _1; + zval *schemaName_param = NULL, tables, table, allTables, _0, _1, _2, *_3, _4, _5$$3, _6$$4; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&strategy); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&modelColumnMap); - ZVAL_UNDEF(&container); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&allTables); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&prefixKey); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(key) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &key); - - - if (UNEXPECTED(Z_TYPE_P(key) == IS_NULL)) { - RETURN_MM_BOOL(0); - } - if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - if (1 == zephir_array_isset(&_0, key)) { - RETURN_MM_BOOL(0); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); } - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SV(&_1, "map-", key); - zephir_get_strval(&prefixKey, &_1); - ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); - zephir_check_call_status(); - if (Z_TYPE_P(&data) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("columnMap"), key, &data); - RETURN_MM_BOOL(0); } - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&modelColumnMap, &strategy, "getcolumnmaps", NULL, 0, model, &container); + + + ZEPHIR_INIT_VAR(&allTables); + array_init(&allTables); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "listtables", NULL, 0, &schemaName); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("columnMap"), key, &modelColumnMap); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelColumnMap); + ZVAL_LONG(&_2, 3); + ZEPHIR_CALL_METHOD(&tables, this_ptr, "fetchall", NULL, 0, &_1, &_2); zephir_check_call_status(); - RETURN_MM_BOOL(1); + zephir_is_iterable(&tables, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 977); + if (Z_TYPE_P(&tables) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&tables), _3) + { + ZEPHIR_INIT_NVAR(&table); + ZVAL_COPY(&table, _3); + zephir_array_fetch_long(&_5$$3, &table, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 974); + zephir_array_append(&allTables, &_5$$3, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 974); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &tables, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, &tables, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&table, &tables, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_long(&_6$$4, &table, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 974); + zephir_array_append(&allTables, &_6$$4, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 974); + ZEPHIR_CALL_METHOD(NULL, &tables, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&table); + RETURN_CCTOR(&allTables); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, throwWriteException) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, listViews) { - zval message; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *option, option_sub, _0$$3; + zval *schemaName_param = NULL, tables, table, allTables, _0, _1, _2, *_3, _4, _5$$3, _6$$4; + zval schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&option_sub); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&allTables); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(option) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &option); + zephir_fetch_params(1, 0, 1, &schemaName_param); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + } - ZEPHIR_INIT_VAR(&message); - ZVAL_STRING(&message, "Failed to store metaData to the cache adapter"); - if (zephir_is_true(option)) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 32, &message); - zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/MetaData.zep", 882); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_VAR(&allTables); + array_init(&allTables); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "listviews", NULL, 0, &schemaName); + zephir_check_call_status(); + ZVAL_LONG(&_2, 3); + ZEPHIR_CALL_METHOD(&tables, this_ptr, "fetchall", NULL, 0, &_1, &_2); + zephir_check_call_status(); + zephir_is_iterable(&tables, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 1004); + if (Z_TYPE_P(&tables) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&tables), _3) + { + ZEPHIR_INIT_NVAR(&table); + ZVAL_COPY(&table, _3); + zephir_array_fetch_long(&_5$$3, &table, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 1001); + zephir_array_append(&allTables, &_5$$3, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1001); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &message); + ZEPHIR_CALL_METHOD(NULL, &tables, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, &tables, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&table, &tables, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_long(&_6$$4, &table, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 1001); + zephir_array_append(&allTables, &_6$$4, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1001); + ZEPHIR_CALL_METHOD(NULL, &tables, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&table); + RETURN_CCTOR(&allTables); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getArrVal) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, modifyColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; - zval collection; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, *currentColumn = NULL, currentColumn_sub, __$null, _0, _1; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(¤tColumn_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(currentColumn, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + if (!currentColumn) { + currentColumn = ¤tColumn_sub; + currentColumn = &__$null; } - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 1)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CTOR(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "modifycolumn", NULL, 0, &tableName, &schemaName, column, currentColumn); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getMetaDataUniqueKey) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, releaseSavepoint) { - zval key; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0, _1$$3; + zval *name_param = NULL, dialect, _0, _1, _2, _3; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&dialect); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } - ZEPHIR_INIT_VAR(&key); - zephir_get_class(&key, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - if (0 == zephir_array_isset(&_0, &key)) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "initializemetadata", NULL, 30, model, &key); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_NULL(); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dialect, &_0); + ZEPHIR_CALL_METHOD(&_1, &dialect, "supportssavepoints", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter", "phalcon/Db/Adapter/AbstractAdapter.zep", 1034); + return; } - RETURN_CTOR(&key); + ZEPHIR_CALL_METHOD(&_2, &dialect, "supportsreleasesavepoints", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_2))) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_3, &dialect, "releasesavepoint", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_3); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMapUniqueKey) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, rollbackSavepoint) { - zval key; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0, _1$$3; + zval *name_param = NULL, dialect, _0, _1, _2; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&dialect); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } - ZEPHIR_INIT_VAR(&key); - zephir_get_class(&key, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - if (0 == zephir_array_isset(&_0, &key)) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "initializecolumnmap", NULL, 31, model, &key); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_NULL(); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dialect, &_0); + ZEPHIR_CALL_METHOD(&_1, &dialect, "supportssavepoints", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter", "phalcon/Db/Adapter/AbstractAdapter.zep", 1058); + return; } - RETURN_CTOR(&key); + ZEPHIR_CALL_METHOD(&_2, &dialect, "rollbacksavepoint", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_2); + zephir_check_call_status(); + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_MetaData(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, setEventsManager) { - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("metaData"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("columnMap"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} + ZVAL_UNDEF(&eventsManager_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); -#ifdef HAVE_CONFIG_H -#endif + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); +} +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, setDialect) +{ + zval *dialect, dialect_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&dialect_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(dialect, phalcon_db_dialectinterface_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + zephir_fetch_params_without_memory_grow(1, 0, &dialect); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaDataInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, MetaDataInterface, phalcon, mvc_model_metadatainterface, phalcon_mvc_model_metadatainterface_method_entry); - return SUCCESS; + zephir_update_property_zval(this_ptr, ZEND_STRL("dialect"), dialect); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticCreateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticUpdateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getColumnMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDefaultValues); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypesNumeric); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getEmptyStringAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getIdentityField); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNonPrimaryKeyAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNotNullAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getPrimaryKeyAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getReverseColumnMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getStrategy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, hasAttribute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, isEmpty); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, read); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMapIndex); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaData); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaDataIndex); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticCreateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticUpdateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setEmptyStringAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, writeMetaDataIndex); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setStrategy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, write); - - - - -#ifdef HAVE_CONFIG_H -#endif - +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, setNestedTransactionsWithSavepoints) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *nestedTransactionsWithSavepoints_param = NULL, __$true, __$false, _0, _1, _2; + zend_bool nestedTransactionsWithSavepoints; + zval *this_ptr = getThis(); -#if PHP_VERSION_ID < 70000 -#else + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(nestedTransactionsWithSavepoints) + ZEND_PARSE_PARAMETERS_END(); #endif -static void phalcon_orm_destroy_cache() { - - zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; - - if (phalcon_globals_ptr->orm.parser_cache != NULL) { - zend_hash_destroy(phalcon_globals_ptr->orm.parser_cache); - FREE_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); - phalcon_globals_ptr->orm.parser_cache = NULL; - } - - if (phalcon_globals_ptr->orm.ast_cache != NULL) { - zend_hash_destroy(phalcon_globals_ptr->orm.ast_cache); - FREE_HASHTABLE(phalcon_globals_ptr->orm.ast_cache); - phalcon_globals_ptr->orm.ast_cache = NULL; - } -} - -static void phalcon_orm_singlequotes(zval *return_value, zval *str) { - - int i; - smart_str escaped_str = {0}; - char *marker; - if (Z_TYPE_P(str) != IS_STRING) { - RETURN_ZVAL(str, 1, 0); - } + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &nestedTransactionsWithSavepoints_param); + nestedTransactionsWithSavepoints = zephir_get_boolval(nestedTransactionsWithSavepoints_param); - marker = Z_STRVAL_P(str); - for (i = 0; i < Z_STRLEN_P(str); i++) { - if ((*marker) == '\0') { - break; - } - if ((*marker) == '\'') { - if (i > 0) { - if (*(marker - 1) != '\\') { - smart_str_appendc(&escaped_str, '\''); - } - } else { - smart_str_appendc(&escaped_str, '\''); - } - } - smart_str_appendc(&escaped_str, (*marker)); - marker++; + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(ZEPHIR_GT_LONG(&_0, 0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Nested transaction with savepoints behavior cannot be changed while a transaction is open", "phalcon/Db/Adapter/AbstractAdapter.zep", 1090); + return; } - - smart_str_0(&escaped_str); - -#if PHP_VERSION_ID < 70000 - if (escaped_str.len) { - RETURN_STRINGL(escaped_str.c, escaped_str.len, 0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "supportssavepoints", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_2))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter", "phalcon/Db/Adapter/AbstractAdapter.zep", 1096); + return; } -#else - if (escaped_str.s) { - RETURN_STR(escaped_str.s); + if (nestedTransactionsWithSavepoints) { + zephir_update_property_zval(this_ptr, ZEND_STRL("transactionsWithSavepoints"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("transactionsWithSavepoints"), &__$false); } -#endif - - smart_str_free(&escaped_str); - RETURN_EMPTY_STRING(); + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, sharedLock) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sqlQuery_param = NULL, _0; + zval sqlQuery; + zval *this_ptr = getThis(); - -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sqlQuery) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &sqlQuery_param); + if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { + zephir_get_strval(&sqlQuery, sqlQuery_param); + } else { + ZEPHIR_INIT_VAR(&sqlQuery); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "sharedlock", NULL, 0, &sqlQuery); + zephir_check_call_status(); + RETURN_MM(); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, supportSequences) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Query, phalcon, mvc_model_query, phalcon_mvc_model_query_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("ast"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("bindParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("cache"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("cacheOptions"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("enableImplicitJoins"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("intermediate"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("manager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("metaData"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("models"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("modelsInstances"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_query_ce, SL("nestingLevel"), -1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("phql"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_ce, SL("sharedLock"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliasesModels"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliasesModelsInstances"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlColumnAliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlModelsAliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_ce, SL("uniqueRow"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("transaction"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("internalPhqlCache"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - phalcon_mvc_model_query_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Query; - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_DELETE"), 303); - - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_INSERT"), 306); + zval *this_ptr = getThis(); - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_SELECT"), 309); - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_UPDATE"), 300); - zend_class_implements(phalcon_mvc_model_query_ce, 1, phalcon_mvc_model_queryinterface_ce); - zend_class_implements(phalcon_mvc_model_query_ce, 1, phalcon_di_injectionawareinterface_ce); - return SUCCESS; + RETURN_BOOL(0); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, __construct) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, tableExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *phql_param = NULL, *container = NULL, container_sub, *options_param = NULL, __$true, __$false, __$null, enableImplicitJoins, _0, _1; - zval phql; + zval *tableName_param = NULL, *schemaName_param = NULL, _0, _1, _2, _3, _4; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&container_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&enableImplicitJoins); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tableName) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(phql) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - Z_PARAM_ARRAY(options) + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 3, &phql_param, &container, &options_param); - if (!phql_param) { - ZEPHIR_INIT_VAR(&phql); + zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - zephir_get_strval(&phql, phql_param); + ZEPHIR_INIT_VAR(&tableName); } - if (!container) { - container = &container_sub; - container = &__$null; + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_INIT_VAR(&schemaName); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("phql"), &phql); - if (Z_TYPE_P(container) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, container); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&enableImplicitJoins); - if (zephir_array_isset_string_fetch(&enableImplicitJoins, &options, SL("enable_implicit_joins"), 0)) { - if (ZEPHIR_IS_TRUE(&enableImplicitJoins)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$false); - } - } else { - if (ZEPHIR_GLOBAL(orm).enable_implicit_joins) { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$false); - } - } - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1); - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "tableexists", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchone", NULL, 0, &_2, &_3); + zephir_check_call_status(); + zephir_array_fetch_long(&_4, &_0, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 1132); + RETURN_MM_BOOL(ZEPHIR_GT_LONG(&_4, 0)); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, cache) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, tableOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *cacheOptions_param = NULL; - zval cacheOptions; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, sql, _0, _1, _2, _3; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cacheOptions); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(cacheOptions) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tableName) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &cacheOptions_param); - zephir_get_arrval(&cacheOptions, cacheOptions_param); - - - zephir_update_property_zval(this_ptr, ZEND_STRL("cacheOptions"), &cacheOptions); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, clean) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - + zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); + } else { + zephir_get_strval(&schemaName, schemaName_param); + } - ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_static_property_ce(phalcon_mvc_model_query_ce, ZEND_STRL("internalPhqlCache"), &_0); - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&sql, &_0, "tableoptions", NULL, 0, &tableName, &schemaName); + zephir_check_call_status(); + if (!(zephir_is_true(&sql))) { + array_init(return_value); + RETURN_MM(); + } + ZVAL_LONG(&_2, 2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "fetchall", NULL, 0, &sql, &_2); + zephir_check_call_status(); + zephir_array_fetch_long(&_3, &_1, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 1154); + RETURN_CTOR(&_3); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, execute) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, update) { - zval _5$$8; + zend_bool _5$$3, _11$$12; + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *bindParams_param = NULL, *bindTypes_param = NULL, uniqueRow, cacheOptions, key, cacheService, cache, result, preparedResult, defaultBindParams, mergedParams, defaultBindTypes, mergedTypes, type, lifetime, intermediate, _0, _1$$3, _2$$3, _3$$3, _4$$8, _6$$9, _7$$19, _8$$19; - zval bindParams, bindTypes; + zval *table_param = NULL, *fields, fields_sub, *values, values_sub, *whereCondition = NULL, whereCondition_sub, *dataTypes = NULL, dataTypes_sub, __$null, bindDataTypes, bindType, conditions, escapedField, escapedTable, field, placeholders, position, setClause, tableName, updateSql, updateValues, value, whereBind, whereTypes, *_0, _1, _17, _18, _7$$5, _9$$8, _10$$9, _13$$14, _15$$17, _16$$18; + zval table, _6$$5, _8$$7, _12$$14, _14$$16; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&uniqueRow); - ZVAL_UNDEF(&cacheOptions); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&cacheService); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&preparedResult); - ZVAL_UNDEF(&defaultBindParams); - ZVAL_UNDEF(&mergedParams); - ZVAL_UNDEF(&defaultBindTypes); - ZVAL_UNDEF(&mergedTypes); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&lifetime); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$19); - ZVAL_UNDEF(&_8$$19); - ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_12$$14); + ZVAL_UNDEF(&_14$$16); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&values_sub); + ZVAL_UNDEF(&whereCondition_sub); + ZVAL_UNDEF(&dataTypes_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&bindDataTypes); + ZVAL_UNDEF(&bindType); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&escapedField); + ZVAL_UNDEF(&escapedTable); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&setClause); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&updateSql); + ZVAL_UNDEF(&updateValues); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&whereBind); + ZVAL_UNDEF(&whereTypes); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_18); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&_15$$17); + ZVAL_UNDEF(&_16$$18); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STR(table) + Z_PARAM_ZVAL(fields) + Z_PARAM_ZVAL(values) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + Z_PARAM_ZVAL_OR_NULL(whereCondition) + Z_PARAM_ZVAL_OR_NULL(dataTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, &bindParams_param, &bindTypes_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); + zephir_fetch_params(1, 3, 2, &table_param, &fields, &values, &whereCondition, &dataTypes); + zephir_get_strval(&table, table_param); + if (!whereCondition) { + whereCondition = &whereCondition_sub; + whereCondition = &__$null; } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); + if (!dataTypes) { + dataTypes = &dataTypes_sub; + dataTypes = &__$null; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueRow"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueRow, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cacheOptions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cacheOptions, &_0); - if (Z_TYPE_P(&cacheOptions) != IS_NULL) { - if (UNEXPECTED(Z_TYPE_P(&cacheOptions) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid caching options", "phalcon/Mvc/Model/Query.zep", 274); - return; - } - ZEPHIR_OBS_VAR(&key); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&key, &cacheOptions, SL("key"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A cache key must be provided to identify the cached resultset in the cache backend", "phalcon/Mvc/Model/Query.zep", 283); - return; - } - ZEPHIR_OBS_VAR(&lifetime); - if (!(zephir_array_isset_string_fetch(&lifetime, &cacheOptions, SL("lifetime"), 0))) { - ZEPHIR_INIT_NVAR(&lifetime); - ZVAL_LONG(&lifetime, 3600); - } - ZEPHIR_OBS_VAR(&cacheService); - if (!(zephir_array_isset_string_fetch(&cacheService, &cacheOptions, SL("service"), 0))) { - ZEPHIR_INIT_NVAR(&cacheService); - ZVAL_STRING(&cacheService, "modelsCache"); - } - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&cache, &_1$$3, "getshared", NULL, 0, &cacheService); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Phalcon\\Cache\\CacheInterface"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "is_a", NULL, 86, &cache, &_2$$3); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3))) { - ZEPHIR_INIT_VAR(&_4$$8); - object_init_ex(&_4$$8, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_5$$8); - ZEPHIR_CONCAT_SS(&_5$$8, "Cache service must be an object implementing ", "Phalcon\\Cache\\CacheInterface"); - ZEPHIR_CALL_METHOD(NULL, &_4$$8, "__construct", NULL, 32, &_5$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$8, "phalcon/Mvc/Model/Query.zep", 303); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&result, &cache, "get", NULL, 0, &key); - zephir_check_call_status(); - if (!(ZEPHIR_IS_EMPTY(&result))) { - if (UNEXPECTED(Z_TYPE_P(&result) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cache didn't return a valid resultset", "phalcon/Mvc/Model/Query.zep", 312); + ZEPHIR_INIT_VAR(&placeholders); + array_init(&placeholders); + ZEPHIR_INIT_VAR(&updateValues); + array_init(&updateValues); + ZEPHIR_INIT_VAR(&bindDataTypes); + array_init(&bindDataTypes); + zephir_is_iterable(values, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 1244); + if (Z_TYPE_P(values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(values), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&position); + if (_3 != NULL) { + ZVAL_STR_COPY(&position, _3); + } else { + ZVAL_LONG(&position, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + ZEPHIR_OBS_NVAR(&field); + if (UNEXPECTED(!(zephir_array_isset_fetch(&field, fields, &position, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The number of values in the update is not the same as fields", "phalcon/Db/Adapter/AbstractAdapter.zep", 1209); return; } - ZVAL_BOOL(&_6$$9, 0); - ZEPHIR_CALL_METHOD(NULL, &result, "setisfresh", NULL, 0, &_6$$9); + ZEPHIR_CALL_METHOD(&escapedField, this_ptr, "escapeidentifier", &_4, 0, &field); zephir_check_call_status(); - if (zephir_is_true(&uniqueRow)) { - ZEPHIR_CALL_METHOD(&preparedResult, &result, "getfirst", NULL, 0); - zephir_check_call_status(); + _5$$3 = Z_TYPE_P(&value) == IS_OBJECT; + if (_5$$3) { + _5$$3 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); + } + if (_5$$3) { + zephir_cast_to_string(&_6$$5, &value); + ZEPHIR_INIT_NVAR(&_7$$5); + ZEPHIR_CONCAT_VSV(&_7$$5, &escapedField, " = ", &_6$$5); + zephir_array_append(&placeholders, &_7$$5, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1215); } else { - ZEPHIR_CPY_WRT(&preparedResult, &result); + if (Z_TYPE_P(&value) == IS_OBJECT) { + zephir_cast_to_string(&_8$$7, &value); + ZEPHIR_CPY_WRT(&value, &_8$$7); + } + if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_9$$8); + ZEPHIR_CONCAT_VS(&_9$$8, &escapedField, " = null"); + zephir_array_append(&placeholders, &_9$$8, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1222); + } else { + zephir_array_append(&updateValues, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1224); + if (Z_TYPE_P(dataTypes) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, dataTypes, &position, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Incomplete number of bind types", "phalcon/Db/Adapter/AbstractAdapter.zep", 1230); + return; + } + zephir_array_append(&bindDataTypes, &bindType, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1233); + } + ZEPHIR_INIT_NVAR(&_10$$9); + ZEPHIR_CONCAT_VS(&_10$$9, &escapedField, " = ?"); + zephir_array_append(&placeholders, &_10$$9, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1236); + } } - RETURN_CCTOR(&preparedResult); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &cache); - } - ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&defaultBindParams); - zephir_read_property(&defaultBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&mergedParams); - zephir_add_function(&mergedParams, &defaultBindParams, &bindParams); - ZEPHIR_OBS_VAR(&defaultBindTypes); - zephir_read_property(&defaultBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); - if (Z_TYPE_P(&defaultBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&mergedTypes); - zephir_add_function(&mergedTypes, &defaultBindTypes, &bindTypes); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CPY_WRT(&mergedTypes, &bindTypes); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&type, &_0); - do { - if (ZEPHIR_IS_LONG(&type, 309)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executeselect", NULL, 447, &intermediate, &mergedParams, &mergedTypes); + ZEPHIR_CALL_METHOD(NULL, values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, values, "valid", NULL, 0); zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 306)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executeinsert", NULL, 448, &intermediate, &mergedParams, &mergedTypes); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&position, values, "key", NULL, 0); zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 300)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executeupdate", NULL, 449, &intermediate, &mergedParams, &mergedTypes); + ZEPHIR_CALL_METHOD(&value, values, "current", NULL, 0); zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 303)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executedelete", NULL, 450, &intermediate, &mergedParams, &mergedTypes); + ZEPHIR_OBS_NVAR(&field); + if (UNEXPECTED(!(zephir_array_isset_fetch(&field, fields, &position, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The number of values in the update is not the same as fields", "phalcon/Db/Adapter/AbstractAdapter.zep", 1209); + return; + } + ZEPHIR_CALL_METHOD(&escapedField, this_ptr, "escapeidentifier", &_4, 0, &field); + zephir_check_call_status(); + _11$$12 = Z_TYPE_P(&value) == IS_OBJECT; + if (_11$$12) { + _11$$12 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); + } + if (_11$$12) { + zephir_cast_to_string(&_12$$14, &value); + ZEPHIR_INIT_NVAR(&_13$$14); + ZEPHIR_CONCAT_VSV(&_13$$14, &escapedField, " = ", &_12$$14); + zephir_array_append(&placeholders, &_13$$14, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1215); + } else { + if (Z_TYPE_P(&value) == IS_OBJECT) { + zephir_cast_to_string(&_14$$16, &value); + ZEPHIR_CPY_WRT(&value, &_14$$16); + } + if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_15$$17); + ZEPHIR_CONCAT_VS(&_15$$17, &escapedField, " = null"); + zephir_array_append(&placeholders, &_15$$17, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1222); + } else { + zephir_array_append(&updateValues, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1224); + if (Z_TYPE_P(dataTypes) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, dataTypes, &position, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Incomplete number of bind types", "phalcon/Db/Adapter/AbstractAdapter.zep", 1230); + return; + } + zephir_array_append(&bindDataTypes, &bindType, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1233); + } + ZEPHIR_INIT_NVAR(&_16$$18); + ZEPHIR_CONCAT_VS(&_16$$18, &escapedField, " = ?"); + zephir_array_append(&placeholders, &_16$$18, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1236); + } + } + ZEPHIR_CALL_METHOD(NULL, values, "next", NULL, 0); zephir_check_call_status(); - break; } - ZEPHIR_INIT_VAR(&_7$$19); - object_init_ex(&_7$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_8$$19); - ZEPHIR_CONCAT_SV(&_8$$19, "Unknown statement ", &type); - ZEPHIR_CALL_METHOD(NULL, &_7$$19, "__construct", NULL, 32, &_8$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$19, "phalcon/Mvc/Model/Query.zep", 395); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - if (Z_TYPE_P(&cacheOptions) != IS_NULL) { - if (!ZEPHIR_IS_LONG(&type, 309)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Only PHQL statements that return resultsets can be cached", "phalcon/Mvc/Model/Query.zep", 408); - return; + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_VAR(&_17); + ZVAL_STRING(&_17, "."); + ZEPHIR_INIT_VAR(&_18); + zephir_fast_strpos(&_18, &table, &_17, 0 ); + if (ZEPHIR_GT_LONG(&_18, 0)) { + ZEPHIR_INIT_VAR(&tableName); + zephir_fast_explode_str(&tableName, SL("."), &table, LONG_MAX); + } else { + ZEPHIR_CPY_WRT(&tableName, &table); + } + ZEPHIR_CALL_METHOD(&escapedTable, this_ptr, "escapeidentifier", &_4, 0, &tableName); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&setClause); + zephir_fast_join_str(&setClause, SL(", "), &placeholders); + ZEPHIR_INIT_VAR(&updateSql); + if (Z_TYPE_P(whereCondition) != IS_NULL) { + ZEPHIR_CONCAT_SVSVS(&updateSql, "UPDATE ", &escapedTable, " SET ", &setClause, " WHERE "); + if (Z_TYPE_P(whereCondition) == IS_STRING) { + zephir_concat_self(&updateSql, whereCondition); + } else { + if (UNEXPECTED(Z_TYPE_P(whereCondition) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid WHERE clause conditions", "phalcon/Db/Adapter/AbstractAdapter.zep", 1267); + return; + } + ZEPHIR_OBS_VAR(&conditions); + if (zephir_array_isset_string_fetch(&conditions, whereCondition, SL("conditions"), 0)) { + zephir_concat_self(&updateSql, &conditions); + } + ZEPHIR_OBS_VAR(&whereBind); + if (zephir_array_isset_string_fetch(&whereBind, whereCondition, SL("bind"), 0)) { + zephir_merge_append(&updateValues, &whereBind); + } + ZEPHIR_OBS_VAR(&whereTypes); + if (zephir_array_isset_string_fetch(&whereTypes, whereCondition, SL("bindTypes"), 0)) { + zephir_merge_append(&bindDataTypes, &whereTypes); + } } - ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &key, &result, &lifetime); - zephir_check_call_status(); + } else { + ZEPHIR_CONCAT_SVSV(&updateSql, "UPDATE ", &escapedTable, " SET ", &setClause); } - if (zephir_is_true(&uniqueRow)) { - ZEPHIR_CALL_METHOD(&preparedResult, &result, "getfirst", NULL, 0); + if (!(zephir_fast_count_int(&bindDataTypes))) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &updateSql, &updateValues); zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&preparedResult, &result); + RETURN_MM(); } - RETURN_CCTOR(&preparedResult); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCache) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "cache"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCacheOptions) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "cacheOptions"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &updateSql, &updateValues, &bindDataTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindParams) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, updateAsDict) { + zend_string *_4; + zend_ulong _3; + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *data, data_sub, *whereCondition = NULL, whereCondition_sub, *dataTypes = NULL, dataTypes_sub, __$null, values, fields, field, value, *_1, _2; + zval table; zval *this_ptr = getThis(); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&whereCondition_sub); + ZVAL_UNDEF(&dataTypes_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(table) + Z_PARAM_ZVAL(data) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(whereCondition) + Z_PARAM_ZVAL_OR_NULL(dataTypes) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "bindParams"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindTypes) -{ - zval *this_ptr = getThis(); - + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 2, &table_param, &data, &whereCondition, &dataTypes); + zephir_get_strval(&table, table_param); + if (!whereCondition) { + whereCondition = &whereCondition_sub; + whereCondition = &__$null; + } + if (!dataTypes) { + dataTypes = &dataTypes_sub; + dataTypes = &__$null; + } - RETURN_MEMBER(getThis(), "bindTypes"); + ZEPHIR_INIT_VAR(&values); + array_init(&values); + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + _0 = Z_TYPE_P(data) != IS_ARRAY; + if (!(_0)) { + _0 = ZEPHIR_IS_EMPTY(data); + } + if (_0) { + RETURN_MM_BOOL(0); + } + zephir_is_iterable(data, 0, "phalcon/Db/Adapter/AbstractAdapter.zep", 1340); + if (Z_TYPE_P(data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(data), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&field); + if (_4 != NULL) { + ZVAL_STR_COPY(&field, _4); + } else { + ZVAL_LONG(&field, _3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _1); + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1336); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1337); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&field, data, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, data, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1336); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Db/Adapter/AbstractAdapter.zep", 1337); + ZEPHIR_CALL_METHOD(NULL, data, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "update", NULL, 0, &table, &fields, &values, whereCondition, dataTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getDI) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, useExplicitIdValue) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "container"); + RETURN_BOOL(0); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getIntermediate) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, supportsDefaultValue) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "intermediate"); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleResult) +static PHP_METHOD(Phalcon_Db_Adapter_AbstractAdapter, viewExists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *bindParams_param = NULL, *bindTypes_param = NULL, _0, _1; - zval bindParams, bindTypes; + zval *viewName_param = NULL, *schemaName_param = NULL, _0, _1, _2, _3, _4; + zval viewName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&viewName); + ZVAL_UNDEF(&schemaName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(viewName) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + Z_PARAM_STR_OR_NULL(schemaName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, &bindParams_param, &bindTypes_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); + zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); + if (UNEXPECTED(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(viewName_param) == IS_STRING)) { + zephir_get_strval(&viewName, viewName_param); } else { - zephir_get_arrval(&bindParams, bindParams_param); + ZEPHIR_INIT_VAR(&viewName); } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); + if (!schemaName_param) { + ZEPHIR_INIT_VAR(&schemaName); } else { - zephir_get_arrval(&bindTypes, bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueRow"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "execute", NULL, 0, &bindParams, &bindTypes); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "viewexists", NULL, 0, &viewName, &schemaName); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_1, "getfirst", NULL, 0); + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchone", NULL, 0, &_2, &_3); zephir_check_call_status(); - RETURN_MM(); + zephir_array_fetch_long(&_4, &_0, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/AbstractAdapter.zep", 1373); + RETURN_MM_BOOL(ZEPHIR_GT_LONG(&_4, 0)); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSql) +zend_object *zephir_init_properties_Phalcon_Db_Adapter_AbstractAdapter(zend_class_entry *class_type) { - zval intermediate, _0, _1$$3, _2$$3, _3$$3; + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - - - ZEPHIR_MM_GROW(); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + - ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_LONG(&_0, 309)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_3$$3, 1); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "executeselect", NULL, 447, &intermediate, &_1$$3, &_2$$3, &_3$$3); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("sqlVariables"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlVariables"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("sqlBindTypes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlBindTypes"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("descriptor"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("descriptor"), &_5$$5); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "This type of statement generates multiple SQL statements", "phalcon/Mvc/Model/Query.zep", 514); - return; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getType) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "type"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Model_Query, getUniqueRow) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "uniqueRow"); -} -static PHP_METHOD(Phalcon_Mvc_Model_Query, getTransaction) +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_AdapterInterface) { - zval *this_ptr = getThis(); - - + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db\\Adapter, AdapterInterface, phalcon, db_adapter_adapterinterface, phalcon_db_adapter_adapterinterface_method_entry); - RETURN_MEMBER(getThis(), "transaction"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, parse) -{ - zval intermediate, phql, ast, irPhql, uniqueId, type, _0, _2$$5, _3$$7, _4$$13, _5$$13; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_1 = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&irPhql); - ZVAL_UNDEF(&uniqueId); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$13); - ZVAL_UNDEF(&_5$$13); - - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("intermediate"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&intermediate, &_0); - if (Z_TYPE_P(&intermediate) == IS_ARRAY) { - RETURN_CCTOR(&intermediate); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&phql, &_0); - ZEPHIR_CALL_CE_STATIC(&ast, phalcon_mvc_model_query_lang_ce, "parsephql", &_1, 0, &phql); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&irPhql); - ZVAL_NULL(&irPhql); - ZEPHIR_INIT_VAR(&uniqueId); - ZVAL_NULL(&uniqueId); - if (Z_TYPE_P(&ast) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&uniqueId); - if (zephir_array_isset_string_fetch(&uniqueId, &ast, SL("id"), 0)) { - ZEPHIR_OBS_NVAR(&irPhql); - zephir_read_static_property_ce(&_2$$5, phalcon_mvc_model_query_ce, SL("internalPhqlCache"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&irPhql, &_2$$5, &uniqueId, 0)) { - if (Z_TYPE_P(&irPhql) == IS_ARRAY) { - zephir_array_fetch_string(&_3$$7, &ast, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 579); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_3$$7); - RETURN_CCTOR(&irPhql); - } - } - } - ZEPHIR_OBS_VAR(&type); - if (zephir_array_isset_string_fetch(&type, &ast, SL("type"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("ast"), &ast); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - do { - if (ZEPHIR_IS_LONG(&type, 309)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareselect", NULL, 451); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 306)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareinsert", NULL, 452); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 300)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareupdate", NULL, 453); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 303)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_preparedelete", NULL, 454); - zephir_check_call_status(); - break; - } - ZEPHIR_INIT_VAR(&_4$$13); - object_init_ex(&_4$$13, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_5$$13); - ZEPHIR_CONCAT_SVSV(&_5$$13, "Unknown statement ", &type, ", when preparing: ", &phql); - ZEPHIR_CALL_METHOD(NULL, &_4$$13, "__construct", NULL, 32, &_5$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$13, "phalcon/Mvc/Model/Query.zep", 613); - ZEPHIR_MM_RESTORE(); - return; - } while(0); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, addColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, addIndex); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, addForeignKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, addPrimaryKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, affectedRows); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, begin); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, close); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, commit); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, connect); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, createSavepoint); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, createTable); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, createView); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, describeColumns); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, describeIndexes); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, describeReferences); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, dropColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, dropForeignKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, dropIndex); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, dropPrimaryKey); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, dropTable); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, dropView); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, escapeIdentifier); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, escapeString); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, execute); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, fetchAll); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, fetchColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, fetchOne); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, forUpdate); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getColumnDefinition); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getColumnList); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getConnectionId); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getDescriptor); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getDialect); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getDialectType); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getDefaultIdValue); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getDefaultValue); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getInternalHandler); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getNestedTransactionSavepointName); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getRealSQLStatement); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getSQLStatement); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getSQLBindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getSQLVariables); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, insert); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, insertAsDict); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, isNestedTransactionsWithSavepoints); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, isUnderTransaction); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, lastInsertId); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, limit); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, listTables); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, listViews); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, modifyColumn); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, query); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, releaseSavepoint); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, rollback); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, rollbackSavepoint); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, sharedLock); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, setNestedTransactionsWithSavepoints); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, supportSequences); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, tableExists); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, tableOptions); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, update); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, updateAsDict); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, useExplicitIdValue); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, supportsDefaultValue); +ZEPHIR_DOC_METHOD(Phalcon_Db_Adapter_AdapterInterface, viewExists); - } - } - if (UNEXPECTED(Z_TYPE_P(&irPhql) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted AST", "phalcon/Mvc/Model/Query.zep", 619); - return; - } - if (Z_TYPE_P(&uniqueId) == IS_LONG) { - zephir_update_static_property_array_multi_ce(phalcon_mvc_model_query_ce, SL("internalPhqlCache"), &irPhql, SL("z"), 1, &uniqueId); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediate"), &irPhql); - RETURN_CCTOR(&irPhql); -} -static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindParams) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindParams_param = NULL, *merge_param = NULL, currentBindParams, _0$$3; - zval bindParams; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(&_0$$3); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); - if (!merge_param) { - merge = 0; - } else { - merge = zephir_get_boolval(merge_param); - } - if (merge) { - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_0$$3); - zephir_add_function(&_0$$3, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - RETURN_THIS(); + +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_PdoFactory) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter, PdoFactory, phalcon, db_adapter_pdofactory, phalcon_factory_abstractfactory_ce, phalcon_db_adapter_pdofactory_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindTypes) +static PHP_METHOD(Phalcon_Db_Adapter_PdoFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindTypes_param = NULL, *merge_param = NULL, currentBindTypes, _0$$4; - zval bindTypes; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&services); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); - if (!merge_param) { - merge = 0; + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); } else { - merge = zephir_get_boolval(merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); } - if (UNEXPECTED(merge)) { - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setDI) +static PHP_METHOD(Phalcon_Db_Adapter_PdoFactory, load) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *container, container_sub, manager, metaData, _0; + zval *config = NULL, config_sub, name, options, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&options); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &container); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "modelsManager"); - ZEPHIR_CALL_METHOD(&manager, container, "getshared", NULL, 0, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsManager' is invalid", "phalcon/Mvc/Model/Query.zep", 683); - return; - } - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&metaData, container, "getshared", NULL, 0, &_0); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "adapter"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsMetaData' is invalid", "phalcon/Mvc/Model/Query.zep", 689); - return; + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_OBS_VAR(&name); + zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Db/Adapter/PdoFactory.zep", 50); + zephir_array_unset_string(config, SL("adapter"), PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_support_helper_arr_get_ce); + if (zephir_has_constructor(&_1)) { + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0); + zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("manager"), &manager); - zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); - ZEPHIR_MM_RESTORE(); + + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "options"); + ZEPHIR_CALL_METHOD(&options, &_1, "__invoke", NULL, 158, config, &_3, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setIntermediate) +static PHP_METHOD(Phalcon_Db_Adapter_PdoFactory, newInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *intermediate_param = NULL; - zval intermediate; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, _0; + zval *name_param = NULL, *options_param = NULL, definition; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(intermediate) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &intermediate_param); - ZEPHIR_OBS_COPY_OR_DUP(&intermediate, intermediate_param); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediate"), &intermediate); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setSharedLock) +static PHP_METHOD(Phalcon_Db_Adapter_PdoFactory, getExceptionClass) { - zval *sharedLock_param = NULL, __$true, __$false; - zend_bool sharedLock; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(sharedLock) - ZEND_PARSE_PARAMETERS_END(); -#endif - - zephir_fetch_params_without_memory_grow(0, 1, &sharedLock_param); - if (!sharedLock_param) { - sharedLock = 0; - } else { - sharedLock = zephir_get_boolval(sharedLock_param); - } - - if (sharedLock) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &__$false); - } - RETURN_THISW(); + RETURN_STRING("Phalcon\\Db\\Exception"); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setTransaction) +static PHP_METHOD(Phalcon_Db_Adapter_PdoFactory, getServices) { - zval *transaction, transaction_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&transaction_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); + + + zephir_create_array(return_value, 3, 0); + add_assoc_stringl_ex(return_value, SL("mysql"), SL("Phalcon\\Db\\Adapter\\Pdo\\Mysql")); + add_assoc_stringl_ex(return_value, SL("postgresql"), SL("Phalcon\\Db\\Adapter\\Pdo\\Postgresql")); + add_assoc_stringl_ex(return_value, SL("sqlite"), SL("Phalcon\\Db\\Adapter\\Pdo\\Sqlite")); + return; +} + + + + +#ifdef HAVE_CONFIG_H #endif - zephir_fetch_params_without_memory_grow(1, 0, &transaction); - zephir_update_property_zval(this_ptr, ZEND_STRL("transaction"), transaction); - RETURN_THISW(); + +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_AbstractPdo) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, AbstractPdo, phalcon, db_adapter_pdo_abstractpdo, phalcon_db_adapter_abstractadapter_ce, phalcon_db_adapter_pdo_abstractpdo_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_long(phalcon_db_adapter_pdo_abstractpdo_ce, SL("affectedRows"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_adapter_pdo_abstractpdo_ce, SL("pdo"), ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setType) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, __construct) { - zval *type_param = NULL, _0; - zend_long type; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_0 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *descriptor_param = NULL; + zval descriptor; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&descriptor); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(type) + Z_PARAM_ARRAY(descriptor) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &type_param); - type = zephir_get_intval(type_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &descriptor_param); + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, type); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); - RETURN_THISW(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0, &descriptor); + zephir_check_call_status(); + ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_abstractpdo_ce, getThis(), "__construct", &_0, 0, &descriptor); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setUniqueRow) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, affectedRows) { - zval *uniqueRow_param = NULL, __$true, __$false; - zend_bool uniqueRow; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + + + RETURN_MEMBER(getThis(), "affectedRows"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, begin) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *nesting_param = NULL, eventsManager, savepointName, _0, _3, _6, _7, _1$$3, _2$$4, _8$$6; + zend_bool nesting, _4, _5; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&savepointName); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_8$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(uniqueRow) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(nesting) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &uniqueRow_param); - uniqueRow = zephir_get_boolval(uniqueRow_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &nesting_param); + if (!nesting_param) { + nesting = 1; + } else { + nesting = zephir_get_boolval(nesting_param); + } - if (uniqueRow) { - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueRow"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueRow"), &__$false); + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("transactionLevel"))); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_0, 1)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_1$$3); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "db:beginTransaction"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_2$$4, this_ptr); + zephir_check_call_status(); + } + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_1$$3, "begintransaction", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - RETURN_THISW(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + _4 = ZEPHIR_IS_LONG_IDENTICAL(&_3, 0); + if (!(_4)) { + _4 = !nesting; + } + _5 = _4; + if (!(_5)) { + ZEPHIR_CALL_METHOD(&_6, this_ptr, "isnestedtransactionswithsavepoints", NULL, 0); + zephir_check_call_status(); + _5 = !zephir_is_true(&_6); + } + if (_5) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_7); + ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_8$$6); + ZVAL_STRING(&_8$$6, "db:createSavepoint"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_8$$6, this_ptr, &savepointName); + zephir_check_call_status(); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "createsavepoint", NULL, 0, &savepointName); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeDelete) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, commit) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, models, modelName, model, records, connection, record, _0, _3, _9, _1$$4, _2$$5, _5$$6, _7$$7; - zval intermediate, bindParams, bindTypes; + zval *nesting_param = NULL, eventsManager, savepointName, _0, _1, _4, _7, _9, _2$$4, _3$$5, _8$$6, _10$$8; + zend_bool nesting, _5, _6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&record); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&savepointName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$8); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(nesting) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); + zephir_fetch_params(1, 0, 1, &nesting_param); + if (!nesting_param) { + nesting = 1; + } else { + nesting = zephir_get_boolval(nesting_param); + } - ZEPHIR_OBS_VAR(&models); - zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 757); - if (UNEXPECTED(zephir_array_isset_long(&models, 1))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Delete from several models at the same time is still not supported", "phalcon/Mvc/Model/Query.zep", 762); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_0, 0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "There is no active transaction", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 151); return; } - ZEPHIR_OBS_VAR(&modelName); - zephir_array_fetch_long(&modelName, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 765); - ZEPHIR_OBS_VAR(&model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&model, &_1$$4, "load", NULL, 0, &modelName); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 455, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (!(zephir_fast_count_int(&records))) { - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_2$$5, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_2$$5); + zephir_read_property(&_1, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_1, 1)) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_2$$4); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_3$$5); + ZVAL_STRING(&_3$$5, "db:commitTransaction"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_3$$5, this_ptr); + zephir_check_call_status(); + } + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel"))); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2$$4, "commit", NULL, 0); zephir_check_call_status(); RETURN_MM(); } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &records, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_3))) { - break; - } - ZEPHIR_CALL_METHOD(&record, &records, "current", &_4, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$6, &record, "delete", NULL, 0); + zephir_read_property(&_4, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + _5 = ZEPHIR_IS_LONG_IDENTICAL(&_4, 0); + if (!(_5)) { + _5 = !nesting; + } + _6 = _5; + if (!(_6)) { + ZEPHIR_CALL_METHOD(&_7, this_ptr, "isnestedtransactionswithsavepoints", NULL, 0); zephir_check_call_status(); - if (!(zephir_is_true(&_5$$6))) { - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", &_6, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_7$$7, 0); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_7$$7, &record); - zephir_check_call_status(); - RETURN_MM(); + _6 = !zephir_is_true(&_7); + } + if (_6) { + zephir_read_property(&_8$$6, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GT_LONG(&_8$$6, 0)) { + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel"))); } - ZEPHIR_CALL_METHOD(NULL, &records, "next", &_8, 0); - zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); + zephir_read_property(&_9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_9); + ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_9, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_9); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_10$$8); + ZVAL_STRING(&_10$$8, "db:releaseSavepoint"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_10$$8, this_ptr, &savepointName); + zephir_check_call_status(); + } + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel"))); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "releasesavepoint", NULL, 0, &savepointName); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeInsert) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, close) { - zend_string *_5; - zend_ulong _4; - zend_bool automaticFields = 0, _18$$8, _31$$17; + zval __$null; + zval *this_ptr = getThis(); + + ZVAL_NULL(&__$null); + + + + zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), &__$null); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, connect) +{ + zend_string *_9; + zend_ulong _8; + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_14 = NULL, *_16 = NULL, *_17 = NULL, *_22 = NULL, *_24 = NULL, *_30 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, modelName, manager, connection, metaData, attributes, fields, columnMap, dialect, insertValues, number, value, model, values, exprValue, insertValue, wildcard, fieldName, attributeName, insertModel, _0, _1, *_2, _3, _34, _6$$8, _8$$11, _10$$11, _11$$11, _12$$12, _13$$12, _15$$13, _19$$15, _20$$15, _21$$17, _23$$20, _25$$20, _26$$20, _27$$21, _28$$21, _29$$22, _32$$24, _33$$24; - zval intermediate, bindParams, bindTypes; + zval *descriptor_param = NULL, username, password, dsnAttributes, dsnAttributesCustomRaw, dsnAttributesMap, key, options, persistent, value, _2, _4, _5, *_6, _7, _12, _13, _14, _0$$3, _3$$9, _10$$11, _11$$12; + zval descriptor, dsnParts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&insertValues); - ZVAL_UNDEF(&number); + ZVAL_UNDEF(&descriptor); + ZVAL_UNDEF(&dsnParts); + ZVAL_UNDEF(&username); + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&dsnAttributes); + ZVAL_UNDEF(&dsnAttributesCustomRaw); + ZVAL_UNDEF(&dsnAttributesMap); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&persistent); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&insertValue); - ZVAL_UNDEF(&wildcard); - ZVAL_UNDEF(&fieldName); - ZVAL_UNDEF(&attributeName); - ZVAL_UNDEF(&insertModel); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_34); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_3$$9); ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_13$$12); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_20$$15); - ZVAL_UNDEF(&_21$$17); - ZVAL_UNDEF(&_23$$20); - ZVAL_UNDEF(&_25$$20); - ZVAL_UNDEF(&_26$$20); - ZVAL_UNDEF(&_27$$21); - ZVAL_UNDEF(&_28$$21); - ZVAL_UNDEF(&_29$$22); - ZVAL_UNDEF(&_32$$24); - ZVAL_UNDEF(&_33$$24); + ZVAL_UNDEF(&_11$$12); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(descriptor) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); + zephir_fetch_params(1, 0, 1, &descriptor_param); + if (!descriptor_param) { + ZEPHIR_INIT_VAR(&descriptor); + array_init(&descriptor); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); + } - ZEPHIR_OBS_VAR(&modelName); - zephir_array_fetch_string(&modelName, &intermediate, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 846); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_OBS_VAR(&model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&model, &manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&dsnParts); + array_init(&dsnParts); + if (ZEPHIR_IS_EMPTY(&descriptor)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("descriptor"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&descriptor, &_0$$3); } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_1); - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", NULL, 0, &model); - zephir_check_call_status(); - automaticFields = 0; - ZEPHIR_OBS_VAR(&fields); - if (!(zephir_array_isset_string_fetch(&fields, &intermediate, SL("fields"), 0))) { - automaticFields = 1; - ZEPHIR_CPY_WRT(&fields, &attributes); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &model); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } + ZEPHIR_OBS_VAR(&username); + if (zephir_array_isset_string_fetch(&username, &descriptor, SL("username"), 0)) { + zephir_array_unset_string(&descriptor, SL("username"), PH_SEPARATE); } - ZEPHIR_OBS_VAR(&values); - zephir_array_fetch_string(&values, &intermediate, SL("values"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 881); - if (UNEXPECTED(zephir_fast_count_int(&fields) != zephir_fast_count_int(&values))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The column count does not match the values count", "phalcon/Mvc/Model/Query.zep", 890); - return; + ZEPHIR_OBS_VAR(&password); + if (zephir_array_isset_string_fetch(&password, &descriptor, SL("password"), 0)) { + zephir_array_unset_string(&descriptor, SL("password"), PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); + if (zephir_array_isset_string(&descriptor, SL("dialectClass"))) { + zephir_array_unset_string(&descriptor, SL("dialectClass"), PH_SEPARATE); + } + _1 = zephir_array_isset_string(&descriptor, SL("options")); + if (_1) { + zephir_array_fetch_string(&_2, &descriptor, SL("options"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 265); + _1 = Z_TYPE_P(&_2) == IS_ARRAY; + } + if (_1) { + ZEPHIR_OBS_VAR(&options); + zephir_array_fetch_string(&options, &descriptor, SL("options"), PH_NOISY, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 266); + zephir_array_unset_string(&descriptor, SL("options"), PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&options); + array_init(&options); + } + ZEPHIR_OBS_VAR(&persistent); + if (zephir_array_isset_string_fetch(&persistent, &descriptor, SL("persistent"), 0)) { + ZEPHIR_INIT_VAR(&_3$$9); + ZVAL_BOOL(&_3$$9, zephir_get_boolval(&persistent)); + zephir_array_update_long(&options, 12, &_3$$9, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } + ZEPHIR_INIT_VAR(&_4); + ZVAL_LONG(&_4, 2); + zephir_array_update_long(&options, 3, &_4, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_OBS_VAR(&dsnAttributesCustomRaw); + if (zephir_array_isset_string_fetch(&dsnAttributesCustomRaw, &descriptor, SL("dsn"), 0)) { + zephir_array_append(&dsnParts, &dsnAttributesCustomRaw, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 282); + zephir_array_unset_string(&descriptor, SL("dsn"), PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getdsndefaults", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&insertValues); - array_init(&insertValues); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query.zep", 961); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _4, _5, _2) + ZEPHIR_INIT_VAR(&dsnAttributesMap); + zephir_fast_array_merge(&dsnAttributesMap, &_5, &descriptor); + zephir_is_iterable(&dsnAttributesMap, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 302); + if (Z_TYPE_P(&dsnAttributesMap) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&dsnAttributesMap), _8, _9, _6) { - ZEPHIR_INIT_NVAR(&number); - if (_5 != NULL) { - ZVAL_STR_COPY(&number, _5); + ZEPHIR_INIT_NVAR(&key); + if (_9 != NULL) { + ZVAL_STR_COPY(&key, _9); } else { - ZVAL_LONG(&number, _4); + ZVAL_LONG(&key, _8); } ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 900); - zephir_array_fetch_string(&_6$$8, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 902); - do { - if (ZEPHIR_IS_LONG(&_6$$8, 260) || ZEPHIR_IS_LONG(&_6$$8, 258) || ZEPHIR_IS_LONG(&_6$$8, 259)) { - ZEPHIR_CALL_METHOD(&insertValue, &dialect, "getsqlexpression", &_7, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_6$$8, 322)) { - ZEPHIR_INIT_NVAR(&insertValue); - ZVAL_NULL(&insertValue); - break; - } - if (ZEPHIR_IS_LONG(&_6$$8, 273) || ZEPHIR_IS_LONG(&_6$$8, 274) || ZEPHIR_IS_LONG(&_6$$8, 277)) { - ZEPHIR_CALL_METHOD(&_8$$11, &dialect, "getsqlexpression", &_9, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$11); - ZVAL_STRING(&_10$$11, ":"); - ZEPHIR_INIT_NVAR(&_11$$11); - ZVAL_STRING(&_11$$11, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_10$$11, &_11$$11, &_8$$11); - ZEPHIR_OBS_NVAR(&insertValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&insertValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_12$$12); - object_init_ex(&_12$$12, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_13$$12); - ZEPHIR_CONCAT_SVS(&_13$$12, "Bound parameter '", &wildcard, "' cannot be replaced because it isn't in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_12$$12, "__construct", &_14, 32, &_13$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$12, "phalcon/Mvc/Model/Query.zep", 926); - ZEPHIR_MM_RESTORE(); - return; - } - break; - } - ZEPHIR_INIT_NVAR(&insertValue); - object_init_ex(&insertValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_15$$13, &dialect, "getsqlexpression", &_16, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &insertValue, "__construct", &_17, 35, &_15$$13); - zephir_check_call_status(); - break; - } while(0); - - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch(&fieldName, &fields, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 939); - _18$$8 = automaticFields; - if (_18$$8) { - _18$$8 = Z_TYPE_P(&columnMap) == IS_ARRAY; - } - if (_18$$8) { - ZEPHIR_OBS_NVAR(&attributeName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeName, &columnMap, &fieldName, 0)))) { - ZEPHIR_INIT_NVAR(&_19$$15); - object_init_ex(&_19$$15, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_20$$15); - ZEPHIR_CONCAT_SVS(&_20$$15, "Column '", &fieldName, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_19$$15, "__construct", &_14, 32, &_20$$15); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19$$15, "phalcon/Mvc/Model/Query.zep", 949); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeName, &fieldName); - } - zephir_array_update_zval(&insertValues, &attributeName, &insertValue, PH_COPY | PH_SEPARATE); + ZVAL_COPY(&value, _6); + ZEPHIR_INIT_NVAR(&_10$$11); + ZEPHIR_CONCAT_VSV(&_10$$11, &key, "=", &value); + zephir_array_append(&dsnParts, &_10$$11, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 298); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &dsnAttributesMap, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, &values, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_7, &dsnAttributesMap, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_7)) { break; } - ZEPHIR_CALL_METHOD(&number, &values, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&key, &dsnAttributesMap, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &dsnAttributesMap, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 900); - zephir_array_fetch_string(&_21$$17, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 902); - do { - if (ZEPHIR_IS_LONG(&_21$$17, 260) || ZEPHIR_IS_LONG(&_21$$17, 258) || ZEPHIR_IS_LONG(&_21$$17, 259)) { - ZEPHIR_CALL_METHOD(&insertValue, &dialect, "getsqlexpression", &_22, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_21$$17, 322)) { - ZEPHIR_INIT_NVAR(&insertValue); - ZVAL_NULL(&insertValue); - break; - } - if (ZEPHIR_IS_LONG(&_21$$17, 273) || ZEPHIR_IS_LONG(&_21$$17, 274) || ZEPHIR_IS_LONG(&_21$$17, 277)) { - ZEPHIR_CALL_METHOD(&_23$$20, &dialect, "getsqlexpression", &_24, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_25$$20); - ZVAL_STRING(&_25$$20, ":"); - ZEPHIR_INIT_NVAR(&_26$$20); - ZVAL_STRING(&_26$$20, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_25$$20, &_26$$20, &_23$$20); - ZEPHIR_OBS_NVAR(&insertValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&insertValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_27$$21); - object_init_ex(&_27$$21, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_28$$21); - ZEPHIR_CONCAT_SVS(&_28$$21, "Bound parameter '", &wildcard, "' cannot be replaced because it isn't in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_27$$21, "__construct", &_14, 32, &_28$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_27$$21, "phalcon/Mvc/Model/Query.zep", 926); - ZEPHIR_MM_RESTORE(); - return; - } - break; - } - ZEPHIR_INIT_NVAR(&insertValue); - object_init_ex(&insertValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_29$$22, &dialect, "getsqlexpression", &_30, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &insertValue, "__construct", &_17, 35, &_29$$22); - zephir_check_call_status(); - break; - } while(0); - - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch(&fieldName, &fields, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 939); - _31$$17 = automaticFields; - if (_31$$17) { - _31$$17 = Z_TYPE_P(&columnMap) == IS_ARRAY; - } - if (_31$$17) { - ZEPHIR_OBS_NVAR(&attributeName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeName, &columnMap, &fieldName, 0)))) { - ZEPHIR_INIT_NVAR(&_32$$24); - object_init_ex(&_32$$24, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_33$$24); - ZEPHIR_CONCAT_SVS(&_33$$24, "Column '", &fieldName, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_32$$24, "__construct", &_14, 32, &_33$$24); - zephir_check_call_status(); - zephir_throw_exception_debug(&_32$$24, "phalcon/Mvc/Model/Query.zep", 949); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeName, &fieldName); - } - zephir_array_update_zval(&insertValues, &attributeName, &insertValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_11$$12); + ZEPHIR_CONCAT_VSV(&_11$$12, &key, "=", &value); + zephir_array_append(&dsnParts, &_11$$12, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 298); + ZEPHIR_CALL_METHOD(NULL, &dsnAttributesMap, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&number); - ZEPHIR_CALL_METHOD(&insertModel, &manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &insertModel, "assign", NULL, 0, &insertValues); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZEPHIR_CALL_METHOD(&_34, &insertModel, "create", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_34, &insertModel); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_VAR(&dsnAttributes); + zephir_fast_join_str(&dsnAttributes, SL(";"), &dsnParts); + ZEPHIR_INIT_VAR(&_12); + object_init_ex(&_12, php_pdo_get_dbh_ce()); + zephir_read_property(&_13, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14); + ZEPHIR_CONCAT_VSV(&_14, &_13, ":", &dsnAttributes); + ZEPHIR_CALL_METHOD(NULL, &_12, "__construct", NULL, 0, &_14, &username, &password, &options); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), &_12); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeSelect) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, convertBoundParams) { - zend_string *_17, *_63, *_69, *_84$$93; - zend_ulong _16, _62, _68, _83$$93; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_8 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL, *_30 = NULL, *_41 = NULL, *_42 = NULL, *_43 = NULL, *_51 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, numberObjects = 0; - zend_bool simulate, haveObjects = 0, haveScalars = 0, isComplex = 0, isSimpleStd = 0, isKeepingSnapshots = 0, _38$$28, _59$$46, _90$$83; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, *simulate_param = NULL, __$true, __$null, manager, modelName, models, model, connection, connectionTypes, columns, column, selectColumns, simpleColumnMap, metaData, aliasCopy, sqlColumn, attributes, instance, columnMap, attribute, columnAlias, sqlAlias, dialect, sqlSelect, bindCounts, processed, wildcard, value, processedTypes, typeWildcard, result, resultData, cache, resultObject, columns1, typesColumnMap, wildcardValue, resultsetClassName, _0, *_1, _2, *_10, _11, *_14, _15, *_60, _61, *_66, _67, _73, _3$$3, _6$$5, _7$$7, _9$$9, _12$$11, _13$$16, _18$$28, _19$$29, *_23$$31, _24$$31, _29$$31, _26$$34, _28$$35, _31$$36, *_32$$37, _33$$37, _36$$41, _37$$42, _39$$46, _40$$47, *_44$$49, _45$$49, _50$$49, _47$$52, _49$$53, _52$$54, *_53$$55, _54$$55, _57$$59, _58$$60, _64$$67, _65$$71, _70$$73, _71$$76, _72$$79, _74$$90, *_75$$90, _76$$90, _78$$91, _80$$92, *_81$$93, _82$$93, _86$$94, _88$$95, _89$$85, _98$$83, _91$$98, _92$$98, _93$$97, _94$$97, _95$$99, _96$$99; - zval intermediate, bindParams, bindTypes, _25$$34, _27$$35, _34$$38, _35$$39, _46$$52, _48$$53, _55$$56, _56$$57, _77$$91, _79$$92, _85$$94, _87$$95, _97$$97; + zend_long ZEPHIR_LAST_CALL_STATUS, setOrder = 0; + zval params; + zval *sql_param = NULL, *params_param = NULL, boundSql, placeHolders, bindPattern, matches, placeMatch, value, _0, _1, _2, *_3$$3, _4$$3, _9$$3, _5$$4, _6$$5, _7$$8, _8$$9; + zval sql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&_25$$34); - ZVAL_UNDEF(&_27$$35); - ZVAL_UNDEF(&_34$$38); - ZVAL_UNDEF(&_35$$39); - ZVAL_UNDEF(&_46$$52); - ZVAL_UNDEF(&_48$$53); - ZVAL_UNDEF(&_55$$56); - ZVAL_UNDEF(&_56$$57); - ZVAL_UNDEF(&_77$$91); - ZVAL_UNDEF(&_79$$92); - ZVAL_UNDEF(&_85$$94); - ZVAL_UNDEF(&_87$$95); - ZVAL_UNDEF(&_97$$97); - ZVAL_BOOL(&__$true, 1); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&connectionTypes); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&selectColumns); - ZVAL_UNDEF(&simpleColumnMap); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&aliasCopy); - ZVAL_UNDEF(&sqlColumn); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&columnAlias); - ZVAL_UNDEF(&sqlAlias); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&sqlSelect); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&processed); - ZVAL_UNDEF(&wildcard); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&boundSql); + ZVAL_UNDEF(&placeHolders); + ZVAL_UNDEF(&bindPattern); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&placeMatch); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&processedTypes); - ZVAL_UNDEF(&typeWildcard); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&resultData); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&resultObject); - ZVAL_UNDEF(&columns1); - ZVAL_UNDEF(&typesColumnMap); - ZVAL_UNDEF(&wildcardValue); - ZVAL_UNDEF(&resultsetClassName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_61); - ZVAL_UNDEF(&_67); - ZVAL_UNDEF(&_73); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_18$$28); - ZVAL_UNDEF(&_19$$29); - ZVAL_UNDEF(&_24$$31); - ZVAL_UNDEF(&_29$$31); - ZVAL_UNDEF(&_26$$34); - ZVAL_UNDEF(&_28$$35); - ZVAL_UNDEF(&_31$$36); - ZVAL_UNDEF(&_33$$37); - ZVAL_UNDEF(&_36$$41); - ZVAL_UNDEF(&_37$$42); - ZVAL_UNDEF(&_39$$46); - ZVAL_UNDEF(&_40$$47); - ZVAL_UNDEF(&_45$$49); - ZVAL_UNDEF(&_50$$49); - ZVAL_UNDEF(&_47$$52); - ZVAL_UNDEF(&_49$$53); - ZVAL_UNDEF(&_52$$54); - ZVAL_UNDEF(&_54$$55); - ZVAL_UNDEF(&_57$$59); - ZVAL_UNDEF(&_58$$60); - ZVAL_UNDEF(&_64$$67); - ZVAL_UNDEF(&_65$$71); - ZVAL_UNDEF(&_70$$73); - ZVAL_UNDEF(&_71$$76); - ZVAL_UNDEF(&_72$$79); - ZVAL_UNDEF(&_74$$90); - ZVAL_UNDEF(&_76$$90); - ZVAL_UNDEF(&_78$$91); - ZVAL_UNDEF(&_80$$92); - ZVAL_UNDEF(&_82$$93); - ZVAL_UNDEF(&_86$$94); - ZVAL_UNDEF(&_88$$95); - ZVAL_UNDEF(&_89$$85); - ZVAL_UNDEF(&_98$$83); - ZVAL_UNDEF(&_91$$98); - ZVAL_UNDEF(&_92$$98); - ZVAL_UNDEF(&_93$$97); - ZVAL_UNDEF(&_94$$97); - ZVAL_UNDEF(&_95$$99); - ZVAL_UNDEF(&_96$$99); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(¶ms); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(sql) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(simulate) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &intermediate_param, &bindParams_param, &bindTypes_param, &simulate_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - if (!simulate_param) { - simulate = 0; + zephir_fetch_params(1, 1, 1, &sql_param, ¶ms_param); + if (UNEXPECTED(Z_TYPE_P(sql_param) != IS_STRING && Z_TYPE_P(sql_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sql' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sql_param) == IS_STRING)) { + zephir_get_strval(&sql, sql_param); } else { - simulate = zephir_get_boolval(simulate_param); + ZEPHIR_INIT_VAR(&sql); + } + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else { + zephir_get_arrval(¶ms, params_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_INIT_VAR(&connectionTypes); - array_init(&connectionTypes); - ZEPHIR_OBS_VAR(&models); - zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 998); - zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query.zep", 1026); - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&models), _1) - { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_COPY(&modelName, _1); - ZEPHIR_OBS_NVAR(&model); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_3$$3, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_4, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &model); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getreadconnection", &_5, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (Z_TYPE_P(&connection) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_6$$5, &connection, "gettype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&connectionTypes, &_6$$5, &__$true, PH_COPY | PH_SEPARATE); - if (UNEXPECTED(zephir_fast_count_int(&connectionTypes) == 2)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/Mvc/Model/Query.zep", 1021); - return; + ZEPHIR_INIT_VAR(&placeHolders); + array_init(&placeHolders); + ZEPHIR_INIT_VAR(&bindPattern); + ZVAL_STRING(&bindPattern, "/\\?([0-9]+)|:([a-zA-Z0-9_]+):/"); + ZEPHIR_INIT_VAR(&matches); + ZVAL_NULL(&matches); + setOrder = 2; + ZVAL_LONG(&_0, setOrder); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_2, setOrder); + zephir_preg_match(&_1, &bindPattern, &sql, &matches, 1, zephir_get_intval(&_0) , 0 ); + if (zephir_is_true(&_1)) { + zephir_is_iterable(&matches, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 356); + if (Z_TYPE_P(&matches) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&matches), _3$$3) + { + ZEPHIR_INIT_NVAR(&placeMatch); + ZVAL_COPY(&placeMatch, _3$$3); + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch_long(&_5$$4, &placeMatch, 1, PH_READONLY, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 339); + if (!(zephir_array_isset_fetch(&value, ¶ms, &_5$$4, 0))) { + if (UNEXPECTED(!(zephir_array_isset_long(&placeMatch, 2)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter was not found in parameters list", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 343); + return; + } + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch_long(&_6$$5, &placeMatch, 2, PH_READONLY, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 346); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, ¶ms, &_6$$5, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter was not found in parameters list", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 349); + return; + } } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &models, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&modelName, &models, "current", NULL, 0); + zephir_array_append(&placeHolders, &value, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 353); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &matches, "rewind", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&model); - zephir_read_property(&_7$$7, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_7$$7, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_8, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &model); + while (1) { + ZEPHIR_CALL_METHOD(&_4$$3, &matches, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4$$3)) { + break; } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getreadconnection", &_5, 0, &model, &intermediate, &bindParams, &bindTypes); + ZEPHIR_CALL_METHOD(&placeMatch, &matches, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&connection) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_9$$9, &connection, "gettype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&connectionTypes, &_9$$9, &__$true, PH_COPY | PH_SEPARATE); - if (UNEXPECTED(zephir_fast_count_int(&connectionTypes) == 2)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/Mvc/Model/Query.zep", 1021); - return; + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch_long(&_7$$8, &placeMatch, 1, PH_READONLY, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 339); + if (!(zephir_array_isset_fetch(&value, ¶ms, &_7$$8, 0))) { + if (UNEXPECTED(!(zephir_array_isset_long(&placeMatch, 2)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter was not found in parameters list", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 343); + return; + } + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch_long(&_8$$9, &placeMatch, 2, PH_READONLY, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 346); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, ¶ms, &_8$$9, 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter was not found in parameters list", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 349); + return; + } } - } - ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); - zephir_check_call_status(); + zephir_array_append(&placeHolders, &value, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 353); + ZEPHIR_CALL_METHOD(NULL, &matches, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&placeMatch); + ZEPHIR_INIT_VAR(&_9$$3); + ZVAL_STRING(&_9$$3, "?"); + ZEPHIR_CALL_FUNCTION(&boundSql, "preg_replace", NULL, 40, &bindPattern, &_9$$3, &sql); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&boundSql, &sql); } - ZEPHIR_INIT_NVAR(&modelName); - ZEPHIR_OBS_VAR(&columns); - zephir_array_fetch_string(&columns, &intermediate, SL("columns"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1026); - haveObjects = 0; - haveScalars = 0; - isComplex = 0; - numberObjects = 0; - ZEPHIR_CPY_WRT(&columns1, &columns); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query.zep", 1054); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _10) - { - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _10); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/Mvc/Model/Query.zep", 1038); - return; - } - zephir_array_fetch_string(&_12$$11, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1041); - if (ZEPHIR_IS_STRING(&_12$$11, "scalar")) { - if (!(zephir_array_isset_string(&column, SL("balias")))) { - isComplex = 1; - } - haveScalars = 1; - } else { - haveObjects = 1; - numberObjects++; - } - } ZEND_HASH_FOREACH_END(); + zephir_create_array(return_value, 2, 0); + zephir_array_update_string(return_value, SL("sql"), &boundSql, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("params"), &placeHolders, PH_COPY | PH_SEPARATE); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, escapeString) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *str_param = NULL, _0; + zval str; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&str); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(str) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &str_param); + zephir_get_strval(&str, str_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "quote", NULL, 0, &str); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, execute) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval bindParams, bindTypes; + zval *sqlStatement_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, eventsManager, affectedRows, newStatement, statement, _0, _1$$3, _2$$3, _3$$5, _4$$7, _5$$9; + zval sqlStatement; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&sqlStatement); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&affectedRows); + ZVAL_UNDEF(&newStatement); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(sqlStatement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { + zephir_get_strval(&sqlStatement, sqlStatement_param); } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + ZEPHIR_INIT_VAR(&sqlStatement); + } + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); + } + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); + } + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlStatement"), &sqlStatement); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlVariables"), &bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlBindTypes"), &bindTypes); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "db:beforeQuery"); + ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11, &columns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11)) { - break; - } - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_INIT_VAR(&affectedRows); + ZVAL_LONG(&affectedRows, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "preparerealsql", NULL, 0, &sqlStatement, &bindParams); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&bindParams))) { + zephir_read_property(&_3$$5, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&statement, &_3$$5, "prepare", NULL, 0, &sqlStatement); + zephir_check_call_status(); + if (Z_TYPE_P(&statement) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&newStatement, this_ptr, "executeprepared", NULL, 0, &statement, &bindParams, &bindTypes); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/Mvc/Model/Query.zep", 1038); - return; - } - zephir_array_fetch_string(&_13$$16, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1041); - if (ZEPHIR_IS_STRING(&_13$$16, "scalar")) { - if (!(zephir_array_isset_string(&column, SL("balias")))) { - isComplex = 1; - } - haveScalars = 1; - } else { - haveObjects = 1; - numberObjects++; - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&affectedRows, &newStatement, "rowcount", NULL, 0); zephir_check_call_status(); } + } else { + zephir_read_property(&_4$$7, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&affectedRows, &_4$$7, "exec", NULL, 0, &sqlStatement); + zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(&column); - if (!(isComplex)) { - if (haveObjects) { - if (haveScalars) { - isComplex = 1; - } else { - if (numberObjects == 1) { - isSimpleStd = 0; - } else { - isComplex = 1; - } - } - } else { - isSimpleStd = 1; + if (Z_TYPE_P(&affectedRows) == IS_LONG) { + zephir_update_property_zval(this_ptr, ZEND_STRL("affectedRows"), &affectedRows); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_5$$9); + ZVAL_STRING(&_5$$9, "db:afterQuery"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_5$$9, this_ptr); + zephir_check_call_status(); } } - ZEPHIR_INIT_VAR(&instance); - ZVAL_NULL(&instance); - ZEPHIR_INIT_VAR(&selectColumns); - array_init(&selectColumns); - ZEPHIR_INIT_VAR(&simpleColumnMap); - array_init(&simpleColumnMap); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_0); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query.zep", 1160); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _16, _17, _14) + RETURN_MM_BOOL(1); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, executePrepared) +{ + zval _5$$8, _8$$13, _25$$39, _27$$44; + zend_bool _4$$3, _24$$34; + zend_string *_3, *_13$$22, *_21$$31, *_31$$53, *_39$$62; + zend_ulong _2, _12$$22, _20$$31, _30$$53, _38$$62; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval placeholders; + zval *statement, statement_sub, *placeholders_param = NULL, *dataTypes, dataTypes_sub, wildcard, value, type, castValue, parameter, position, itemValue, *_0, _1, _6$$12, *_10$$22, _11$$22, _14$$24, _15$$25, _16$$27, _17$$28, *_18$$31, _19$$31, _22$$32, _23$$33, _26$$43, *_28$$53, _29$$53, _32$$55, _33$$56, _34$$58, _35$$59, *_36$$62, _37$$62, _40$$63, _41$$64; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&statement_sub); + ZVAL_UNDEF(&dataTypes_sub); + ZVAL_UNDEF(&wildcard); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&castValue); + ZVAL_UNDEF(¶meter); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&itemValue); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6$$12); + ZVAL_UNDEF(&_11$$22); + ZVAL_UNDEF(&_14$$24); + ZVAL_UNDEF(&_15$$25); + ZVAL_UNDEF(&_16$$27); + ZVAL_UNDEF(&_17$$28); + ZVAL_UNDEF(&_19$$31); + ZVAL_UNDEF(&_22$$32); + ZVAL_UNDEF(&_23$$33); + ZVAL_UNDEF(&_26$$43); + ZVAL_UNDEF(&_29$$53); + ZVAL_UNDEF(&_32$$55); + ZVAL_UNDEF(&_33$$56); + ZVAL_UNDEF(&_34$$58); + ZVAL_UNDEF(&_35$$59); + ZVAL_UNDEF(&_37$$62); + ZVAL_UNDEF(&_40$$63); + ZVAL_UNDEF(&_41$$64); + ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_8$$13); + ZVAL_UNDEF(&_25$$39); + ZVAL_UNDEF(&_27$$44); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(statement, zephir_get_internal_ce(SL("pdostatement"))) + Z_PARAM_ARRAY(placeholders) + Z_PARAM_ZVAL(dataTypes) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &statement, &placeholders_param, &dataTypes); + ZEPHIR_OBS_COPY_OR_DUP(&placeholders, placeholders_param); + + + zephir_is_iterable(&placeholders, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 567); + if (Z_TYPE_P(&placeholders) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&placeholders), _2, _3, _0) { - ZEPHIR_INIT_NVAR(&aliasCopy); - if (_17 != NULL) { - ZVAL_STR_COPY(&aliasCopy, _17); + ZEPHIR_INIT_NVAR(&wildcard); + if (_3 != NULL) { + ZVAL_STR_COPY(&wildcard, _3); } else { - ZVAL_LONG(&aliasCopy, _16); + ZVAL_LONG(&wildcard, _2); } - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _14); - ZEPHIR_OBS_NVAR(&sqlColumn); - zephir_array_fetch_string(&sqlColumn, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1077); - zephir_array_fetch_string(&_18$$28, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1080); - if (ZEPHIR_IS_STRING(&_18$$28, "object")) { - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &column, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1081); - ZEPHIR_OBS_NVAR(&instance); - zephir_read_property(&_19$$29, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&instance, &_19$$29, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&instance, &manager, "load", &_20, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &instance); + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (Z_TYPE_P(&wildcard) == IS_LONG) { + ZEPHIR_INIT_NVAR(¶meter); + ZVAL_LONG(¶meter, (zephir_get_numberval(&wildcard) + 1)); + } else if (Z_TYPE_P(&wildcard) == IS_STRING) { + ZEPHIR_CPY_WRT(¶meter, &wildcard); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind parameter (1)", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 487); + return; + } + _4$$3 = Z_TYPE_P(dataTypes) == IS_ARRAY; + if (_4$$3) { + ZEPHIR_OBS_NVAR(&type); + _4$$3 = zephir_array_isset_fetch(&type, dataTypes, &wildcard, 0); + } + if (_4$$3) { + if (ZEPHIR_IS_LONG(&type, 32)) { + zephir_cast_to_string(&_5$$8, &value); + ZEPHIR_CPY_WRT(&castValue, &_5$$8); + ZEPHIR_INIT_NVAR(&type); + ZVAL_LONG(&type, 1024); + } else { + if (ZEPHIR_GLOBAL(db).force_casting) { + if (Z_TYPE_P(&value) != IS_ARRAY) { + do { + if (ZEPHIR_IS_LONG(&type, 1)) { + ZVAL_LONG(&_6$$12, 10); + ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_7, 41, &value, &_6$$12); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 2)) { + zephir_cast_to_string(&_8$$13, &value); + ZEPHIR_CPY_WRT(&castValue, &_8$$13); + break; + } + if (ZEPHIR_IS_LONG(&type, 0)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_NULL(&castValue); + break; + } + if (ZEPHIR_IS_LONG(&type, 5)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_BOOL(&castValue, zephir_get_boolval(&value)); + break; + } + ZEPHIR_CPY_WRT(&castValue, &value); + break; + } while(0); + + } else { + ZEPHIR_CPY_WRT(&castValue, &value); + } + } else { + ZEPHIR_CPY_WRT(&castValue, &value); + } } - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", &_21, 0, &instance); - zephir_check_call_status(); - if (isComplex) { - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", &_22, 0, &instance); + if (Z_TYPE_P(&castValue) != IS_ARRAY) { + if (ZEPHIR_IS_LONG(&type, 1024)) { + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &castValue); zephir_check_call_status(); } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &castValue, &type); + zephir_check_call_status(); } - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1117); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _23$$31) + } else { + zephir_is_iterable(&castValue, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 555); + if (Z_TYPE_P(&castValue) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&castValue), _12$$22, _13$$22, _10$$22) { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _23$$31); - ZEPHIR_INIT_NVAR(&_25$$34); - zephir_create_array(&_25$$34, 3, 0); - zephir_array_fast_append(&_25$$34, &attribute); - zephir_array_fast_append(&_25$$34, &sqlColumn); - ZEPHIR_INIT_NVAR(&_26$$34); - ZEPHIR_CONCAT_SVSV(&_26$$34, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_25$$34, &_26$$34); - zephir_array_append(&selectColumns, &_25$$34, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); + ZEPHIR_INIT_NVAR(&position); + if (_13$$22 != NULL) { + ZVAL_STR_COPY(&position, _13$$22); + } else { + ZVAL_LONG(&position, _12$$22); + } + ZEPHIR_INIT_NVAR(&itemValue); + ZVAL_COPY(&itemValue, _10$$22); + if (ZEPHIR_IS_LONG(&type, 1024)) { + ZEPHIR_INIT_NVAR(&_14$$24); + ZEPHIR_CONCAT_VV(&_14$$24, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_14$$24, &itemValue); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_15$$25); + ZEPHIR_CONCAT_VV(&_15$$25, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_15$$25, &itemValue, &type); + zephir_check_call_status(); + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &castValue, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_24$$31, &attributes, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_11$$22, &castValue, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_24$$31)) { + if (!zend_is_true(&_11$$22)) { break; } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&position, &castValue, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_27$$35); - zephir_create_array(&_27$$35, 3, 0); - zephir_array_fast_append(&_27$$35, &attribute); - zephir_array_fast_append(&_27$$35, &sqlColumn); - ZEPHIR_INIT_NVAR(&_28$$35); - ZEPHIR_CONCAT_SVSV(&_28$$35, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_27$$35, &_28$$35); - zephir_array_append(&selectColumns, &_27$$35, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&itemValue, &castValue, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&type, 1024)) { + ZEPHIR_INIT_NVAR(&_16$$27); + ZEPHIR_CONCAT_VV(&_16$$27, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_16$$27, &itemValue); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_17$$28); + ZEPHIR_CONCAT_VV(&_17$$28, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_17$$28, &itemValue, &type); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &castValue, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&attribute); - zephir_array_update_multi(&columns1, &instance, SL("zs"), 3, &aliasCopy, SL("instance")); - zephir_array_update_multi(&columns1, &attributes, SL("zs"), 3, &aliasCopy, SL("attributes")); - zephir_array_update_multi(&columns1, &columnMap, SL("zs"), 3, &aliasCopy, SL("columnMap")); - ZEPHIR_CALL_METHOD(&_29$$31, &manager, "iskeepingsnapshots", &_30, 0, &instance); + ZEPHIR_INIT_NVAR(&itemValue); + ZEPHIR_INIT_NVAR(&position); + } + } else { + if (Z_TYPE_P(&value) != IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &value); zephir_check_call_status(); - isKeepingSnapshots = zephir_get_boolval(&_29$$31); - if (isKeepingSnapshots) { - ZEPHIR_INIT_NVAR(&_31$$36); - ZVAL_BOOL(&_31$$36, isKeepingSnapshots); - zephir_array_update_multi(&columns1, &_31$$36, SL("zs"), 3, &aliasCopy, SL("keepSnapshots")); - } } else { - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1134); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _32$$37) + zephir_is_iterable(&value, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 563); + if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&value), _20$$31, _21$$31, _18$$31) { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _32$$37); - ZEPHIR_INIT_NVAR(&_34$$38); - zephir_create_array(&_34$$38, 2, 0); - zephir_array_fast_append(&_34$$38, &attribute); - zephir_array_fast_append(&_34$$38, &sqlColumn); - zephir_array_append(&selectColumns, &_34$$38, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); + ZEPHIR_INIT_NVAR(&position); + if (_21$$31 != NULL) { + ZVAL_STR_COPY(&position, _21$$31); + } else { + ZVAL_LONG(&position, _20$$31); + } + ZEPHIR_INIT_NVAR(&itemValue); + ZVAL_COPY(&itemValue, _18$$31); + ZEPHIR_INIT_NVAR(&_22$$32); + ZEPHIR_CONCAT_VV(&_22$$32, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_22$$32, &itemValue); + zephir_check_call_status(); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &value, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_33$$37, &attributes, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_19$$31, &value, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_33$$37)) { + if (!zend_is_true(&_19$$31)) { break; } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&position, &value, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_35$$39); - zephir_create_array(&_35$$39, 2, 0); - zephir_array_fast_append(&_35$$39, &attribute); - zephir_array_fast_append(&_35$$39, &sqlColumn); - zephir_array_append(&selectColumns, &_35$$39, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&itemValue, &value, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_23$$33); + ZEPHIR_CONCAT_VV(&_23$$33, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_23$$33, &itemValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &value, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&attribute); - } - } else { - ZEPHIR_INIT_NVAR(&columnAlias); - if (Z_TYPE_P(&aliasCopy) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_36$$41); - zephir_create_array(&_36$$41, 2, 0); - zephir_array_fast_append(&_36$$41, &sqlColumn); - zephir_array_fast_append(&_36$$41, &__$null); - ZEPHIR_CPY_WRT(&columnAlias, &_36$$41); - } else { - ZEPHIR_INIT_NVAR(&_37$$42); - zephir_create_array(&_37$$42, 3, 0); - zephir_array_fast_append(&_37$$42, &sqlColumn); - zephir_array_fast_append(&_37$$42, &__$null); - zephir_array_fast_append(&_37$$42, &aliasCopy); - ZEPHIR_CPY_WRT(&columnAlias, &_37$$42); - } - zephir_array_append(&selectColumns, &columnAlias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1145); - } - _38$$28 = !isComplex; - if (_38$$28) { - _38$$28 = isSimpleStd; - } - if (_38$$28) { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - zephir_array_update_zval(&simpleColumnMap, &sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&simpleColumnMap, &aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&itemValue); + ZEPHIR_INIT_NVAR(&position); } } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &placeholders, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_15, &columns, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &placeholders, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_15)) { + if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&aliasCopy, &columns, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&wildcard, &placeholders, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &placeholders, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&sqlColumn); - zephir_array_fetch_string(&sqlColumn, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1077); - zephir_array_fetch_string(&_39$$46, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1080); - if (ZEPHIR_IS_STRING(&_39$$46, "object")) { - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &column, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1081); - ZEPHIR_OBS_NVAR(&instance); - zephir_read_property(&_40$$47, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&instance, &_40$$47, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&instance, &manager, "load", &_41, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &instance); + if (Z_TYPE_P(&wildcard) == IS_LONG) { + ZEPHIR_INIT_NVAR(¶meter); + ZVAL_LONG(¶meter, (zephir_get_numberval(&wildcard) + 1)); + } else if (Z_TYPE_P(&wildcard) == IS_STRING) { + ZEPHIR_CPY_WRT(¶meter, &wildcard); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind parameter (1)", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 487); + return; + } + _24$$34 = Z_TYPE_P(dataTypes) == IS_ARRAY; + if (_24$$34) { + ZEPHIR_OBS_NVAR(&type); + _24$$34 = zephir_array_isset_fetch(&type, dataTypes, &wildcard, 0); + } + if (_24$$34) { + if (ZEPHIR_IS_LONG(&type, 32)) { + zephir_cast_to_string(&_25$$39, &value); + ZEPHIR_CPY_WRT(&castValue, &_25$$39); + ZEPHIR_INIT_NVAR(&type); + ZVAL_LONG(&type, 1024); + } else { + if (ZEPHIR_GLOBAL(db).force_casting) { + if (Z_TYPE_P(&value) != IS_ARRAY) { + do { + if (ZEPHIR_IS_LONG(&type, 1)) { + ZVAL_LONG(&_26$$43, 10); + ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_7, 41, &value, &_26$$43); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 2)) { + zephir_cast_to_string(&_27$$44, &value); + ZEPHIR_CPY_WRT(&castValue, &_27$$44); + break; + } + if (ZEPHIR_IS_LONG(&type, 0)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_NULL(&castValue); + break; + } + if (ZEPHIR_IS_LONG(&type, 5)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_BOOL(&castValue, zephir_get_boolval(&value)); + break; + } + ZEPHIR_CPY_WRT(&castValue, &value); + break; + } while(0); + + } else { + ZEPHIR_CPY_WRT(&castValue, &value); + } + } else { + ZEPHIR_CPY_WRT(&castValue, &value); + } } - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", &_42, 0, &instance); - zephir_check_call_status(); - if (isComplex) { - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", &_43, 0, &instance); + if (Z_TYPE_P(&castValue) != IS_ARRAY) { + if (ZEPHIR_IS_LONG(&type, 1024)) { + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &castValue); zephir_check_call_status(); } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &castValue, &type); + zephir_check_call_status(); } - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1117); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _44$$49) + } else { + zephir_is_iterable(&castValue, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 555); + if (Z_TYPE_P(&castValue) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&castValue), _30$$53, _31$$53, _28$$53) { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _44$$49); - ZEPHIR_INIT_NVAR(&_46$$52); - zephir_create_array(&_46$$52, 3, 0); - zephir_array_fast_append(&_46$$52, &attribute); - zephir_array_fast_append(&_46$$52, &sqlColumn); - ZEPHIR_INIT_NVAR(&_47$$52); - ZEPHIR_CONCAT_SVSV(&_47$$52, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_46$$52, &_47$$52); - zephir_array_append(&selectColumns, &_46$$52, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); + ZEPHIR_INIT_NVAR(&position); + if (_31$$53 != NULL) { + ZVAL_STR_COPY(&position, _31$$53); + } else { + ZVAL_LONG(&position, _30$$53); + } + ZEPHIR_INIT_NVAR(&itemValue); + ZVAL_COPY(&itemValue, _28$$53); + if (ZEPHIR_IS_LONG(&type, 1024)) { + ZEPHIR_INIT_NVAR(&_32$$55); + ZEPHIR_CONCAT_VV(&_32$$55, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_32$$55, &itemValue); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_33$$56); + ZEPHIR_CONCAT_VV(&_33$$56, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_33$$56, &itemValue, &type); + zephir_check_call_status(); + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &castValue, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_45$$49, &attributes, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_29$$53, &castValue, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_45$$49)) { + if (!zend_is_true(&_29$$53)) { break; } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&position, &castValue, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_48$$53); - zephir_create_array(&_48$$53, 3, 0); - zephir_array_fast_append(&_48$$53, &attribute); - zephir_array_fast_append(&_48$$53, &sqlColumn); - ZEPHIR_INIT_NVAR(&_49$$53); - ZEPHIR_CONCAT_SVSV(&_49$$53, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_48$$53, &_49$$53); - zephir_array_append(&selectColumns, &_48$$53, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&itemValue, &castValue, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&type, 1024)) { + ZEPHIR_INIT_NVAR(&_34$$58); + ZEPHIR_CONCAT_VV(&_34$$58, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_34$$58, &itemValue); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_35$$59); + ZEPHIR_CONCAT_VV(&_35$$59, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_35$$59, &itemValue, &type); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &castValue, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&attribute); - zephir_array_update_multi(&columns1, &instance, SL("zs"), 3, &aliasCopy, SL("instance")); - zephir_array_update_multi(&columns1, &attributes, SL("zs"), 3, &aliasCopy, SL("attributes")); - zephir_array_update_multi(&columns1, &columnMap, SL("zs"), 3, &aliasCopy, SL("columnMap")); - ZEPHIR_CALL_METHOD(&_50$$49, &manager, "iskeepingsnapshots", &_51, 0, &instance); + ZEPHIR_INIT_NVAR(&itemValue); + ZEPHIR_INIT_NVAR(&position); + } + } else { + if (Z_TYPE_P(&value) != IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &value); zephir_check_call_status(); - isKeepingSnapshots = zephir_get_boolval(&_50$$49); - if (isKeepingSnapshots) { - ZEPHIR_INIT_NVAR(&_52$$54); - ZVAL_BOOL(&_52$$54, isKeepingSnapshots); - zephir_array_update_multi(&columns1, &_52$$54, SL("zs"), 3, &aliasCopy, SL("keepSnapshots")); - } } else { - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1134); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _53$$55) + zephir_is_iterable(&value, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 563); + if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&value), _38$$62, _39$$62, _36$$62) { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _53$$55); - ZEPHIR_INIT_NVAR(&_55$$56); - zephir_create_array(&_55$$56, 2, 0); - zephir_array_fast_append(&_55$$56, &attribute); - zephir_array_fast_append(&_55$$56, &sqlColumn); - zephir_array_append(&selectColumns, &_55$$56, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); + ZEPHIR_INIT_NVAR(&position); + if (_39$$62 != NULL) { + ZVAL_STR_COPY(&position, _39$$62); + } else { + ZVAL_LONG(&position, _38$$62); + } + ZEPHIR_INIT_NVAR(&itemValue); + ZVAL_COPY(&itemValue, _36$$62); + ZEPHIR_INIT_NVAR(&_40$$63); + ZEPHIR_CONCAT_VV(&_40$$63, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_40$$63, &itemValue); + zephir_check_call_status(); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &value, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_54$$55, &attributes, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_37$$62, &value, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_54$$55)) { + if (!zend_is_true(&_37$$62)) { break; } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&position, &value, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_56$$57); - zephir_create_array(&_56$$57, 2, 0); - zephir_array_fast_append(&_56$$57, &attribute); - zephir_array_fast_append(&_56$$57, &sqlColumn); - zephir_array_append(&selectColumns, &_56$$57, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&itemValue, &value, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_41$$64); + ZEPHIR_CONCAT_VV(&_41$$64, ¶meter, &position); + ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, &_41$$64, &itemValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &value, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&attribute); - } - } else { - if (Z_TYPE_P(&aliasCopy) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_57$$59); - zephir_create_array(&_57$$59, 2, 0); - zephir_array_fast_append(&_57$$59, &sqlColumn); - zephir_array_fast_append(&_57$$59, &__$null); - ZEPHIR_CPY_WRT(&columnAlias, &_57$$59); - } else { - ZEPHIR_INIT_NVAR(&_58$$60); - zephir_create_array(&_58$$60, 3, 0); - zephir_array_fast_append(&_58$$60, &sqlColumn); - zephir_array_fast_append(&_58$$60, &__$null); - zephir_array_fast_append(&_58$$60, &aliasCopy); - ZEPHIR_CPY_WRT(&columnAlias, &_58$$60); - } - zephir_array_append(&selectColumns, &columnAlias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1145); - } - _59$$46 = !isComplex; - if (_59$$46) { - _59$$46 = isSimpleStd; - } - if (_59$$46) { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - zephir_array_update_zval(&simpleColumnMap, &sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&simpleColumnMap, &aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&itemValue); + ZEPHIR_INIT_NVAR(&position); } } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_NVAR(&aliasCopy); - ZEPHIR_INIT_VAR(&processed); - array_init(&processed); - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - zephir_array_update_string(&intermediate, SL("columns"), &selectColumns, PH_COPY | PH_SEPARATE); - zephir_is_iterable(&bindParams, 0, "phalcon/Mvc/Model/Query.zep", 1181); - if (Z_TYPE_P(&bindParams) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bindParams), _62, _63, _60) - { - ZEPHIR_INIT_NVAR(&wildcard); - if (_63 != NULL) { - ZVAL_STR_COPY(&wildcard, _63); - } else { - ZVAL_LONG(&wildcard, _62); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _60); - if (Z_TYPE_P(&wildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&wildcardValue); - ZEPHIR_CONCAT_SV(&wildcardValue, ":", &wildcard); - } else { - ZEPHIR_CPY_WRT(&wildcardValue, &wildcard); - } - zephir_array_update_zval(&processed, &wildcardValue, &value, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_64$$67); - ZVAL_LONG(&_64$$67, zephir_fast_count_int(&value)); - zephir_array_update_zval(&bindCounts, &wildcardValue, &_64$$67, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &bindParams, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_61, &bindParams, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_61)) { - break; - } - ZEPHIR_CALL_METHOD(&wildcard, &bindParams, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &bindParams, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&wildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&wildcardValue); - ZEPHIR_CONCAT_SV(&wildcardValue, ":", &wildcard); - } else { - ZEPHIR_CPY_WRT(&wildcardValue, &wildcard); - } - zephir_array_update_zval(&processed, &wildcardValue, &value, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_65$$71); - ZVAL_LONG(&_65$$71, zephir_fast_count_int(&value)); - zephir_array_update_zval(&bindCounts, &wildcardValue, &_65$$71, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &bindParams, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &placeholders, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&value); ZEPHIR_INIT_NVAR(&wildcard); - ZEPHIR_INIT_VAR(&processedTypes); - array_init(&processedTypes); - zephir_is_iterable(&bindTypes, 0, "phalcon/Mvc/Model/Query.zep", 1194); - if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bindTypes), _68, _69, _66) - { - ZEPHIR_INIT_NVAR(&typeWildcard); - if (_69 != NULL) { - ZVAL_STR_COPY(&typeWildcard, _69); - } else { - ZVAL_LONG(&typeWildcard, _68); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _66); - if (Z_TYPE_P(&typeWildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_70$$73); - ZEPHIR_CONCAT_SV(&_70$$73, ":", &typeWildcard); - zephir_array_update_zval(&processedTypes, &_70$$73, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&processedTypes, &typeWildcard, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &bindTypes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_67, &bindTypes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_67)) { - break; - } - ZEPHIR_CALL_METHOD(&typeWildcard, &bindTypes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &bindTypes, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&typeWildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_71$$76); - ZEPHIR_CONCAT_SV(&_71$$76, ":", &typeWildcard); - zephir_array_update_zval(&processedTypes, &_71$$76, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&processedTypes, &typeWildcard, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &bindTypes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&typeWildcard); - if (zephir_fast_count_int(&bindCounts)) { - zephir_array_update_string(&intermediate, SL("bindCounts"), &bindCounts, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&sqlSelect, &dialect, "select", NULL, 0, &intermediate); + ZEPHIR_CALL_METHOD(NULL, statement, "execute", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_METHOD(&_72$$79, &dialect, "sharedlock", NULL, 0, &sqlSelect); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&sqlSelect, &_72$$79); - } - if (simulate) { - zephir_create_array(return_value, 3, 0); - zephir_array_update_string(return_value, SL("sql"), &sqlSelect, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("bind"), &processed, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("bindTypes"), &processedTypes, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&result, &connection, "query", NULL, 0, &sqlSelect, &processed, &processedTypes); + RETVAL_ZVAL(statement, 1, 0); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, getErrorInfo) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "errorinfo", NULL, 0); zephir_check_call_status(); - if (zephir_instance_of_ev(&result, phalcon_db_resultinterface_ce)) { - ZEPHIR_CPY_WRT(&resultData, &result); - } else { - ZEPHIR_INIT_NVAR(&resultData); - ZVAL_NULL(&resultData); - } - zephir_read_property(&_73, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_73); - if (!(isComplex)) { - if (isSimpleStd) { - ZEPHIR_INIT_VAR(&resultObject); - object_init_ex(&resultObject, phalcon_mvc_model_row_ce); - if (zephir_has_constructor(&resultObject)) { - ZEPHIR_CALL_METHOD(NULL, &resultObject, "__construct", NULL, 0); - zephir_check_call_status(); - } + RETURN_MM(); +} - isKeepingSnapshots = 0; - } else { - if (Z_TYPE_P(&instance) == IS_OBJECT) { - ZEPHIR_CPY_WRT(&resultObject, &instance); - } else { - ZEPHIR_CPY_WRT(&resultObject, &model); - } - if (!(ZEPHIR_GLOBAL(orm).cast_on_hydrate)) { - ZEPHIR_CALL_METHOD(&simpleColumnMap, &metaData, "getcolumnmap", NULL, 0, &resultObject); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &resultObject); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&typesColumnMap, &metaData, "getdatatypes", NULL, 0, &resultObject); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&simpleColumnMap); - if (Z_TYPE_P(&columnMap) == IS_NULL) { - array_init(&simpleColumnMap); - ZEPHIR_CALL_METHOD(&_74$$90, &metaData, "getattributes", NULL, 0, &resultObject); - zephir_check_call_status(); - zephir_is_iterable(&_74$$90, 0, "phalcon/Mvc/Model/Query.zep", 1282); - if (Z_TYPE_P(&_74$$90) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_74$$90), _75$$90) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _75$$90); - ZEPHIR_INIT_NVAR(&_77$$91); - zephir_create_array(&_77$$91, 2, 0); - zephir_array_fast_append(&_77$$91, &attribute); - ZEPHIR_OBS_NVAR(&_78$$91); - zephir_array_fetch(&_78$$91, &typesColumnMap, &attribute, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1280); - zephir_array_fast_append(&_77$$91, &_78$$91); - zephir_array_update_zval(&simpleColumnMap, &attribute, &_77$$91, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_74$$90, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_76$$90, &_74$$90, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_76$$90)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &_74$$90, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_79$$92); - zephir_create_array(&_79$$92, 2, 0); - zephir_array_fast_append(&_79$$92, &attribute); - ZEPHIR_OBS_NVAR(&_80$$92); - zephir_array_fetch(&_80$$92, &typesColumnMap, &attribute, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1280); - zephir_array_fast_append(&_79$$92, &_80$$92); - zephir_array_update_zval(&simpleColumnMap, &attribute, &_79$$92, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &_74$$90, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - } else { - array_init(&simpleColumnMap); - zephir_is_iterable(&columnMap, 0, "phalcon/Mvc/Model/Query.zep", 1291); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columnMap), _83$$93, _84$$93, _81$$93) - { - ZEPHIR_INIT_NVAR(&column); - if (_84$$93 != NULL) { - ZVAL_STR_COPY(&column, _84$$93); - } else { - ZVAL_LONG(&column, _83$$93); - } - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _81$$93); - ZEPHIR_INIT_NVAR(&_85$$94); - zephir_create_array(&_85$$94, 2, 0); - zephir_array_fast_append(&_85$$94, &attribute); - ZEPHIR_OBS_NVAR(&_86$$94); - zephir_array_fetch(&_86$$94, &typesColumnMap, &column, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1289); - zephir_array_fast_append(&_85$$94, &_86$$94); - zephir_array_update_zval(&simpleColumnMap, &column, &_85$$94, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columnMap, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_82$$93, &columnMap, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_82$$93)) { - break; - } - ZEPHIR_CALL_METHOD(&column, &columnMap, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&attribute, &columnMap, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_87$$95); - zephir_create_array(&_87$$95, 2, 0); - zephir_array_fast_append(&_87$$95, &attribute); - ZEPHIR_OBS_NVAR(&_88$$95); - zephir_array_fetch(&_88$$95, &typesColumnMap, &column, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1289); - zephir_array_fast_append(&_87$$95, &_88$$95); - zephir_array_update_zval(&simpleColumnMap, &column, &_87$$95, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &columnMap, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - ZEPHIR_INIT_NVAR(&column); - } - } - ZEPHIR_CALL_METHOD(&_89$$85, &manager, "iskeepingsnapshots", NULL, 0, &resultObject); - zephir_check_call_status(); - isKeepingSnapshots = zephir_get_boolval(&_89$$85); - } - _90$$83 = zephir_instance_of_ev(&resultObject, phalcon_mvc_modelinterface_ce); - if (_90$$83) { - _90$$83 = (zephir_method_exists_ex(&resultObject, ZEND_STRL("getresultsetclass")) == SUCCESS); - } - if (_90$$83) { - ZEPHIR_CALL_METHOD(&resultsetClassName, &resultObject, "getresultsetclass", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&resultsetClassName)) { - if (UNEXPECTED(!(zephir_class_exists(&resultsetClassName, 1)))) { - ZEPHIR_INIT_VAR(&_91$$98); - object_init_ex(&_91$$98, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_92$$98); - ZEPHIR_CONCAT_SVS(&_92$$98, "Resultset class \"", &resultsetClassName, "\" not found"); - ZEPHIR_CALL_METHOD(NULL, &_91$$98, "__construct", NULL, 32, &_92$$98); - zephir_check_call_status(); - zephir_throw_exception_debug(&_91$$98, "phalcon/Mvc/Model/Query.zep", 1307); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_93$$97); - ZVAL_STRING(&_93$$97, "Phalcon\\Mvc\\Model\\ResultsetInterface"); - ZEPHIR_CALL_FUNCTION(&_94$$97, "is_subclass_of", NULL, 439, &resultsetClassName, &_93$$97); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_94$$97))) { - ZEPHIR_INIT_VAR(&_95$$99); - object_init_ex(&_95$$99, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_96$$99); - ZEPHIR_CONCAT_SVS(&_96$$99, "Resultset class \"", &resultsetClassName, "\" must be an implementation of Phalcon\\Mvc\\Model\\ResultsetInterface"); - ZEPHIR_CALL_METHOD(NULL, &_95$$99, "__construct", NULL, 32, &_96$$99); - zephir_check_call_status(); - zephir_throw_exception_debug(&_95$$99, "phalcon/Mvc/Model/Query.zep", 1313); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_97$$97); - zephir_create_array(&_97$$97, 5, 0); - zephir_array_fast_append(&_97$$97, &simpleColumnMap); - zephir_array_fast_append(&_97$$97, &resultObject); - zephir_array_fast_append(&_97$$97, &resultData); - zephir_array_fast_append(&_97$$97, &cache); - ZEPHIR_INIT_NVAR(&_93$$97); - ZVAL_BOOL(&_93$$97, isKeepingSnapshots); - zephir_array_fast_append(&_97$$97, &_93$$97); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &resultsetClassName, &_97$$97); - zephir_check_call_status(); - RETURN_MM(); - } - } - object_init_ex(return_value, phalcon_mvc_model_resultset_simple_ce); - if (isKeepingSnapshots) { - ZVAL_BOOL(&_98$$83, 1); - } else { - ZVAL_BOOL(&_98$$83, 0); - } - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 457, &simpleColumnMap, &resultObject, &resultData, &cache, &_98$$83); - zephir_check_call_status(); - RETURN_MM(); - } - object_init_ex(return_value, phalcon_mvc_model_resultset_complex_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 458, &columns1, &resultData, &cache); +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, getInternalHandler) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "pdo"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, getTransactionLevel) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "transactionLevel"); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, isUnderTransaction) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "intransaction", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeUpdate) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, lastInsertId) { - zend_string *_5; - zend_ulong _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_14 = NULL, *_16 = NULL, *_17 = NULL, *_19 = NULL, *_21 = NULL, *_27 = NULL, *_30 = NULL, *_32 = NULL, *_34 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, models, modelName, model, connection, dialect, fields, values, updateValues, fieldName, value, selectBindParams, selectBindTypes, number, field, records, exprValue, updateValue, wildcard, record, _0, *_2, _3, _29, _35, _1$$4, _6$$5, _8$$10, _10$$10, _11$$10, _12$$11, _13$$11, _15$$13, _18$$14, _20$$19, _22$$19, _23$$19, _24$$20, _25$$20, _26$$22, _28$$23, _31$$24, _33$$25; - zval intermediate, bindParams, bindTypes; + zval *name_param = NULL, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&updateValues); - ZVAL_UNDEF(&fieldName); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&selectBindParams); - ZVAL_UNDEF(&selectBindTypes); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&updateValue); - ZVAL_UNDEF(&wildcard); - ZVAL_UNDEF(&record); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_29); - ZVAL_UNDEF(&_35); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_18$$14); - ZVAL_UNDEF(&_20$$19); - ZVAL_UNDEF(&_22$$19); - ZVAL_UNDEF(&_23$$19); - ZVAL_UNDEF(&_24$$20); - ZVAL_UNDEF(&_25$$20); - ZVAL_UNDEF(&_26$$22); - ZVAL_UNDEF(&_28$$23); - ZVAL_UNDEF(&_31$$24); - ZVAL_UNDEF(&_33$$25); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - - - ZEPHIR_OBS_VAR(&models); - zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1361); - if (UNEXPECTED(zephir_array_isset_long(&models, 1))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Updating several models at the same time is still not supported", "phalcon/Mvc/Model/Query.zep", 1366); - return; - } - ZEPHIR_OBS_VAR(&modelName); - zephir_array_fetch_long(&modelName, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1369); - ZEPHIR_OBS_VAR(&model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&model, &_1$$4, "load", NULL, 0, &modelName); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&fields); - zephir_array_fetch_string(&fields, &intermediate, SL("fields"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1388); - ZEPHIR_OBS_VAR(&values); - zephir_array_fetch_string(&values, &intermediate, SL("values"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1389); - ZEPHIR_INIT_VAR(&updateValues); - array_init(&updateValues); - ZEPHIR_CPY_WRT(&selectBindParams, &bindParams); - ZEPHIR_CPY_WRT(&selectBindTypes, &bindTypes); - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 1461); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&number); - if (_5 != NULL) { - ZVAL_STR_COPY(&number, _5); - } else { - ZVAL_LONG(&number, _4); - } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _2); - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &values, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1404); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1405); - if (zephir_array_isset_string(&field, SL("balias"))) { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1408); - } else { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1410); - } - zephir_array_fetch_string(&_6$$5, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1413); - do { - if (ZEPHIR_IS_LONG(&_6$$5, 260) || ZEPHIR_IS_LONG(&_6$$5, 258) || ZEPHIR_IS_LONG(&_6$$5, 259)) { - ZEPHIR_CALL_METHOD(&updateValue, &dialect, "getsqlexpression", &_7, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_6$$5, 322)) { - ZEPHIR_INIT_NVAR(&updateValue); - ZVAL_NULL(&updateValue); - break; - } - if (ZEPHIR_IS_LONG(&_6$$5, 273) || ZEPHIR_IS_LONG(&_6$$5, 274) || ZEPHIR_IS_LONG(&_6$$5, 277)) { - ZEPHIR_CALL_METHOD(&_8$$10, &dialect, "getsqlexpression", &_9, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$10); - ZVAL_STRING(&_10$$10, ":"); - ZEPHIR_INIT_NVAR(&_11$$10); - ZVAL_STRING(&_11$$10, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_10$$10, &_11$$10, &_8$$10); - ZEPHIR_OBS_NVAR(&updateValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&updateValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_12$$11); - object_init_ex(&_12$$11, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_13$$11); - ZEPHIR_CONCAT_SVS(&_13$$11, "Bound parameter '", &wildcard, "' cannot be replaced because it's not in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", &_14, 32, &_13$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$11, "phalcon/Mvc/Model/Query.zep", 1436); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_unset(&selectBindParams, &wildcard, PH_SEPARATE); - zephir_array_unset(&selectBindTypes, &wildcard, PH_SEPARATE); - break; - } - if (ZEPHIR_IS_LONG(&_6$$5, 277)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Query.zep", 1445); - return; - } - ZEPHIR_INIT_NVAR(&updateValue); - object_init_ex(&updateValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_15$$13, &dialect, "getsqlexpression", &_16, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &updateValue, "__construct", &_17, 35, &_15$$13); - zephir_check_call_status(); - break; - } while(0); - - zephir_array_update_zval(&updateValues, &fieldName, &updateValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&number, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &values, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1404); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1405); - if (zephir_array_isset_string(&field, SL("balias"))) { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1408); - } else { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1410); - } - zephir_array_fetch_string(&_18$$14, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1413); - do { - if (ZEPHIR_IS_LONG(&_18$$14, 260) || ZEPHIR_IS_LONG(&_18$$14, 258) || ZEPHIR_IS_LONG(&_18$$14, 259)) { - ZEPHIR_CALL_METHOD(&updateValue, &dialect, "getsqlexpression", &_19, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_18$$14, 322)) { - ZEPHIR_INIT_NVAR(&updateValue); - ZVAL_NULL(&updateValue); - break; - } - if (ZEPHIR_IS_LONG(&_18$$14, 273) || ZEPHIR_IS_LONG(&_18$$14, 274) || ZEPHIR_IS_LONG(&_18$$14, 277)) { - ZEPHIR_CALL_METHOD(&_20$$19, &dialect, "getsqlexpression", &_21, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_22$$19); - ZVAL_STRING(&_22$$19, ":"); - ZEPHIR_INIT_NVAR(&_23$$19); - ZVAL_STRING(&_23$$19, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_22$$19, &_23$$19, &_20$$19); - ZEPHIR_OBS_NVAR(&updateValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&updateValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_24$$20); - object_init_ex(&_24$$20, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_25$$20); - ZEPHIR_CONCAT_SVS(&_25$$20, "Bound parameter '", &wildcard, "' cannot be replaced because it's not in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_24$$20, "__construct", &_14, 32, &_25$$20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_24$$20, "phalcon/Mvc/Model/Query.zep", 1436); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_unset(&selectBindParams, &wildcard, PH_SEPARATE); - zephir_array_unset(&selectBindTypes, &wildcard, PH_SEPARATE); - break; - } - if (ZEPHIR_IS_LONG(&_18$$14, 277)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Query.zep", 1445); - return; - } - ZEPHIR_INIT_NVAR(&updateValue); - object_init_ex(&updateValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_26$$22, &dialect, "getsqlexpression", &_27, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &updateValue, "__construct", &_17, 35, &_26$$22); - zephir_check_call_status(); - break; - } while(0); - - zephir_array_update_zval(&updateValues, &fieldName, &updateValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); - } + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&number); - ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 455, &model, &intermediate, &selectBindParams, &selectBindTypes); - zephir_check_call_status(); - if (!(zephir_fast_count_int(&records))) { - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_28$$23, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_28$$23); - zephir_check_call_status(); - RETURN_MM(); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_29, &records, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_29))) { - break; - } - ZEPHIR_CALL_METHOD(&record, &records, "current", &_30, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &record, "assign", NULL, 0, &updateValues); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_31$$24, &record, "update", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_31$$24))) { - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", &_32, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_33$$25, 0); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_33$$25, &record); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &records, "next", &_34, 0); - zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_35, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &_35); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "lastinsertid", NULL, 0, &name); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCallArgument) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, prepare) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *argument_param = NULL, _0; - zval argument; + zval *sqlStatement_param = NULL, _0; + zval sqlStatement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&sqlStatement); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(argument) + Z_PARAM_STR(sqlStatement) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &argument_param); - ZEPHIR_OBS_COPY_OR_DUP(&argument, argument_param); + zephir_fetch_params(1, 1, 0, &sqlStatement_param); + if (UNEXPECTED(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { + zephir_get_strval(&sqlStatement, sqlStatement_param); + } else { + ZEPHIR_INIT_VAR(&sqlStatement); + } - zephir_array_fetch_string(&_0, &argument, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1523); - if (ZEPHIR_IS_LONG(&_0, 352)) { - zephir_create_array(return_value, 1, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("all")); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getexpression", NULL, 459, &argument); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "prepare", NULL, 0, &sqlStatement); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCaseExpression) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, query) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, whenClauses, whenExpr, _0, *_1, _2, _18, _19, _4$$4, _5$$4, _7$$4, _9$$5, _10$$5, _12$$7, _13$$7, _14$$7, _16$$8, _17$$8; - zval expr, _3$$4, _8$$5, _11$$7, _15$$8; + zval bindParams, bindTypes; + zval *sqlStatement_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, eventsManager, statement, params, types, _0, _3, _1$$3, _2$$3, _4$$9; + zval sqlStatement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_15$$8); - ZVAL_UNDEF(&whenClauses); - ZVAL_UNDEF(&whenExpr); + ZVAL_UNDEF(&sqlStatement); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&types); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$7); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_16$$8); - ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(sqlStatement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); + zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { + zephir_get_strval(&sqlStatement, sqlStatement_param); + } else { + ZEPHIR_INIT_VAR(&sqlStatement); + } + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); + } + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); + } - ZEPHIR_INIT_VAR(&whenClauses); - array_init(&whenClauses); - zephir_array_fetch_string(&_0, &expr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1541); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model/Query.zep", 1556); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&whenExpr); - ZVAL_COPY(&whenExpr, _1); - if (zephir_array_isset_string(&whenExpr, SL("right"))) { - ZEPHIR_INIT_NVAR(&_3$$4); - zephir_create_array(&_3$$4, 3, 0); - add_assoc_stringl_ex(&_3$$4, SL("type"), SL("when")); - zephir_array_fetch_string(&_5$$4, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1545); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "getexpression", &_6, 459, &_5$$4); - zephir_check_call_status(); - zephir_array_update_string(&_3$$4, SL("expr"), &_4$$4, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_7$$4, &whenExpr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1546); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "getexpression", &_6, 459, &_7$$4); - zephir_check_call_status(); - zephir_array_update_string(&_3$$4, SL("then"), &_4$$4, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_3$$4, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1547); - } else { - ZEPHIR_INIT_NVAR(&_8$$5); - zephir_create_array(&_8$$5, 2, 0); - add_assoc_stringl_ex(&_8$$5, SL("type"), SL("else")); - zephir_array_fetch_string(&_10$$5, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1551); - ZEPHIR_CALL_METHOD(&_9$$5, this_ptr, "getexpression", &_6, 459, &_10$$5); - zephir_check_call_status(); - zephir_array_update_string(&_8$$5, SL("expr"), &_9$$5, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_8$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1552); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlStatement"), &sqlStatement); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlVariables"), &bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlBindTypes"), &bindTypes); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "db:beforeQuery"); + ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&whenExpr, &_0, "current", NULL, 0); - zephir_check_call_status(); - if (zephir_array_isset_string(&whenExpr, SL("right"))) { - ZEPHIR_INIT_NVAR(&_11$$7); - zephir_create_array(&_11$$7, 3, 0); - add_assoc_stringl_ex(&_11$$7, SL("type"), SL("when")); - zephir_array_fetch_string(&_13$$7, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1545); - ZEPHIR_CALL_METHOD(&_12$$7, this_ptr, "getexpression", &_6, 459, &_13$$7); - zephir_check_call_status(); - zephir_array_update_string(&_11$$7, SL("expr"), &_12$$7, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_14$$7, &whenExpr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1546); - ZEPHIR_CALL_METHOD(&_12$$7, this_ptr, "getexpression", &_6, 459, &_14$$7); - zephir_check_call_status(); - zephir_array_update_string(&_11$$7, SL("then"), &_12$$7, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_11$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1547); - } else { - ZEPHIR_INIT_NVAR(&_15$$8); - zephir_create_array(&_15$$8, 2, 0); - add_assoc_stringl_ex(&_15$$8, SL("type"), SL("else")); - zephir_array_fetch_string(&_17$$8, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1551); - ZEPHIR_CALL_METHOD(&_16$$8, this_ptr, "getexpression", &_6, 459, &_17$$8); - zephir_check_call_status(); - zephir_array_update_string(&_15$$8, SL("expr"), &_16$$8, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_15$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1552); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_BOOL(0); } } - ZEPHIR_INIT_NVAR(&whenExpr); - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("case")); - zephir_array_fetch_string(&_19, &expr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1558); - ZEPHIR_CALL_METHOD(&_18, this_ptr, "getexpression", &_6, 459, &_19); + if (!(ZEPHIR_IS_EMPTY(&bindParams))) { + ZEPHIR_CPY_WRT(¶ms, &bindParams); + ZEPHIR_CPY_WRT(&types, &bindTypes); + } else { + ZEPHIR_INIT_NVAR(¶ms); + array_init(¶ms); + ZEPHIR_INIT_NVAR(&types); + array_init(&types); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&statement, &_0, "prepare", NULL, 0, &sqlStatement); zephir_check_call_status(); - zephir_array_update_string(return_value, SL("expr"), &_18, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("when-clauses"), &whenClauses, PH_COPY | PH_SEPARATE); - RETURN_MM(); + if (UNEXPECTED(Z_TYPE_P(&statement) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Cannot prepare statement", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 717); + return; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "preparerealsql", NULL, 0, &sqlStatement, &bindParams); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "executeprepared", NULL, 0, &statement, ¶ms, &types); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&statement, &_3); + if (Z_TYPE_P(&statement) == IS_OBJECT) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_4$$9); + ZVAL_STRING(&_4$$9, "db:afterQuery"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_4$$9, this_ptr); + zephir_check_call_status(); + } + object_init_ex(return_value, phalcon_db_result_pdoresult_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 42, this_ptr, &statement, &sqlStatement, &bindParams, &bindTypes); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_CCTOR(&statement); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getExpression) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, rollback) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool quoting, tempNotQuoting = 0; - zval *expr_param = NULL, *quoting_param = NULL, exprType, exprLeft, exprRight, left, right, listItems, exprListItem, exprReturn, value, escapedValue, exprValue, valueParts, name, bindType, bind, _0$$5, _1$$6, _2$$8, _3$$9, _4$$10, _5$$11, _6$$12, _7$$13, _8$$14, _9$$16, _10$$17, _11$$18, _12$$19, _13$$20, _14$$21, _15$$22, _16$$23, _17$$24, _18$$25, _19$$25, _20$$26, _21$$27, _22$$28, _23$$33, _24$$33, _25$$33, _26$$33, _27$$33, _28$$34, _29$$34, _30$$34, _31$$37, _32$$37, _33$$37, _34$$38, _35$$38, _36$$38, _37$$39, _38$$39, _39$$39, _40$$40, _41$$40, _42$$40, _43$$41, _44$$41, _45$$41, _46$$42, _47$$42, _48$$42, _49$$43, _56$$43, _57$$43, _50$$44, _51$$44, _52$$45, _53$$45, _54$$46, _55$$46, _58$$47, _59$$47, _60$$48, _61$$48, _62$$49, _63$$50, _64$$51, _65$$52, _66$$53, _67$$54, _68$$55, _69$$56, _70$$57, _71$$58, _72$$59, _73$$60, _74$$61, _75$$62, _76$$63, _77$$64, _78$$65, _79$$66, _80$$66, _81$$69, _82$$69, _83$$69, _84$$70, _85$$70, *_86$$72, _87$$72, _88$$73, _89$$74; - zval expr; + zval *nesting_param = NULL, eventsManager, savepointName, _0, _1, _4, _7, _9, _2$$4, _3$$5, _8$$6, _10$$8; + zend_bool nesting, _5, _6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&exprType); - ZVAL_UNDEF(&exprLeft); - ZVAL_UNDEF(&exprRight); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); - ZVAL_UNDEF(&listItems); - ZVAL_UNDEF(&exprListItem); - ZVAL_UNDEF(&exprReturn); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&escapedValue); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&valueParts); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&bindType); - ZVAL_UNDEF(&bind); - ZVAL_UNDEF(&_0$$5); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_2$$8); - ZVAL_UNDEF(&_3$$9); - ZVAL_UNDEF(&_4$$10); - ZVAL_UNDEF(&_5$$11); - ZVAL_UNDEF(&_6$$12); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_9$$16); - ZVAL_UNDEF(&_10$$17); - ZVAL_UNDEF(&_11$$18); - ZVAL_UNDEF(&_12$$19); - ZVAL_UNDEF(&_13$$20); - ZVAL_UNDEF(&_14$$21); - ZVAL_UNDEF(&_15$$22); - ZVAL_UNDEF(&_16$$23); - ZVAL_UNDEF(&_17$$24); - ZVAL_UNDEF(&_18$$25); - ZVAL_UNDEF(&_19$$25); - ZVAL_UNDEF(&_20$$26); - ZVAL_UNDEF(&_21$$27); - ZVAL_UNDEF(&_22$$28); - ZVAL_UNDEF(&_23$$33); - ZVAL_UNDEF(&_24$$33); - ZVAL_UNDEF(&_25$$33); - ZVAL_UNDEF(&_26$$33); - ZVAL_UNDEF(&_27$$33); - ZVAL_UNDEF(&_28$$34); - ZVAL_UNDEF(&_29$$34); - ZVAL_UNDEF(&_30$$34); - ZVAL_UNDEF(&_31$$37); - ZVAL_UNDEF(&_32$$37); - ZVAL_UNDEF(&_33$$37); - ZVAL_UNDEF(&_34$$38); - ZVAL_UNDEF(&_35$$38); - ZVAL_UNDEF(&_36$$38); - ZVAL_UNDEF(&_37$$39); - ZVAL_UNDEF(&_38$$39); - ZVAL_UNDEF(&_39$$39); - ZVAL_UNDEF(&_40$$40); - ZVAL_UNDEF(&_41$$40); - ZVAL_UNDEF(&_42$$40); - ZVAL_UNDEF(&_43$$41); - ZVAL_UNDEF(&_44$$41); - ZVAL_UNDEF(&_45$$41); - ZVAL_UNDEF(&_46$$42); - ZVAL_UNDEF(&_47$$42); - ZVAL_UNDEF(&_48$$42); - ZVAL_UNDEF(&_49$$43); - ZVAL_UNDEF(&_56$$43); - ZVAL_UNDEF(&_57$$43); - ZVAL_UNDEF(&_50$$44); - ZVAL_UNDEF(&_51$$44); - ZVAL_UNDEF(&_52$$45); - ZVAL_UNDEF(&_53$$45); - ZVAL_UNDEF(&_54$$46); - ZVAL_UNDEF(&_55$$46); - ZVAL_UNDEF(&_58$$47); - ZVAL_UNDEF(&_59$$47); - ZVAL_UNDEF(&_60$$48); - ZVAL_UNDEF(&_61$$48); - ZVAL_UNDEF(&_62$$49); - ZVAL_UNDEF(&_63$$50); - ZVAL_UNDEF(&_64$$51); - ZVAL_UNDEF(&_65$$52); - ZVAL_UNDEF(&_66$$53); - ZVAL_UNDEF(&_67$$54); - ZVAL_UNDEF(&_68$$55); - ZVAL_UNDEF(&_69$$56); - ZVAL_UNDEF(&_70$$57); - ZVAL_UNDEF(&_71$$58); - ZVAL_UNDEF(&_72$$59); - ZVAL_UNDEF(&_73$$60); - ZVAL_UNDEF(&_74$$61); - ZVAL_UNDEF(&_75$$62); - ZVAL_UNDEF(&_76$$63); - ZVAL_UNDEF(&_77$$64); - ZVAL_UNDEF(&_78$$65); - ZVAL_UNDEF(&_79$$66); - ZVAL_UNDEF(&_80$$66); - ZVAL_UNDEF(&_81$$69); - ZVAL_UNDEF(&_82$$69); - ZVAL_UNDEF(&_83$$69); - ZVAL_UNDEF(&_84$$70); - ZVAL_UNDEF(&_85$$70); - ZVAL_UNDEF(&_87$$72); - ZVAL_UNDEF(&_88$$73); - ZVAL_UNDEF(&_89$$74); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&savepointName); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$8); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(expr) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(quoting) + Z_PARAM_BOOL(nesting) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &expr_param, "ing_param); - zephir_get_arrval(&expr, expr_param); - if (!quoting_param) { - quoting = 1; + zephir_fetch_params(1, 0, 1, &nesting_param); + if (!nesting_param) { + nesting = 1; } else { - quoting = zephir_get_boolval(quoting_param); + nesting = zephir_get_boolval(nesting_param); } - ZEPHIR_INIT_VAR(&left); - ZVAL_NULL(&left); - ZEPHIR_INIT_VAR(&right); - ZVAL_NULL(&right); - ZEPHIR_OBS_VAR(&exprType); - if (zephir_array_isset_string_fetch(&exprType, &expr, SL("type"), 0)) { - tempNotQuoting = 1; - if (!ZEPHIR_IS_LONG(&exprType, 409)) { - ZEPHIR_OBS_VAR(&exprLeft); - if (zephir_array_isset_string_fetch(&exprLeft, &expr, SL("left"), 0)) { - if (tempNotQuoting) { - ZVAL_BOOL(&_0$$5, 1); - } else { - ZVAL_BOOL(&_0$$5, 0); - } - ZEPHIR_CALL_METHOD(&left, this_ptr, "getexpression", NULL, 459, &exprLeft, &_0$$5); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&exprRight); - if (zephir_array_isset_string_fetch(&exprRight, &expr, SL("right"), 0)) { - if (tempNotQuoting) { - ZVAL_BOOL(&_1$$6, 1); - } else { - ZVAL_BOOL(&_1$$6, 0); - } - ZEPHIR_CALL_METHOD(&right, this_ptr, "getexpression", NULL, 459, &exprRight, &_1$$6); - zephir_check_call_status(); - } - } - do { - if (ZEPHIR_IS_LONG(&exprType, '<')) { - ZEPHIR_INIT_VAR(&exprReturn); - zephir_create_array(&exprReturn, 4, 0); - add_assoc_stringl_ex(&exprReturn, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&exprReturn, SL("op"), SL("<")); - zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '=')) { - ZEPHIR_INIT_VAR(&_2$$8); - zephir_create_array(&_2$$8, 4, 0); - add_assoc_stringl_ex(&_2$$8, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_2$$8, SL("op"), SL("=")); - zephir_array_update_string(&_2$$8, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_2$$8, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_2$$8); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '>')) { - ZEPHIR_INIT_VAR(&_3$$9); - zephir_create_array(&_3$$9, 4, 0); - add_assoc_stringl_ex(&_3$$9, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_3$$9, SL("op"), SL(">")); - zephir_array_update_string(&_3$$9, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_3$$9, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_3$$9); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 270)) { - ZEPHIR_INIT_VAR(&_4$$10); - zephir_create_array(&_4$$10, 4, 0); - add_assoc_stringl_ex(&_4$$10, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_4$$10, SL("op"), SL("<>")); - zephir_array_update_string(&_4$$10, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4$$10, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_4$$10); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 271)) { - ZEPHIR_INIT_VAR(&_5$$11); - zephir_create_array(&_5$$11, 4, 0); - add_assoc_stringl_ex(&_5$$11, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_5$$11, SL("op"), SL("<=")); - zephir_array_update_string(&_5$$11, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_5$$11, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_5$$11); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 272)) { - ZEPHIR_INIT_VAR(&_6$$12); - zephir_create_array(&_6$$12, 4, 0); - add_assoc_stringl_ex(&_6$$12, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_6$$12, SL("op"), SL(">=")); - zephir_array_update_string(&_6$$12, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_6$$12, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_6$$12); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 266)) { - ZEPHIR_INIT_VAR(&_7$$13); - zephir_create_array(&_7$$13, 4, 0); - add_assoc_stringl_ex(&_7$$13, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_7$$13, SL("op"), SL("AND")); - zephir_array_update_string(&_7$$13, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_7$$13, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_7$$13); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 267)) { - ZEPHIR_INIT_VAR(&_8$$14); - zephir_create_array(&_8$$14, 4, 0); - add_assoc_stringl_ex(&_8$$14, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_8$$14, SL("op"), SL("OR")); - zephir_array_update_string(&_8$$14, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_8$$14, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_8$$14); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 355)) { - ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getqualified", NULL, 460, &expr); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '+')) { - ZEPHIR_INIT_VAR(&_9$$16); - zephir_create_array(&_9$$16, 4, 0); - add_assoc_stringl_ex(&_9$$16, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_9$$16, SL("op"), SL("+")); - zephir_array_update_string(&_9$$16, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_9$$16, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_9$$16); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '-')) { - ZEPHIR_INIT_VAR(&_10$$17); - zephir_create_array(&_10$$17, 4, 0); - add_assoc_stringl_ex(&_10$$17, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_10$$17, SL("op"), SL("-")); - zephir_array_update_string(&_10$$17, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10$$17, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_10$$17); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '*')) { - ZEPHIR_INIT_VAR(&_11$$18); - zephir_create_array(&_11$$18, 4, 0); - add_assoc_stringl_ex(&_11$$18, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_11$$18, SL("op"), SL("*")); - zephir_array_update_string(&_11$$18, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_11$$18, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_11$$18); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '/')) { - ZEPHIR_INIT_VAR(&_12$$19); - zephir_create_array(&_12$$19, 4, 0); - add_assoc_stringl_ex(&_12$$19, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_12$$19, SL("op"), SL("/")); - zephir_array_update_string(&_12$$19, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_12$$19, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_12$$19); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '%')) { - ZEPHIR_INIT_VAR(&_13$$20); - zephir_create_array(&_13$$20, 4, 0); - add_assoc_stringl_ex(&_13$$20, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_13$$20, SL("op"), SL("%")); - zephir_array_update_string(&_13$$20, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_13$$20, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_13$$20); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '&')) { - ZEPHIR_INIT_VAR(&_14$$21); - zephir_create_array(&_14$$21, 4, 0); - add_assoc_stringl_ex(&_14$$21, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_14$$21, SL("op"), SL("&")); - zephir_array_update_string(&_14$$21, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_14$$21, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_14$$21); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '|')) { - ZEPHIR_INIT_VAR(&_15$$22); - zephir_create_array(&_15$$22, 4, 0); - add_assoc_stringl_ex(&_15$$22, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_15$$22, SL("op"), SL("|")); - zephir_array_update_string(&_15$$22, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$22, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_15$$22); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 356) || ZEPHIR_IS_LONG(&exprType, 407)) { - ZEPHIR_INIT_VAR(&_16$$23); - zephir_create_array(&_16$$23, 2, 0); - add_assoc_stringl_ex(&_16$$23, SL("type"), SL("parentheses")); - zephir_array_update_string(&_16$$23, SL("left"), &left, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_16$$23); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 367)) { - ZEPHIR_INIT_VAR(&_17$$24); - zephir_create_array(&_17$$24, 3, 0); - add_assoc_stringl_ex(&_17$$24, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_17$$24, SL("op"), SL("-")); - zephir_array_update_string(&_17$$24, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_17$$24); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 258) || ZEPHIR_IS_LONG(&exprType, 259) || ZEPHIR_IS_LONG(&exprType, 414)) { - ZEPHIR_INIT_VAR(&_18$$25); - zephir_create_array(&_18$$25, 2, 0); - add_assoc_stringl_ex(&_18$$25, SL("type"), SL("literal")); - ZEPHIR_OBS_VAR(&_19$$25); - zephir_array_fetch_string(&_19$$25, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1774); - zephir_array_update_string(&_18$$25, SL("value"), &_19$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_18$$25); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 334)) { - ZEPHIR_INIT_VAR(&_20$$26); - zephir_create_array(&_20$$26, 2, 0); - add_assoc_stringl_ex(&_20$$26, SL("type"), SL("literal")); - add_assoc_stringl_ex(&_20$$26, SL("value"), SL("TRUE")); - ZEPHIR_CPY_WRT(&exprReturn, &_20$$26); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 335)) { - ZEPHIR_INIT_VAR(&_21$$27); - zephir_create_array(&_21$$27, 2, 0); - add_assoc_stringl_ex(&_21$$27, SL("type"), SL("literal")); - add_assoc_stringl_ex(&_21$$27, SL("value"), SL("FALSE")); - ZEPHIR_CPY_WRT(&exprReturn, &_21$$27); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 260)) { - ZEPHIR_OBS_VAR(&value); - zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1795); - if (quoting) { - if (zephir_memnstr_str(&value, SL("'"), "phalcon/Mvc/Model/Query.zep", 1802)) { - ZEPHIR_INIT_VAR(&escapedValue); - phalcon_orm_singlequotes(&escapedValue, &value); - } else { - ZEPHIR_CPY_WRT(&escapedValue, &value); - } - ZEPHIR_INIT_VAR(&exprValue); - ZEPHIR_CONCAT_SVS(&exprValue, "'", &escapedValue, "'"); - } else { - ZEPHIR_CPY_WRT(&exprValue, &value); - } - ZEPHIR_INIT_VAR(&_22$$28); - zephir_create_array(&_22$$28, 2, 0); - add_assoc_stringl_ex(&_22$$28, SL("type"), SL("literal")); - zephir_array_update_string(&_22$$28, SL("value"), &exprValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_22$$28); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 273)) { - ZEPHIR_INIT_VAR(&_23$$33); - zephir_create_array(&_23$$33, 2, 0); - add_assoc_stringl_ex(&_23$$33, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_24$$33); - zephir_array_fetch_string(&_25$$33, &expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1823); - ZEPHIR_INIT_VAR(&_26$$33); - ZVAL_STRING(&_26$$33, "?"); - ZEPHIR_INIT_VAR(&_27$$33); - ZVAL_STRING(&_27$$33, ":"); - zephir_fast_str_replace(&_24$$33, &_26$$33, &_27$$33, &_25$$33); - zephir_array_update_string(&_23$$33, SL("value"), &_24$$33, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_23$$33); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 274)) { - ZEPHIR_INIT_VAR(&_28$$34); - zephir_create_array(&_28$$34, 2, 0); - add_assoc_stringl_ex(&_28$$34, SL("type"), SL("placeholder")); - zephir_array_fetch_string(&_29$$34, &expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1832); - ZEPHIR_INIT_VAR(&_30$$34); - ZEPHIR_CONCAT_SV(&_30$$34, ":", &_29$$34); - zephir_array_update_string(&_28$$34, SL("value"), &_30$$34, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_28$$34); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 277)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1837); - if (zephir_memnstr_str(&value, SL(":"), "phalcon/Mvc/Model/Query.zep", 1839)) { - ZEPHIR_INIT_VAR(&valueParts); - zephir_fast_explode_str(&valueParts, SL(":"), &value, LONG_MAX); - ZEPHIR_OBS_VAR(&name); - zephir_array_fetch_long(&name, &valueParts, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1841); - ZEPHIR_OBS_VAR(&bindType); - zephir_array_fetch_long(&bindType, &valueParts, 1, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1842); - do { - if (ZEPHIR_IS_STRING(&bindType, "str")) { - ZEPHIR_INIT_VAR(&_31$$37); - ZVAL_LONG(&_31$$37, 2); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_31$$37); - ZEPHIR_INIT_VAR(&_32$$37); - zephir_create_array(&_32$$37, 2, 0); - add_assoc_stringl_ex(&_32$$37, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_33$$37); - ZEPHIR_CONCAT_SV(&_33$$37, ":", &name); - zephir_array_update_string(&_32$$37, SL("value"), &_33$$37, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_32$$37); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "int")) { - ZEPHIR_INIT_VAR(&_34$$38); - ZVAL_LONG(&_34$$38, 1); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_34$$38); - ZEPHIR_INIT_VAR(&_35$$38); - zephir_create_array(&_35$$38, 2, 0); - add_assoc_stringl_ex(&_35$$38, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_36$$38); - ZEPHIR_CONCAT_SV(&_36$$38, ":", &name); - zephir_array_update_string(&_35$$38, SL("value"), &_36$$38, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_35$$38); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "double")) { - ZEPHIR_INIT_VAR(&_37$$39); - ZVAL_LONG(&_37$$39, 32); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_37$$39); - ZEPHIR_INIT_VAR(&_38$$39); - zephir_create_array(&_38$$39, 2, 0); - add_assoc_stringl_ex(&_38$$39, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_39$$39); - ZEPHIR_CONCAT_SV(&_39$$39, ":", &name); - zephir_array_update_string(&_38$$39, SL("value"), &_39$$39, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_38$$39); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "bool")) { - ZEPHIR_INIT_VAR(&_40$$40); - ZVAL_LONG(&_40$$40, 5); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_40$$40); - ZEPHIR_INIT_VAR(&_41$$40); - zephir_create_array(&_41$$40, 2, 0); - add_assoc_stringl_ex(&_41$$40, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_42$$40); - ZEPHIR_CONCAT_SV(&_42$$40, ":", &name); - zephir_array_update_string(&_41$$40, SL("value"), &_42$$40, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_41$$40); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "blob")) { - ZEPHIR_INIT_VAR(&_43$$41); - ZVAL_LONG(&_43$$41, 3); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_43$$41); - ZEPHIR_INIT_VAR(&_44$$41); - zephir_create_array(&_44$$41, 2, 0); - add_assoc_stringl_ex(&_44$$41, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_45$$41); - ZEPHIR_CONCAT_SV(&_45$$41, ":", &name); - zephir_array_update_string(&_44$$41, SL("value"), &_45$$41, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_44$$41); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "null")) { - ZEPHIR_INIT_VAR(&_46$$42); - ZVAL_LONG(&_46$$42, 0); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_46$$42); - ZEPHIR_INIT_VAR(&_47$$42); - zephir_create_array(&_47$$42, 2, 0); - add_assoc_stringl_ex(&_47$$42, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_48$$42); - ZEPHIR_CONCAT_SV(&_48$$42, ":", &name); - zephir_array_update_string(&_47$$42, SL("value"), &_48$$42, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_47$$42); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "array") || ZEPHIR_IS_STRING(&bindType, "array-str") || ZEPHIR_IS_STRING(&bindType, "array-int")) { - ZEPHIR_OBS_VAR(&bind); - zephir_read_property(&_49$$43, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bind, &_49$$43, &name, 0)))) { - ZEPHIR_INIT_VAR(&_50$$44); - object_init_ex(&_50$$44, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_51$$44); - ZEPHIR_CONCAT_SV(&_51$$44, "Bind value is required for array type placeholder: ", &name); - ZEPHIR_CALL_METHOD(NULL, &_50$$44, "__construct", NULL, 32, &_51$$44); - zephir_check_call_status(); - zephir_throw_exception_debug(&_50$$44, "phalcon/Mvc/Model/Query.zep", 1912); - ZEPHIR_MM_RESTORE(); - return; - } - if (UNEXPECTED(Z_TYPE_P(&bind) != IS_ARRAY)) { - ZEPHIR_INIT_VAR(&_52$$45); - object_init_ex(&_52$$45, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_53$$45); - ZEPHIR_CONCAT_SV(&_53$$45, "Bind type requires an array in placeholder: ", &name); - ZEPHIR_CALL_METHOD(NULL, &_52$$45, "__construct", NULL, 32, &_53$$45); - zephir_check_call_status(); - zephir_throw_exception_debug(&_52$$45, "phalcon/Mvc/Model/Query.zep", 1918); - ZEPHIR_MM_RESTORE(); - return; - } - if (UNEXPECTED(zephir_fast_count_int(&bind) < 1)) { - ZEPHIR_INIT_VAR(&_54$$46); - object_init_ex(&_54$$46, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_55$$46); - ZEPHIR_CONCAT_SV(&_55$$46, "At least one value must be bound in placeholder: ", &name); - ZEPHIR_CALL_METHOD(NULL, &_54$$46, "__construct", NULL, 32, &_55$$46); - zephir_check_call_status(); - zephir_throw_exception_debug(&_54$$46, "phalcon/Mvc/Model/Query.zep", 1924); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_56$$43); - zephir_create_array(&_56$$43, 4, 0); - add_assoc_stringl_ex(&_56$$43, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_57$$43); - ZEPHIR_CONCAT_SV(&_57$$43, ":", &name); - zephir_array_update_string(&_56$$43, SL("value"), &_57$$43, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_56$$43, SL("rawValue"), &name, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(&_56$$43, SL("times"), zephir_fast_count_int(&bind)); - ZEPHIR_CPY_WRT(&exprReturn, &_56$$43); - break; - } - ZEPHIR_INIT_VAR(&_58$$47); - object_init_ex(&_58$$47, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_59$$47); - ZEPHIR_CONCAT_SV(&_59$$47, "Unknown bind type: ", &bindType); - ZEPHIR_CALL_METHOD(NULL, &_58$$47, "__construct", NULL, 32, &_59$$47); - zephir_check_call_status(); - zephir_throw_exception_debug(&_58$$47, "phalcon/Mvc/Model/Query.zep", 1939); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - } else { - ZEPHIR_INIT_VAR(&_60$$48); - zephir_create_array(&_60$$48, 2, 0); - add_assoc_stringl_ex(&_60$$48, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_61$$48); - ZEPHIR_CONCAT_SV(&_61$$48, ":", &value); - zephir_array_update_string(&_60$$48, SL("value"), &_61$$48, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_60$$48); - } - break; - } - if (ZEPHIR_IS_LONG(&exprType, 322)) { - ZEPHIR_INIT_VAR(&_62$$49); - zephir_create_array(&_62$$49, 2, 0); - add_assoc_stringl_ex(&_62$$49, SL("type"), SL("literal")); - add_assoc_stringl_ex(&_62$$49, SL("value"), SL("NULL")); - ZEPHIR_CPY_WRT(&exprReturn, &_62$$49); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 268)) { - ZEPHIR_INIT_VAR(&_63$$50); - zephir_create_array(&_63$$50, 4, 0); - add_assoc_stringl_ex(&_63$$50, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_63$$50, SL("op"), SL("LIKE")); - zephir_array_update_string(&_63$$50, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_63$$50, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_63$$50); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 351)) { - ZEPHIR_INIT_VAR(&_64$$51); - zephir_create_array(&_64$$51, 4, 0); - add_assoc_stringl_ex(&_64$$51, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_64$$51, SL("op"), SL("NOT LIKE")); - zephir_array_update_string(&_64$$51, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_64$$51, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_64$$51); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 275)) { - ZEPHIR_INIT_VAR(&_65$$52); - zephir_create_array(&_65$$52, 4, 0); - add_assoc_stringl_ex(&_65$$52, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_65$$52, SL("op"), SL("ILIKE")); - zephir_array_update_string(&_65$$52, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_65$$52, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_65$$52); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 357)) { - ZEPHIR_INIT_VAR(&_66$$53); - zephir_create_array(&_66$$53, 4, 0); - add_assoc_stringl_ex(&_66$$53, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_66$$53, SL("op"), SL("NOT ILIKE")); - zephir_array_update_string(&_66$$53, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$53, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_66$$53); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '!')) { - ZEPHIR_INIT_VAR(&_67$$54); - zephir_create_array(&_67$$54, 3, 0); - add_assoc_stringl_ex(&_67$$54, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_67$$54, SL("op"), SL("NOT ")); - zephir_array_update_string(&_67$$54, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_67$$54); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 365)) { - ZEPHIR_INIT_VAR(&_68$$55); - zephir_create_array(&_68$$55, 3, 0); - add_assoc_stringl_ex(&_68$$55, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_68$$55, SL("op"), SL(" IS NULL")); - zephir_array_update_string(&_68$$55, SL("left"), &left, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_68$$55); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 366)) { - ZEPHIR_INIT_VAR(&_69$$56); - zephir_create_array(&_69$$56, 3, 0); - add_assoc_stringl_ex(&_69$$56, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_69$$56, SL("op"), SL(" IS NOT NULL")); - zephir_array_update_string(&_69$$56, SL("left"), &left, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_69$$56); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 315)) { - ZEPHIR_INIT_VAR(&_70$$57); - zephir_create_array(&_70$$57, 4, 0); - add_assoc_stringl_ex(&_70$$57, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_70$$57, SL("op"), SL("IN")); - zephir_array_update_string(&_70$$57, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_70$$57, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_70$$57); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 323)) { - ZEPHIR_INIT_VAR(&_71$$58); - zephir_create_array(&_71$$58, 4, 0); - add_assoc_stringl_ex(&_71$$58, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_71$$58, SL("op"), SL("NOT IN")); - zephir_array_update_string(&_71$$58, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_71$$58, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_71$$58); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 408)) { - ZEPHIR_INIT_VAR(&_72$$59); - zephir_create_array(&_72$$59, 3, 0); - add_assoc_stringl_ex(&_72$$59, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_72$$59, SL("op"), SL("EXISTS")); - zephir_array_update_string(&_72$$59, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_72$$59); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 330)) { - ZEPHIR_INIT_VAR(&_73$$60); - zephir_create_array(&_73$$60, 3, 0); - add_assoc_stringl_ex(&_73$$60, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_73$$60, SL("op"), SL("DISTINCT ")); - zephir_array_update_string(&_73$$60, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_73$$60); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 332)) { - ZEPHIR_INIT_VAR(&_74$$61); - zephir_create_array(&_74$$61, 4, 0); - add_assoc_stringl_ex(&_74$$61, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_74$$61, SL("op"), SL("BETWEEN NOT")); - zephir_array_update_string(&_74$$61, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_74$$61, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_74$$61); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 331)) { - ZEPHIR_INIT_VAR(&_75$$62); - zephir_create_array(&_75$$62, 4, 0); - add_assoc_stringl_ex(&_75$$62, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_75$$62, SL("op"), SL("BETWEEN")); - zephir_array_update_string(&_75$$62, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_75$$62, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_75$$62); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 276)) { - ZEPHIR_INIT_VAR(&_76$$63); - zephir_create_array(&_76$$63, 4, 0); - add_assoc_stringl_ex(&_76$$63, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_76$$63, SL("op"), SL("AGAINST")); - zephir_array_update_string(&_76$$63, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_76$$63, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_76$$63); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 333)) { - ZEPHIR_INIT_VAR(&_77$$64); - zephir_create_array(&_77$$64, 3, 0); - add_assoc_stringl_ex(&_77$$64, SL("type"), SL("cast")); - zephir_array_update_string(&_77$$64, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_77$$64, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_77$$64); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 336)) { - ZEPHIR_INIT_VAR(&_78$$65); - zephir_create_array(&_78$$65, 3, 0); - add_assoc_stringl_ex(&_78$$65, SL("type"), SL("convert")); - zephir_array_update_string(&_78$$65, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_78$$65, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_78$$65); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 358)) { - ZEPHIR_INIT_VAR(&_79$$66); - zephir_create_array(&_79$$66, 2, 0); - add_assoc_stringl_ex(&_79$$66, SL("type"), SL("literal")); - ZEPHIR_OBS_VAR(&_80$$66); - zephir_array_fetch_string(&_80$$66, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2115); - zephir_array_update_string(&_79$$66, SL("value"), &_80$$66, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_79$$66); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 350)) { - ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getfunctioncall", NULL, 461, &expr); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 409)) { - ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getcaseexpression", NULL, 462, &expr); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 309)) { - ZEPHIR_INIT_VAR(&_81$$69); - zephir_create_array(&_81$$69, 2, 0); - add_assoc_stringl_ex(&_81$$69, SL("type"), SL("select")); - ZVAL_BOOL(&_83$$69, 1); - ZEPHIR_CALL_METHOD(&_82$$69, this_ptr, "_prepareselect", NULL, 451, &expr, &_83$$69); - zephir_check_call_status(); - zephir_array_update_string(&_81$$69, SL("value"), &_82$$69, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_81$$69); - break; - } - ZEPHIR_INIT_VAR(&_84$$70); - object_init_ex(&_84$$70, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_85$$70); - ZEPHIR_CONCAT_SV(&_85$$70, "Unknown expression type ", &exprType); - ZEPHIR_CALL_METHOD(NULL, &_84$$70, "__construct", NULL, 32, &_85$$70); - zephir_check_call_status(); - zephir_throw_exception_debug(&_84$$70, "phalcon/Mvc/Model/Query.zep", 2138); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - RETURN_CCTOR(&exprReturn); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_0, 0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "There is no active transaction", "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 755); + return; } - if (zephir_array_isset_string(&expr, SL("domain"))) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getqualified", NULL, 460, &expr); + zephir_read_property(&_1, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_1, 1)) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_2$$4); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_3$$5); + ZVAL_STRING(&_3$$5, "db:rollbackTransaction"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_3$$5, this_ptr); + zephir_check_call_status(); + } + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel"))); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2$$4, "rollback", NULL, 0); zephir_check_call_status(); RETURN_MM(); } - if (zephir_array_isset_long(&expr, 0)) { - ZEPHIR_INIT_VAR(&listItems); - array_init(&listItems); - zephir_is_iterable(&expr, 0, "phalcon/Mvc/Model/Query.zep", 2161); - if (Z_TYPE_P(&expr) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&expr), _86$$72) - { - ZEPHIR_INIT_NVAR(&exprListItem); - ZVAL_COPY(&exprListItem, _86$$72); - ZEPHIR_CALL_METHOD(&_88$$73, this_ptr, "getexpression", NULL, 459, &exprListItem); - zephir_check_call_status(); - zephir_array_append(&listItems, &_88$$73, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2158); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &expr, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_87$$72, &expr, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_87$$72)) { - break; - } - ZEPHIR_CALL_METHOD(&exprListItem, &expr, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_89$$74, this_ptr, "getexpression", NULL, 459, &exprListItem); - zephir_check_call_status(); - zephir_array_append(&listItems, &_89$$74, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2158); - ZEPHIR_CALL_METHOD(NULL, &expr, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_read_property(&_4, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + _5 = ZEPHIR_IS_LONG_IDENTICAL(&_4, 0); + if (!(_5)) { + _5 = !nesting; + } + _6 = _5; + if (!(_6)) { + ZEPHIR_CALL_METHOD(&_7, this_ptr, "isnestedtransactionswithsavepoints", NULL, 0); + zephir_check_call_status(); + _6 = !zephir_is_true(&_7); + } + if (_6) { + zephir_read_property(&_8$$6, this_ptr, ZEND_STRL("transactionLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GT_LONG(&_8$$6, 0)) { + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel"))); } - ZEPHIR_INIT_NVAR(&exprListItem); - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("list")); - zephir_array_fast_append(return_value, &listItems); - RETURN_MM(); + RETURN_MM_BOOL(0); } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown expression", "phalcon/Mvc/Model/Query.zep", 2167); - return; + ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_9); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_10$$8); + ZVAL_STRING(&_10$$8, "db:rollbackSavepoint"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_10$$8, this_ptr, &savepointName); + zephir_check_call_status(); + } + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel"))); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rollbacksavepoint", NULL, 0, &savepointName); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getFunctionCall) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, getDsnDefaults) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, distinct = 0; - zval *expr_param = NULL, arguments, argument, _10, *_0$$6, _1$$6, _2$$7, _4$$8, _5$$9, _6$$9, _7$$10, _8$$10, _9$$11; - zval expr, functionArgs; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&functionArgs); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$11); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); - - - ZEPHIR_OBS_VAR(&arguments); - if (zephir_array_isset_string_fetch(&arguments, &expr, SL("arguments"), 0)) { - if (zephir_array_isset_string(&expr, SL("distinct"))) { - distinct = 1; - } else { - distinct = 0; - } - if (zephir_array_isset_long(&arguments, 0)) { - ZEPHIR_INIT_VAR(&functionArgs); - array_init(&functionArgs); - zephir_is_iterable(&arguments, 0, "phalcon/Mvc/Model/Query.zep", 2193); - if (Z_TYPE_P(&arguments) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _0$$6) - { - ZEPHIR_INIT_NVAR(&argument); - ZVAL_COPY(&argument, _0$$6); - ZEPHIR_CALL_METHOD(&_2$$7, this_ptr, "getcallargument", &_3, 463, &argument); - zephir_check_call_status(); - zephir_array_append(&functionArgs, &_2$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2191); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$6, &arguments, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$8, this_ptr, "getcallargument", &_3, 463, &argument); - zephir_check_call_status(); - zephir_array_append(&functionArgs, &_4$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2191); - ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&argument); - } else { - ZEPHIR_INIT_VAR(&_5$$9); - zephir_create_array(&_5$$9, 1, 0); - ZEPHIR_CALL_METHOD(&_6$$9, this_ptr, "getcallargument", &_3, 463, &arguments); - zephir_check_call_status(); - zephir_array_fast_append(&_5$$9, &_6$$9); - ZEPHIR_CPY_WRT(&functionArgs, &_5$$9); - } - if (distinct) { - zephir_create_array(return_value, 4, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); - ZEPHIR_OBS_VAR(&_7$$10); - zephir_array_fetch_string(&_7$$10, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2203); - zephir_array_update_string(return_value, SL("name"), &_7$$10, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_8$$10); - ZVAL_LONG(&_8$$10, distinct); - zephir_array_update_string(return_value, SL("distinct"), &_8$$10, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } else { - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); - ZEPHIR_OBS_VAR(&_9$$11); - zephir_array_fetch_string(&_9$$11, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2210); - zephir_array_update_string(return_value, SL("name"), &_9$$11, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - } - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); - ZEPHIR_OBS_VAR(&_10); - zephir_array_fetch_string(&_10, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2219); - zephir_array_update_string(return_value, SL("name"), &_10, PH_COPY | PH_SEPARATE); - RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getGroupClause) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_AbstractPdo, prepareRealSql) { + zend_string *_3$$3; + zend_ulong _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *group_param = NULL, groupItem, *_0$$3, _1$$3, _2$$4, _4$$5, _5$$6, _6$$6; - zval group, groupParts; + zval parameters, keys, values; + zval *statement_param = NULL, *parameters_param = NULL, key, result, value, *_0$$3, _1$$3, _16$$3, _4$$5, _5$$6, _6$$7, _7$$8, _8$$8, _9$$9, _10$$11, _11$$12, _12$$13, _13$$14, _14$$14, _15$$15; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&groupParts); - ZVAL_UNDEF(&groupItem); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_16$$3); ZVAL_UNDEF(&_4$$5); ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_11$$12); + ZVAL_UNDEF(&_12$$13); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&_14$$14); + ZVAL_UNDEF(&_15$$15); + ZVAL_UNDEF(¶meters); + ZVAL_UNDEF(&keys); + ZVAL_UNDEF(&values); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(group) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(statement) + Z_PARAM_ARRAY(parameters) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &group_param); - ZEPHIR_OBS_COPY_OR_DUP(&group, group_param); + zephir_fetch_params(1, 2, 0, &statement_param, ¶meters_param); + zephir_get_strval(&statement, statement_param); + zephir_get_arrval(¶meters, parameters_param); - if (zephir_array_isset_long(&group, 0)) { - ZEPHIR_INIT_VAR(&groupParts); - array_init(&groupParts); - zephir_is_iterable(&group, 0, "phalcon/Mvc/Model/Query.zep", 2239); - if (Z_TYPE_P(&group) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&group), _0$$3) + ZEPHIR_CPY_WRT(&result, &statement); + ZEPHIR_CPY_WRT(&values, ¶meters); + if (!(ZEPHIR_IS_EMPTY(¶meters))) { + ZEPHIR_INIT_VAR(&keys); + array_init(&keys); + zephir_is_iterable(¶meters, 0, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 844); + if (Z_TYPE_P(¶meters) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶meters), _2$$3, _3$$3, _0$$3) { - ZEPHIR_INIT_NVAR(&groupItem); - ZVAL_COPY(&groupItem, _0$$3); - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getexpression", &_3, 459, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupParts, &_2$$4, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2237); + ZEPHIR_INIT_NVAR(&key); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&key, _3$$3); + } else { + ZVAL_LONG(&key, _2$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0$$3); + if (Z_TYPE_P(&key) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_4$$5); + ZEPHIR_CONCAT_SVS(&_4$$5, "/:", &key, "/"); + zephir_array_append(&keys, &_4$$5, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 830); + } else { + ZEPHIR_INIT_NVAR(&_5$$6); + ZVAL_STRING(&_5$$6, "/[?]/"); + zephir_array_append(&keys, &_5$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 832); + } + if (Z_TYPE_P(&value) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_6$$7); + ZEPHIR_CONCAT_SVS(&_6$$7, "'", &value, "'"); + zephir_array_update_zval(&values, &key, &_6$$7, PH_COPY | PH_SEPARATE); + } else if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_7$$8); + zephir_fast_join_str(&_7$$8, SL("','"), &value); + ZEPHIR_INIT_NVAR(&_8$$8); + ZEPHIR_CONCAT_SVS(&_8$$8, "'", &_7$$8, "'"); + zephir_array_update_zval(&values, &key, &_8$$8, PH_COPY | PH_SEPARATE); + } else if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_9$$9); + ZVAL_STRING(&_9$$9, "NULL"); + zephir_array_update_zval(&values, &key, &_9$$9, PH_COPY | PH_SEPARATE); + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &group, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, ¶meters, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &group, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, ¶meters, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_1$$3)) { break; } - ZEPHIR_CALL_METHOD(&groupItem, &group, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, ¶meters, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getexpression", &_3, 459, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupParts, &_4$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2237); - ZEPHIR_CALL_METHOD(NULL, &group, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&value, ¶meters, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&key) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_10$$11); + ZEPHIR_CONCAT_SVS(&_10$$11, "/:", &key, "/"); + zephir_array_append(&keys, &_10$$11, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 830); + } else { + ZEPHIR_INIT_NVAR(&_11$$12); + ZVAL_STRING(&_11$$12, "/[?]/"); + zephir_array_append(&keys, &_11$$12, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/AbstractPdo.zep", 832); + } + if (Z_TYPE_P(&value) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_12$$13); + ZEPHIR_CONCAT_SVS(&_12$$13, "'", &value, "'"); + zephir_array_update_zval(&values, &key, &_12$$13, PH_COPY | PH_SEPARATE); + } else if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_13$$14); + zephir_fast_join_str(&_13$$14, SL("','"), &value); + ZEPHIR_INIT_NVAR(&_14$$14); + ZEPHIR_CONCAT_SVS(&_14$$14, "'", &_13$$14, "'"); + zephir_array_update_zval(&values, &key, &_14$$14, PH_COPY | PH_SEPARATE); + } else if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_15$$15); + ZVAL_STRING(&_15$$15, "NULL"); + zephir_array_update_zval(&values, &key, &_15$$15, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, ¶meters, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&groupItem); - } else { - ZEPHIR_INIT_VAR(&_5$$6); - zephir_create_array(&_5$$6, 1, 0); - ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getexpression", &_3, 459, &group); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZVAL_LONG(&_16$$3, 1); + ZEPHIR_CALL_FUNCTION(&result, "preg_replace", NULL, 40, &keys, &values, &statement, &_16$$3); zephir_check_call_status(); - zephir_array_fast_append(&_5$$6, &_6$$6); - ZEPHIR_CPY_WRT(&groupParts, &_5$$6); } - RETURN_CTOR(&groupParts); + zephir_update_property_zval(this_ptr, ZEND_STRL("realSqlStatement"), &result); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getLimitClause) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Mysql) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Mysql, phalcon, db_adapter_pdo_mysql, phalcon_db_adapter_pdo_abstractpdo_ce, phalcon_db_adapter_pdo_mysql_method_entry, 0); + + zend_declare_property_string(phalcon_db_adapter_pdo_mysql_ce, SL("dialectType"), "mysql", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_db_adapter_pdo_mysql_ce, SL("type"), "mysql", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *limitClause_param = NULL, number, offset, _0$$3, _1$$4; - zval limitClause, limit; + zephir_fcall_cache_entry *_2 = NULL; + zval *descriptor_param = NULL, __$false, _0, _1; + zval descriptor; zval *this_ptr = getThis(); - ZVAL_UNDEF(&limitClause); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&descriptor); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(limitClause) + Z_PARAM_ARRAY(descriptor) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &limitClause_param); - ZEPHIR_OBS_COPY_OR_DUP(&limitClause, limitClause_param); + zephir_fetch_params(1, 1, 0, &descriptor_param); + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); - ZEPHIR_INIT_VAR(&limit); - array_init(&limit); - ZEPHIR_OBS_VAR(&number); - if (zephir_array_isset_string_fetch(&number, &limitClause, SL("number"), 0)) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getexpression", NULL, 459, &number); - zephir_check_call_status(); - zephir_array_update_string(&limit, SL("number"), &_0$$3, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_0, &descriptor, SL("options"), PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 74); + if (!(zephir_array_isset_long(&_0, 20))) { + zephir_array_update_multi(&descriptor, &__$false, SL("sl"), 3, SL("options"), 20); } - ZEPHIR_OBS_VAR(&offset); - if (zephir_array_isset_string_fetch(&offset, &limitClause, SL("offset"), 0)) { - ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "getexpression", NULL, 459, &offset); - zephir_check_call_status(); - zephir_array_update_string(&limit, SL("offset"), &_1$$4, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_1, &descriptor, SL("options"), PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 77); + if (!(zephir_array_isset_long(&_1, 17))) { + zephir_array_update_multi(&descriptor, &__$false, SL("sl"), 3, SL("options"), 17); } - RETURN_CTOR(&limit); + ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_mysql_ce, getThis(), "__construct", &_2, 0, &descriptor); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoin) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, addForeignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval join; - zval *manager, manager_sub, *join_param = NULL, qualified, modelName, source, model, schema, _0$$3; + zval *tableName_param = NULL, *schemaName_param = NULL, *reference, reference_sub, foreignKeyCheck, _0, _1, _2, _3, _4; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&manager_sub); - ZVAL_UNDEF(&qualified); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&join); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_managerinterface_ce) - Z_PARAM_ARRAY(join) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &manager, &join_param); - zephir_get_arrval(&join, join_param); - - - ZEPHIR_OBS_VAR(&qualified); - if (zephir_array_isset_string_fetch(&qualified, &join, SL("qualified"), 0)) { - zephir_array_fetch_string(&_0$$3, &qualified, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2275); - if (ZEPHIR_IS_LONG(&_0$$3, 355)) { - ZEPHIR_OBS_VAR(&modelName); - zephir_array_fetch_string(&modelName, &qualified, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2276); - ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - zephir_create_array(return_value, 4, 0); - zephir_array_update_string(return_value, SL("schema"), &schema, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("source"), &source, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("modelName"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("model"), &model, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 2291); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoinType) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *join_param = NULL, type, _0, _1, _2; - zval join; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&type); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&reference_sub); + ZVAL_UNDEF(&foreignKeyCheck); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(join) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(reference, phalcon_db_referenceinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &join_param); - zephir_get_arrval(&join, join_param); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } - ZEPHIR_OBS_VAR(&type); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &join, SL("type"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 2302); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getforeignkeychecks", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&foreignKeyCheck, this_ptr, "prepare", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &foreignKeyCheck, "execute", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_2))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "DATABASE PARAMETER 'FOREIGN_KEY_CHECKS' HAS TO BE 1", "phalcon/Db/Adapter/Pdo/Mysql.zep", 98); return; } - do { - if (ZEPHIR_IS_LONG(&type, 360)) { - RETURN_MM_STRING("INNER"); - } - if (ZEPHIR_IS_LONG(&type, 361)) { - RETURN_MM_STRING("LEFT"); - } - if (ZEPHIR_IS_LONG(&type, 362)) { - RETURN_MM_STRING("RIGHT"); - } - if (ZEPHIR_IS_LONG(&type, 363)) { - RETURN_MM_STRING("CROSS"); - } - if (ZEPHIR_IS_LONG(&type, 364)) { - RETURN_MM_STRING("FULL OUTER"); - } - } while(0); - - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_mvc_model_exception_ce); - zephir_read_property(&_1, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SVSV(&_2, "Unknown join type ", &type, ", when preparing: ", &_1); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 32, &_2); + zephir_read_property(&_3, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4, &_3, "addforeignkey", NULL, 0, &tableName, &schemaName, reference); zephir_check_call_status(); - zephir_throw_exception_debug(&_0, "phalcon/Mvc/Model/Query.zep", 2324); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_4); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoins) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeColumns) { - zend_string *_22, *_45, *_30$$21, *_49$$26, *_79$$55; - zend_ulong _21, _44, _29$$21, _48$$26, _78$$55; + zend_bool _5$$3, _66$$49; + zval definition; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL, *_24 = NULL, *_50 = NULL, *_51 = NULL, *_56 = NULL, *_57 = NULL, *_64 = NULL, *_65 = NULL, *_80 = NULL, *_81 = NULL, *_92 = NULL, *_93 = NULL; + zephir_fcall_cache_entry *_64 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *select_param = NULL, __$true, models, sqlAliases, sqlAliasesModels, sqlModelsAliases, sqlAliasesModelsInstances, modelsInstances, fromModels, manager, selectJoins, joinItem, joins, joinData, schema, source, model, realModelName, completeSource, joinType, aliasExpr, alias, joinAliasName, joinExpr, fromModelName, joinAlias, joinModel, joinSource, preCondition, modelNameAlias, relation, relations, modelAlias, sqlJoin, sqlJoinItem, selectTables, tables, tableItem, _0, *_1, _2, *_19, _20, *_35, _36, _41, *_42, _43, _5$$9, _6$$9, _7$$9, _9$$11, _10$$11, _11$$11, _12$$12, _13$$14, _14$$14, _15$$14, _16$$16, _17$$16, _18$$16, _23$$18, _25$$20, _26$$21, *_27$$21, _28$$21, _37$$24, _38$$24, _39$$25, _40$$25, *_46$$26, _47$$26, _52$$31, _53$$31, _54$$31, _55$$32, *_58$$35, _59$$35, _61$$39, _66$$45, _67$$45, _68$$45, _69$$46, *_70$$49, _71$$49, _73$$53, *_76$$55, _77$$55, _82$$60, _83$$60, _84$$60, _85$$61, *_86$$64, _87$$64, _89$$68, _94$$74, _95$$74, _96$$74, _97$$75, *_98$$78, _99$$78, _101$$82; - zval select, sqlJoins, joinModels, joinSources, joinTypes, joinPreCondition, joinPrepared, _31$$22, _32$$22, _33$$23, _34$$23, _60$$39, _62$$40, _63$$40, _72$$53, _74$$54, _75$$54, _88$$68, _90$$69, _91$$69, _100$$82, _102$$83, _103$$83; + zval *table_param = NULL, *schema_param = NULL, __$true, __$false, columns, columnType, fields, field, oldColumn, sizePattern, matches, matchOne, matchTwo, columnName, _0, _1, _2, *_3, _4, _49$$3, _50$$3, _51$$3, _52$$3, _61$$3, _63$$3, _6$$4, _7$$4, _8$$5, _9$$5, _10$$6, _11$$6, _12$$7, _13$$7, _14$$8, _15$$8, _16$$9, _17$$9, _18$$10, _19$$11, _20$$12, _21$$13, _22$$14, _23$$14, _24$$15, _25$$15, _26$$16, _27$$17, _28$$18, _29$$19, _30$$20, _31$$21, _32$$22, _33$$23, _34$$24, _35$$25, _36$$26, _37$$27, _38$$28, _39$$29, _40$$30, _41$$31, _42$$32, _43$$32, _44$$33, _45$$33, _46$$33, _47$$35, _48$$36, _53$$43, _54$$44, _55$$44, _56$$44, _57$$45, _58$$46, _59$$47, _60$$47, _62$$48, _65$$49, _110$$49, _111$$49, _112$$49, _113$$49, _122$$49, _124$$49, _67$$50, _68$$50, _69$$51, _70$$51, _71$$52, _72$$52, _73$$53, _74$$53, _75$$54, _76$$54, _77$$55, _78$$55, _79$$56, _80$$57, _81$$58, _82$$59, _83$$60, _84$$60, _85$$61, _86$$61, _87$$62, _88$$63, _89$$64, _90$$65, _91$$66, _92$$67, _93$$68, _94$$69, _95$$70, _96$$71, _97$$72, _98$$73, _99$$74, _100$$75, _101$$76, _102$$77, _103$$78, _104$$78, _105$$79, _106$$79, _107$$79, _108$$81, _109$$82, _114$$89, _115$$90, _116$$90, _117$$90, _118$$91, _119$$92, _120$$93, _121$$93, _123$$94; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&select); - ZVAL_UNDEF(&sqlJoins); - ZVAL_UNDEF(&joinModels); - ZVAL_UNDEF(&joinSources); - ZVAL_UNDEF(&joinTypes); - ZVAL_UNDEF(&joinPreCondition); - ZVAL_UNDEF(&joinPrepared); - ZVAL_UNDEF(&_31$$22); - ZVAL_UNDEF(&_32$$22); - ZVAL_UNDEF(&_33$$23); - ZVAL_UNDEF(&_34$$23); - ZVAL_UNDEF(&_60$$39); - ZVAL_UNDEF(&_62$$40); - ZVAL_UNDEF(&_63$$40); - ZVAL_UNDEF(&_72$$53); - ZVAL_UNDEF(&_74$$54); - ZVAL_UNDEF(&_75$$54); - ZVAL_UNDEF(&_88$$68); - ZVAL_UNDEF(&_90$$69); - ZVAL_UNDEF(&_91$$69); - ZVAL_UNDEF(&_100$$82); - ZVAL_UNDEF(&_102$$83); - ZVAL_UNDEF(&_103$$83); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlAliasesModels); - ZVAL_UNDEF(&sqlModelsAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&fromModels); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&selectJoins); - ZVAL_UNDEF(&joinItem); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&joinData); + ZVAL_UNDEF(&table); ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&realModelName); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&aliasExpr); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&joinAliasName); - ZVAL_UNDEF(&joinExpr); - ZVAL_UNDEF(&fromModelName); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinModel); - ZVAL_UNDEF(&joinSource); - ZVAL_UNDEF(&preCondition); - ZVAL_UNDEF(&modelNameAlias); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&sqlJoin); - ZVAL_UNDEF(&sqlJoinItem); - ZVAL_UNDEF(&selectTables); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&tableItem); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&columnType); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&oldColumn); + ZVAL_UNDEF(&sizePattern); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&matchOne); + ZVAL_UNDEF(&matchTwo); + ZVAL_UNDEF(&columnName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_36); - ZVAL_UNDEF(&_41); - ZVAL_UNDEF(&_43); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_9$$11); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&_14$$14); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$16); - ZVAL_UNDEF(&_23$$18); - ZVAL_UNDEF(&_25$$20); - ZVAL_UNDEF(&_26$$21); - ZVAL_UNDEF(&_28$$21); - ZVAL_UNDEF(&_37$$24); - ZVAL_UNDEF(&_38$$24); - ZVAL_UNDEF(&_39$$25); - ZVAL_UNDEF(&_40$$25); - ZVAL_UNDEF(&_47$$26); - ZVAL_UNDEF(&_52$$31); - ZVAL_UNDEF(&_53$$31); - ZVAL_UNDEF(&_54$$31); - ZVAL_UNDEF(&_55$$32); - ZVAL_UNDEF(&_59$$35); - ZVAL_UNDEF(&_61$$39); - ZVAL_UNDEF(&_66$$45); - ZVAL_UNDEF(&_67$$45); - ZVAL_UNDEF(&_68$$45); - ZVAL_UNDEF(&_69$$46); - ZVAL_UNDEF(&_71$$49); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_49$$3); + ZVAL_UNDEF(&_50$$3); + ZVAL_UNDEF(&_51$$3); + ZVAL_UNDEF(&_52$$3); + ZVAL_UNDEF(&_61$$3); + ZVAL_UNDEF(&_63$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$9); + ZVAL_UNDEF(&_17$$9); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_20$$12); + ZVAL_UNDEF(&_21$$13); + ZVAL_UNDEF(&_22$$14); + ZVAL_UNDEF(&_23$$14); + ZVAL_UNDEF(&_24$$15); + ZVAL_UNDEF(&_25$$15); + ZVAL_UNDEF(&_26$$16); + ZVAL_UNDEF(&_27$$17); + ZVAL_UNDEF(&_28$$18); + ZVAL_UNDEF(&_29$$19); + ZVAL_UNDEF(&_30$$20); + ZVAL_UNDEF(&_31$$21); + ZVAL_UNDEF(&_32$$22); + ZVAL_UNDEF(&_33$$23); + ZVAL_UNDEF(&_34$$24); + ZVAL_UNDEF(&_35$$25); + ZVAL_UNDEF(&_36$$26); + ZVAL_UNDEF(&_37$$27); + ZVAL_UNDEF(&_38$$28); + ZVAL_UNDEF(&_39$$29); + ZVAL_UNDEF(&_40$$30); + ZVAL_UNDEF(&_41$$31); + ZVAL_UNDEF(&_42$$32); + ZVAL_UNDEF(&_43$$32); + ZVAL_UNDEF(&_44$$33); + ZVAL_UNDEF(&_45$$33); + ZVAL_UNDEF(&_46$$33); + ZVAL_UNDEF(&_47$$35); + ZVAL_UNDEF(&_48$$36); + ZVAL_UNDEF(&_53$$43); + ZVAL_UNDEF(&_54$$44); + ZVAL_UNDEF(&_55$$44); + ZVAL_UNDEF(&_56$$44); + ZVAL_UNDEF(&_57$$45); + ZVAL_UNDEF(&_58$$46); + ZVAL_UNDEF(&_59$$47); + ZVAL_UNDEF(&_60$$47); + ZVAL_UNDEF(&_62$$48); + ZVAL_UNDEF(&_65$$49); + ZVAL_UNDEF(&_110$$49); + ZVAL_UNDEF(&_111$$49); + ZVAL_UNDEF(&_112$$49); + ZVAL_UNDEF(&_113$$49); + ZVAL_UNDEF(&_122$$49); + ZVAL_UNDEF(&_124$$49); + ZVAL_UNDEF(&_67$$50); + ZVAL_UNDEF(&_68$$50); + ZVAL_UNDEF(&_69$$51); + ZVAL_UNDEF(&_70$$51); + ZVAL_UNDEF(&_71$$52); + ZVAL_UNDEF(&_72$$52); ZVAL_UNDEF(&_73$$53); + ZVAL_UNDEF(&_74$$53); + ZVAL_UNDEF(&_75$$54); + ZVAL_UNDEF(&_76$$54); ZVAL_UNDEF(&_77$$55); - ZVAL_UNDEF(&_82$$60); + ZVAL_UNDEF(&_78$$55); + ZVAL_UNDEF(&_79$$56); + ZVAL_UNDEF(&_80$$57); + ZVAL_UNDEF(&_81$$58); + ZVAL_UNDEF(&_82$$59); ZVAL_UNDEF(&_83$$60); ZVAL_UNDEF(&_84$$60); ZVAL_UNDEF(&_85$$61); - ZVAL_UNDEF(&_87$$64); - ZVAL_UNDEF(&_89$$68); - ZVAL_UNDEF(&_94$$74); - ZVAL_UNDEF(&_95$$74); - ZVAL_UNDEF(&_96$$74); - ZVAL_UNDEF(&_97$$75); - ZVAL_UNDEF(&_99$$78); - ZVAL_UNDEF(&_101$$82); + ZVAL_UNDEF(&_86$$61); + ZVAL_UNDEF(&_87$$62); + ZVAL_UNDEF(&_88$$63); + ZVAL_UNDEF(&_89$$64); + ZVAL_UNDEF(&_90$$65); + ZVAL_UNDEF(&_91$$66); + ZVAL_UNDEF(&_92$$67); + ZVAL_UNDEF(&_93$$68); + ZVAL_UNDEF(&_94$$69); + ZVAL_UNDEF(&_95$$70); + ZVAL_UNDEF(&_96$$71); + ZVAL_UNDEF(&_97$$72); + ZVAL_UNDEF(&_98$$73); + ZVAL_UNDEF(&_99$$74); + ZVAL_UNDEF(&_100$$75); + ZVAL_UNDEF(&_101$$76); + ZVAL_UNDEF(&_102$$77); + ZVAL_UNDEF(&_103$$78); + ZVAL_UNDEF(&_104$$78); + ZVAL_UNDEF(&_105$$79); + ZVAL_UNDEF(&_106$$79); + ZVAL_UNDEF(&_107$$79); + ZVAL_UNDEF(&_108$$81); + ZVAL_UNDEF(&_109$$82); + ZVAL_UNDEF(&_114$$89); + ZVAL_UNDEF(&_115$$90); + ZVAL_UNDEF(&_116$$90); + ZVAL_UNDEF(&_117$$90); + ZVAL_UNDEF(&_118$$91); + ZVAL_UNDEF(&_119$$92); + ZVAL_UNDEF(&_120$$93); + ZVAL_UNDEF(&_121$$93); + ZVAL_UNDEF(&_123$$94); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(select) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &select_param); - zephir_get_arrval(&select, select_param); - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliases, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModels, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlModelsAliases, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModelsInstances, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&modelsInstances, &_0); - ZEPHIR_CPY_WRT(&fromModels, &models); - ZEPHIR_INIT_VAR(&sqlJoins); - array_init(&sqlJoins); - ZEPHIR_INIT_VAR(&joinModels); - array_init(&joinModels); - ZEPHIR_INIT_VAR(&joinSources); - array_init(&joinSources); - ZEPHIR_INIT_VAR(&joinTypes); - array_init(&joinTypes); - ZEPHIR_INIT_VAR(&joinPreCondition); - array_init(&joinPreCondition); - ZEPHIR_INIT_VAR(&joinPrepared); - array_init(&joinPrepared); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_OBS_VAR(&tables); - zephir_array_fetch_string(&tables, &select, SL("tables"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2360); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&selectTables); - zephir_create_array(&selectTables, 1, 0); - zephir_array_fast_append(&selectTables, &tables); - } else { - ZEPHIR_CPY_WRT(&selectTables, &tables); - } - ZEPHIR_OBS_VAR(&joins); - zephir_array_fetch_string(&joins, &select, SL("joins"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2368); - if (!(zephir_array_isset_long(&joins, 0))) { - ZEPHIR_INIT_VAR(&selectJoins); - zephir_create_array(&selectJoins, 1, 0); - zephir_array_fast_append(&selectJoins, &joins); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + zephir_get_strval(&table, table_param); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - ZEPHIR_CPY_WRT(&selectJoins, &joins); + zephir_get_strval(&schema, schema_param); } - zephir_is_iterable(&selectJoins, 0, "phalcon/Mvc/Model/Query.zep", 2519); - if (Z_TYPE_P(&selectJoins) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectJoins), _1) + + + ZEPHIR_INIT_VAR(&oldColumn); + ZVAL_NULL(&oldColumn); + ZEPHIR_INIT_VAR(&sizePattern); + ZVAL_STRING(&sizePattern, "#\\(([0-9]+)(?:,\\s*([0-9]+))*\\)#"); + ZEPHIR_INIT_VAR(&columns); + array_init(&columns); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "describecolumns", NULL, 0, &table, &schema); + zephir_check_call_status(); + ZVAL_LONG(&_2, 3); + ZEPHIR_CALL_METHOD(&fields, this_ptr, "fetchall", NULL, 0, &_1, &_2); + zephir_check_call_status(); + zephir_is_iterable(&fields, 0, "phalcon/Db/Adapter/Pdo/Mysql.zep", 500); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fields), _3) { - ZEPHIR_INIT_NVAR(&joinItem); - ZVAL_COPY(&joinItem, _1); - ZEPHIR_CALL_METHOD(&joinData, this_ptr, "getjoin", &_3, 464, &manager, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &joinData, SL("source"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2382); - ZEPHIR_OBS_NVAR(&schema); - zephir_array_fetch_string(&schema, &joinData, SL("schema"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2383); - ZEPHIR_OBS_NVAR(&model); - zephir_array_fetch_string(&model, &joinData, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2384); - ZEPHIR_OBS_NVAR(&realModelName); - zephir_array_fetch_string(&realModelName, &joinData, SL("modelName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2385); - ZEPHIR_INIT_NVAR(&completeSource); - zephir_create_array(&completeSource, 2, 0); - zephir_array_fast_append(&completeSource, &source); - zephir_array_fast_append(&completeSource, &schema); - ZEPHIR_CALL_METHOD(&joinType, this_ptr, "getjointype", &_4, 465, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&aliasExpr); - if (zephir_array_isset_string_fetch(&aliasExpr, &joinItem, SL("alias"), 0)) { - ZEPHIR_OBS_NVAR(&alias); - zephir_array_fetch_string(&alias, &aliasExpr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2397); - if (UNEXPECTED(zephir_array_isset(&joinModels, &alias))) { - ZEPHIR_INIT_NVAR(&_5$$9); - object_init_ex(&_5$$9, phalcon_mvc_model_exception_ce); - zephir_read_property(&_6$$9, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$9); - ZEPHIR_CONCAT_SVSV(&_7$$9, "Cannot use '", &alias, "' as join alias because it was already used, when preparing: ", &_6$$9); - ZEPHIR_CALL_METHOD(NULL, &_5$$9, "__construct", &_8, 32, &_7$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$9, "phalcon/Mvc/Model/Query.zep", 2405); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _3); + ZEPHIR_INIT_NVAR(&definition); + zephir_create_array(&definition, 1, 0); + add_assoc_long_ex(&definition, SL("bindType"), 2); + ZEPHIR_OBS_NVAR(&columnType); + zephir_array_fetch_long(&columnType, &field, 1, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 153); + do { + _5$$3 = 1; + if (_5$$3 == zephir_start_with_str(&columnType, SL("bigint"))) { + ZEPHIR_INIT_NVAR(&_6$$4); + ZVAL_LONG(&_6$$4, 14); + zephir_array_update_string(&definition, SL("type"), &_6$$4, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_LONG(&_7$$4, 2); + zephir_array_update_string(&definition, SL("bindType"), &_7$$4, PH_COPY | PH_SEPARATE); + break; } - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2411); - zephir_array_update_zval(&joinTypes, &alias, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &alias, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &alias, &joinItem, PH_COPY | PH_SEPARATE); - } else { - if (UNEXPECTED(zephir_array_isset(&joinModels, &realModelName))) { - ZEPHIR_INIT_NVAR(&_9$$11); - object_init_ex(&_9$$11, phalcon_mvc_model_exception_ce); - zephir_read_property(&_10$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_11$$11); - ZEPHIR_CONCAT_SVSV(&_11$$11, "Cannot use '", &realModelName, "' as join alias because it was already used, when preparing: ", &_10$$11); - ZEPHIR_CALL_METHOD(NULL, &_9$$11, "__construct", &_8, 32, &_11$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$11, "phalcon/Mvc/Model/Query.zep", 2464); - ZEPHIR_MM_RESTORE(); - return; + if (_5$$3 == zephir_start_with_str(&columnType, SL("mediumint"))) { + ZEPHIR_INIT_NVAR(&_8$$5); + ZVAL_LONG(&_8$$5, 21); + zephir_array_update_string(&definition, SL("type"), &_8$$5, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_9$$5); + ZVAL_LONG(&_9$$5, 1); + zephir_array_update_string(&definition, SL("bindType"), &_9$$5, PH_COPY | PH_SEPARATE); + break; } - zephir_array_update_zval(&joinTypes, &realModelName, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &realModelName, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &realModelName, &joinItem, PH_COPY | PH_SEPARATE); - } - zephir_array_update_zval(&modelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &selectJoins, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &selectJoins, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { + if (_5$$3 == zephir_start_with_str(&columnType, SL("smallint"))) { + ZEPHIR_INIT_NVAR(&_10$$6); + ZVAL_LONG(&_10$$6, 22); + zephir_array_update_string(&definition, SL("type"), &_10$$6, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_11$$6); + ZVAL_LONG(&_11$$6, 1); + zephir_array_update_string(&definition, SL("bindType"), &_11$$6, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("tinyint"))) { + ZEPHIR_INIT_NVAR(&_12$$7); + ZVAL_LONG(&_12$$7, 26); + zephir_array_update_string(&definition, SL("type"), &_12$$7, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_13$$7); + ZVAL_LONG(&_13$$7, 1); + zephir_array_update_string(&definition, SL("bindType"), &_13$$7, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("int"))) { + ZEPHIR_INIT_NVAR(&_14$$8); + ZVAL_LONG(&_14$$8, 0); + zephir_array_update_string(&definition, SL("type"), &_14$$8, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_15$$8); + ZVAL_LONG(&_15$$8, 1); + zephir_array_update_string(&definition, SL("bindType"), &_15$$8, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("bit"))) { + ZEPHIR_INIT_NVAR(&_16$$9); + ZVAL_LONG(&_16$$9, 19); + zephir_array_update_string(&definition, SL("type"), &_16$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_17$$9); + ZVAL_LONG(&_17$$9, 1); + zephir_array_update_string(&definition, SL("bindType"), &_17$$9, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("enum"))) { + ZEPHIR_INIT_NVAR(&_18$$10); + ZVAL_LONG(&_18$$10, 18); + zephir_array_update_string(&definition, SL("type"), &_18$$10, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("datetime"))) { + ZEPHIR_INIT_NVAR(&_19$$11); + ZVAL_LONG(&_19$$11, 4); + zephir_array_update_string(&definition, SL("type"), &_19$$11, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("date"))) { + ZEPHIR_INIT_NVAR(&_20$$12); + ZVAL_LONG(&_20$$12, 1); + zephir_array_update_string(&definition, SL("type"), &_20$$12, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("decimal"))) { + ZEPHIR_INIT_NVAR(&_21$$13); + ZVAL_LONG(&_21$$13, 3); + zephir_array_update_string(&definition, SL("type"), &_21$$13, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("double"))) { + ZEPHIR_INIT_NVAR(&_22$$14); + ZVAL_LONG(&_22$$14, 9); + zephir_array_update_string(&definition, SL("type"), &_22$$14, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_23$$14); + ZVAL_LONG(&_23$$14, 32); + zephir_array_update_string(&definition, SL("bindType"), &_23$$14, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("float"))) { + ZEPHIR_INIT_NVAR(&_24$$15); + ZVAL_LONG(&_24$$15, 7); + zephir_array_update_string(&definition, SL("type"), &_24$$15, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_25$$15); + ZVAL_LONG(&_25$$15, 32); + zephir_array_update_string(&definition, SL("bindType"), &_25$$15, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("mediumblob"))) { + ZEPHIR_INIT_NVAR(&_26$$16); + ZVAL_LONG(&_26$$16, 12); + zephir_array_update_string(&definition, SL("type"), &_26$$16, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("longblob"))) { + ZEPHIR_INIT_NVAR(&_27$$17); + ZVAL_LONG(&_27$$17, 13); + zephir_array_update_string(&definition, SL("type"), &_27$$17, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("tinyblob"))) { + ZEPHIR_INIT_NVAR(&_28$$18); + ZVAL_LONG(&_28$$18, 10); + zephir_array_update_string(&definition, SL("type"), &_28$$18, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("blob"))) { + ZEPHIR_INIT_NVAR(&_29$$19); + ZVAL_LONG(&_29$$19, 11); + zephir_array_update_string(&definition, SL("type"), &_29$$19, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("timestamp"))) { + ZEPHIR_INIT_NVAR(&_30$$20); + ZVAL_LONG(&_30$$20, 17); + zephir_array_update_string(&definition, SL("type"), &_30$$20, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("time"))) { + ZEPHIR_INIT_NVAR(&_31$$21); + ZVAL_LONG(&_31$$21, 20); + zephir_array_update_string(&definition, SL("type"), &_31$$21, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("json"))) { + ZEPHIR_INIT_NVAR(&_32$$22); + ZVAL_LONG(&_32$$22, 15); + zephir_array_update_string(&definition, SL("type"), &_32$$22, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("longtext"))) { + ZEPHIR_INIT_NVAR(&_33$$23); + ZVAL_LONG(&_33$$23, 24); + zephir_array_update_string(&definition, SL("type"), &_33$$23, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("mediumtext"))) { + ZEPHIR_INIT_NVAR(&_34$$24); + ZVAL_LONG(&_34$$24, 23); + zephir_array_update_string(&definition, SL("type"), &_34$$24, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("tinytext"))) { + ZEPHIR_INIT_NVAR(&_35$$25); + ZVAL_LONG(&_35$$25, 25); + zephir_array_update_string(&definition, SL("type"), &_35$$25, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("text"))) { + ZEPHIR_INIT_NVAR(&_36$$26); + ZVAL_LONG(&_36$$26, 6); + zephir_array_update_string(&definition, SL("type"), &_36$$26, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("varchar"))) { + ZEPHIR_INIT_NVAR(&_37$$27); + ZVAL_LONG(&_37$$27, 2); + zephir_array_update_string(&definition, SL("type"), &_37$$27, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("char"))) { + ZEPHIR_INIT_NVAR(&_38$$28); + ZVAL_LONG(&_38$$28, 5); + zephir_array_update_string(&definition, SL("type"), &_38$$28, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("varbinary"))) { + ZEPHIR_INIT_NVAR(&_39$$29); + ZVAL_LONG(&_39$$29, 26); + zephir_array_update_string(&definition, SL("type"), &_39$$29, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_start_with_str(&columnType, SL("binary"))) { + ZEPHIR_INIT_NVAR(&_40$$30); + ZVAL_LONG(&_40$$30, 26); + zephir_array_update_string(&definition, SL("type"), &_40$$30, PH_COPY | PH_SEPARATE); + break; + } + ZEPHIR_INIT_NVAR(&_41$$31); + ZVAL_LONG(&_41$$31, 2); + zephir_array_update_string(&definition, SL("type"), &_41$$31, PH_COPY | PH_SEPARATE); break; - } - ZEPHIR_CALL_METHOD(&joinItem, &selectJoins, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinData, this_ptr, "getjoin", &_3, 464, &manager, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &joinData, SL("source"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2382); - ZEPHIR_OBS_NVAR(&schema); - zephir_array_fetch_string(&schema, &joinData, SL("schema"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2383); - ZEPHIR_OBS_NVAR(&model); - zephir_array_fetch_string(&model, &joinData, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2384); - ZEPHIR_OBS_NVAR(&realModelName); - zephir_array_fetch_string(&realModelName, &joinData, SL("modelName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2385); - ZEPHIR_INIT_NVAR(&_12$$12); - zephir_create_array(&_12$$12, 2, 0); - zephir_array_fast_append(&_12$$12, &source); - zephir_array_fast_append(&_12$$12, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_12$$12); - ZEPHIR_CALL_METHOD(&joinType, this_ptr, "getjointype", &_4, 465, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&aliasExpr); - if (zephir_array_isset_string_fetch(&aliasExpr, &joinItem, SL("alias"), 0)) { - ZEPHIR_OBS_NVAR(&alias); - zephir_array_fetch_string(&alias, &aliasExpr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2397); - if (UNEXPECTED(zephir_array_isset(&joinModels, &alias))) { - ZEPHIR_INIT_NVAR(&_13$$14); - object_init_ex(&_13$$14, phalcon_mvc_model_exception_ce); - zephir_read_property(&_14$$14, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_15$$14); - ZEPHIR_CONCAT_SVSV(&_15$$14, "Cannot use '", &alias, "' as join alias because it was already used, when preparing: ", &_14$$14); - ZEPHIR_CALL_METHOD(NULL, &_13$$14, "__construct", &_8, 32, &_15$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$14, "phalcon/Mvc/Model/Query.zep", 2405); - ZEPHIR_MM_RESTORE(); - return; + } while(0); + + if (zephir_memnstr_str(&columnType, SL("("), "phalcon/Db/Adapter/Pdo/Mysql.zep", 417)) { + ZEPHIR_INIT_NVAR(&matches); + ZVAL_NULL(&matches); + zephir_array_fetch_string(&_42$$32, &definition, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 420); + ZEPHIR_INIT_NVAR(&_43$$32); + zephir_preg_match(&_43$$32, &sizePattern, &columnType, &matches, 0, 0 , 0 ); + if (ZEPHIR_IS_LONG(&_42$$32, 18)) { + ZVAL_LONG(&_44$$33, 5); + ZVAL_LONG(&_45$$33, -1); + ZEPHIR_INIT_NVAR(&_46$$33); + zephir_substr(&_46$$33, &columnType, 5 , -1 , 0); + zephir_array_update_string(&definition, SL("size"), &_46$$33, PH_COPY | PH_SEPARATE); + } else if (zephir_is_true(&_43$$32)) { + ZEPHIR_OBS_NVAR(&matchOne); + if (zephir_array_isset_long_fetch(&matchOne, &matches, 1, 0)) { + ZEPHIR_INIT_NVAR(&_47$$35); + ZVAL_LONG(&_47$$35, zephir_get_intval(&matchOne)); + zephir_array_update_string(&definition, SL("size"), &_47$$35, PH_COPY | PH_SEPARATE); } - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2411); - zephir_array_update_zval(&joinTypes, &alias, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &alias, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &alias, &joinItem, PH_COPY | PH_SEPARATE); - } else { - if (UNEXPECTED(zephir_array_isset(&joinModels, &realModelName))) { - ZEPHIR_INIT_NVAR(&_16$$16); - object_init_ex(&_16$$16, phalcon_mvc_model_exception_ce); - zephir_read_property(&_17$$16, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_18$$16); - ZEPHIR_CONCAT_SVSV(&_18$$16, "Cannot use '", &realModelName, "' as join alias because it was already used, when preparing: ", &_17$$16); - ZEPHIR_CALL_METHOD(NULL, &_16$$16, "__construct", &_8, 32, &_18$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$16, "phalcon/Mvc/Model/Query.zep", 2464); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_OBS_NVAR(&matchTwo); + if (zephir_array_isset_long_fetch(&matchTwo, &matches, 2, 0)) { + ZEPHIR_INIT_NVAR(&_48$$36); + ZVAL_LONG(&_48$$36, zephir_get_intval(&matchTwo)); + zephir_array_update_string(&definition, SL("scale"), &_48$$36, PH_COPY | PH_SEPARATE); } - zephir_array_update_zval(&joinTypes, &realModelName, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &realModelName, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &realModelName, &joinItem, PH_COPY | PH_SEPARATE); } - zephir_array_update_zval(&modelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &selectJoins, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&joinItem); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &sqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &sqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_is_iterable(&joinPrepared, 0, "phalcon/Mvc/Model/Query.zep", 2539); - if (Z_TYPE_P(&joinPrepared) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinPrepared), _21, _22, _19) - { - ZEPHIR_INIT_NVAR(&joinAliasName); - if (_22 != NULL) { - ZVAL_STR_COPY(&joinAliasName, _22); + } + if (zephir_memnstr_str(&columnType, SL("unsigned"), "phalcon/Db/Adapter/Pdo/Mysql.zep", 436)) { + zephir_array_update_string(&definition, SL("unsigned"), &__$true, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&oldColumn) == IS_NULL) { + zephir_array_update_string(&definition, SL("first"), &__$true, PH_COPY | PH_SEPARATE); } else { - ZVAL_LONG(&joinAliasName, _21); + zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&joinItem); - ZVAL_COPY(&joinItem, _19); - ZEPHIR_OBS_NVAR(&joinExpr); - if (zephir_array_isset_string_fetch(&joinExpr, &joinItem, SL("conditions"), 0)) { - ZEPHIR_CALL_METHOD(&_23$$18, this_ptr, "getexpression", &_24, 459, &joinExpr); - zephir_check_call_status(); - zephir_array_update_zval(&joinPreCondition, &joinAliasName, &_23$$18, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_49$$3, &field, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 452); + if (ZEPHIR_IS_STRING(&_49$$3, "PRI")) { + zephir_array_update_string(&definition, SL("primary"), &__$true, PH_COPY | PH_SEPARATE); } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20, &joinPrepared, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20)) { - break; + zephir_array_fetch_long(&_50$$3, &field, 3, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 459); + if (ZEPHIR_IS_STRING(&_50$$3, "YES")) { + zephir_array_update_string(&definition, SL("notNull"), &__$false, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&joinAliasName, &joinPrepared, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinItem, &joinPrepared, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinExpr); - if (zephir_array_isset_string_fetch(&joinExpr, &joinItem, SL("conditions"), 0)) { - ZEPHIR_CALL_METHOD(&_25$$20, this_ptr, "getexpression", &_24, 459, &joinExpr); - zephir_check_call_status(); - zephir_array_update_zval(&joinPreCondition, &joinAliasName, &_25$$20, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&joinItem); - ZEPHIR_INIT_NVAR(&joinAliasName); - zephir_read_property(&_0, this_ptr, ZEND_STRL("enableImplicitJoins"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - ZEPHIR_INIT_VAR(&_26$$21); - zephir_is_iterable(&joinPrepared, 0, "phalcon/Mvc/Model/Query.zep", 2551); - if (Z_TYPE_P(&joinPrepared) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinPrepared), _29$$21, _30$$21, _27$$21) - { - ZEPHIR_INIT_NVAR(&joinAliasName); - if (_30$$21 != NULL) { - ZVAL_STR_COPY(&joinAliasName, _30$$21); + zephir_array_fetch_long(&_51$$3, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 466); + if (ZEPHIR_IS_STRING(&_51$$3, "auto_increment")) { + zephir_array_update_string(&definition, SL("autoIncrement"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_52$$3, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 473); + if (Z_TYPE_P(&_52$$3) != IS_NULL) { + zephir_array_fetch_long(&_53$$43, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 474); + if (zephir_memnstr_str(&_53$$43, SL("on update"), "phalcon/Db/Adapter/Pdo/Mysql.zep", 474)) { + zephir_array_fetch_long(&_54$$44, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 475); + zephir_array_fetch_long(&_55$$44, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 475); + ZEPHIR_INIT_NVAR(&_56$$44); + ZEPHIR_CONCAT_VSV(&_56$$44, &_54$$44, " ", &_55$$44); + zephir_array_update_string(&definition, SL("default"), &_56$$44, PH_COPY | PH_SEPARATE); } else { - ZVAL_LONG(&joinAliasName, _29$$21); + zephir_array_fetch_long(&_57$$45, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 477); + zephir_array_update_string(&definition, SL("default"), &_57$$45, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&_26$$21); - ZVAL_COPY(&_26$$21, _27$$21); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2541); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2542); - ZEPHIR_OBS_NVAR(&preCondition); - zephir_array_fetch(&preCondition, &joinPreCondition, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2543); - ZEPHIR_INIT_NVAR(&_31$$22); - zephir_create_array(&_31$$22, 3, 0); - zephir_array_update_string(&_31$$22, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_31$$22, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_32$$22); - zephir_create_array(&_32$$22, 1, 0); - zephir_array_fast_append(&_32$$22, &preCondition); - zephir_array_update_string(&_31$$22, SL("conditions"), &_32$$22, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_31$$22, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2548); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_28$$21, &joinPrepared, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_28$$21)) { - break; + } else { + zephir_array_fetch_long(&_58$$46, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 480); + if (zephir_memnstr_str(&_58$$46, SL("on update"), "phalcon/Db/Adapter/Pdo/Mysql.zep", 480)) { + zephir_array_fetch_long(&_59$$47, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 481); + ZEPHIR_INIT_NVAR(&_60$$47); + ZEPHIR_CONCAT_SV(&_60$$47, "NULL ", &_59$$47); + zephir_array_update_string(&definition, SL("default"), &_60$$47, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&joinAliasName, &joinPrepared, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_26$$21, &joinPrepared, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2541); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2542); - ZEPHIR_OBS_NVAR(&preCondition); - zephir_array_fetch(&preCondition, &joinPreCondition, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2543); - ZEPHIR_INIT_NVAR(&_33$$23); - zephir_create_array(&_33$$23, 3, 0); - zephir_array_update_string(&_33$$23, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$23, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_34$$23); - zephir_create_array(&_34$$23, 1, 0); - zephir_array_fast_append(&_34$$23, &preCondition); - zephir_array_update_string(&_33$$23, SL("conditions"), &_34$$23, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_33$$23, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2548); - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "next", NULL, 0); - zephir_check_call_status(); } - } - ZEPHIR_INIT_NVAR(&_26$$21); - ZEPHIR_INIT_NVAR(&joinAliasName); - RETURN_CTOR(&sqlJoins); - } - ZEPHIR_INIT_NVAR(&fromModels); - array_init(&fromModels); - zephir_is_iterable(&selectTables, 0, "phalcon/Mvc/Model/Query.zep", 2566); - if (Z_TYPE_P(&selectTables) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectTables), _35) - { - ZEPHIR_INIT_NVAR(&tableItem); - ZVAL_COPY(&tableItem, _35); - zephir_array_fetch_string(&_37$$24, &tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2560); - ZEPHIR_OBS_NVAR(&_38$$24); - zephir_array_fetch_string(&_38$$24, &_37$$24, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2560); - zephir_array_update_zval(&fromModels, &_38$$24, &__$true, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_61$$3, &field, 8, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 488); + if (Z_TYPE_P(&_61$$3) != IS_NULL) { + zephir_array_fetch_long(&_62$$48, &field, 8, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 489); + zephir_array_update_string(&definition, SL("comment"), &_62$$48, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&columnName, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 495); + ZEPHIR_INIT_NVAR(&_63$$3); + object_init_ex(&_63$$3, phalcon_db_column_ce); + ZEPHIR_CALL_METHOD(NULL, &_63$$3, "__construct", &_64, 212, &columnName, &definition); + zephir_check_call_status(); + zephir_array_append(&columns, &_63$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 496); + ZEPHIR_CPY_WRT(&oldColumn, &columnName); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &selectTables, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_36, &selectTables, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_4, &fields, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_36)) { + if (!zend_is_true(&_4)) { break; } - ZEPHIR_CALL_METHOD(&tableItem, &selectTables, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_string(&_39$$25, &tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2560); - ZEPHIR_OBS_NVAR(&_40$$25); - zephir_array_fetch_string(&_40$$25, &_39$$25, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2560); - zephir_array_update_zval(&fromModels, &_40$$25, &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &selectTables, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&tableItem); - ZEPHIR_INIT_VAR(&_41); - zephir_is_iterable(&fromModels, 0, "phalcon/Mvc/Model/Query.zep", 2686); - if (Z_TYPE_P(&fromModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fromModels), _44, _45, _42) - { - ZEPHIR_INIT_NVAR(&fromModelName); - if (_45 != NULL) { - ZVAL_STR_COPY(&fromModelName, _45); - } else { - ZVAL_LONG(&fromModelName, _44); - } - ZEPHIR_INIT_NVAR(&_41); - ZVAL_COPY(&_41, _42); - zephir_is_iterable(&joinModels, 0, "phalcon/Mvc/Model/Query.zep", 2684); - if (Z_TYPE_P(&joinModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinModels), _48$$26, _49$$26, _46$$26) - { - ZEPHIR_INIT_NVAR(&joinAlias); - if (_49$$26 != NULL) { - ZVAL_STR_COPY(&joinAlias, _49$$26); - } else { - ZVAL_LONG(&joinAlias, _48$$26); - } - ZEPHIR_INIT_NVAR(&joinModel); - ZVAL_COPY(&joinModel, _46$$26); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_50, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_51, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_52$$31); - object_init_ex(&_52$$31, phalcon_mvc_model_exception_ce); - zephir_read_property(&_53$$31, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_54$$31); - ZEPHIR_CONCAT_SVSVSV(&_54$$31, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_53$$31); - ZEPHIR_CALL_METHOD(NULL, &_52$$31, "__construct", &_8, 32, &_54$$31); - zephir_check_call_status(); - zephir_throw_exception_debug(&_52$$31, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_55$$32, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_55$$32))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 467, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _58$$35) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _58$$35); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_59$$35, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_59$$35)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_60$$39); - zephir_create_array(&_60$$39, 3, 0); - zephir_array_update_string(&_60$$39, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_60$$39, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_61$$39); - array_init(&_61$$39); - zephir_array_update_string(&_60$$39, SL("conditions"), &_61$$39, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_60$$39, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_62$$40); - zephir_create_array(&_62$$40, 3, 0); - zephir_array_update_string(&_62$$40, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_62$$40, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_63$$40); - zephir_create_array(&_63$$40, 1, 0); - zephir_array_fast_append(&_63$$40, &preCondition); - zephir_array_update_string(&_62$$40, SL("conditions"), &_63$$40, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_62$$40, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); + ZEPHIR_INIT_NVAR(&_65$$49); + zephir_create_array(&_65$$49, 1, 0); + add_assoc_long_ex(&_65$$49, SL("bindType"), 2); + ZEPHIR_CPY_WRT(&definition, &_65$$49); + ZEPHIR_OBS_NVAR(&columnType); + zephir_array_fetch_long(&columnType, &field, 1, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 153); + do { + _66$$49 = 1; + if (_66$$49 == zephir_start_with_str(&columnType, SL("bigint"))) { + ZEPHIR_INIT_NVAR(&_67$$50); + ZVAL_LONG(&_67$$50, 14); + zephir_array_update_string(&definition, SL("type"), &_67$$50, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_68$$50); + ZVAL_LONG(&_68$$50, 2); + zephir_array_update_string(&definition, SL("bindType"), &_68$$50, PH_COPY | PH_SEPARATE); + break; } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_47$$26, &joinModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_47$$26)) { + if (_66$$49 == zephir_start_with_str(&columnType, SL("mediumint"))) { + ZEPHIR_INIT_NVAR(&_69$$51); + ZVAL_LONG(&_69$$51, 21); + zephir_array_update_string(&definition, SL("type"), &_69$$51, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_70$$51); + ZVAL_LONG(&_70$$51, 1); + zephir_array_update_string(&definition, SL("bindType"), &_70$$51, PH_COPY | PH_SEPARATE); break; } - ZEPHIR_CALL_METHOD(&joinAlias, &joinModels, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinModel, &joinModels, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_64, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_65, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_66$$45); - object_init_ex(&_66$$45, phalcon_mvc_model_exception_ce); - zephir_read_property(&_67$$45, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_68$$45); - ZEPHIR_CONCAT_SVSVSV(&_68$$45, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_67$$45); - ZEPHIR_CALL_METHOD(NULL, &_66$$45, "__construct", &_8, 32, &_68$$45); - zephir_check_call_status(); - zephir_throw_exception_debug(&_66$$45, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_69$$46, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_69$$46))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 467, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _70$$49) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _70$$49); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_71$$49, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_71$$49)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_72$$53); - zephir_create_array(&_72$$53, 3, 0); - zephir_array_update_string(&_72$$53, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_72$$53, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_73$$53); - array_init(&_73$$53); - zephir_array_update_string(&_72$$53, SL("conditions"), &_73$$53, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_72$$53, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_74$$54); - zephir_create_array(&_74$$54, 3, 0); - zephir_array_update_string(&_74$$54, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_74$$54, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_75$$54); - zephir_create_array(&_75$$54, 1, 0); - zephir_array_fast_append(&_75$$54, &preCondition); - zephir_array_update_string(&_74$$54, SL("conditions"), &_75$$54, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_74$$54, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); - } - ZEPHIR_CALL_METHOD(NULL, &joinModels, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&joinModel); - ZEPHIR_INIT_NVAR(&joinAlias); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fromModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_43, &fromModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_43)) { - break; - } - ZEPHIR_CALL_METHOD(&fromModelName, &fromModels, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_41, &fromModels, "current", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&joinModels, 0, "phalcon/Mvc/Model/Query.zep", 2684); - if (Z_TYPE_P(&joinModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinModels), _78$$55, _79$$55, _76$$55) - { - ZEPHIR_INIT_NVAR(&joinAlias); - if (_79$$55 != NULL) { - ZVAL_STR_COPY(&joinAlias, _79$$55); - } else { - ZVAL_LONG(&joinAlias, _78$$55); + if (_66$$49 == zephir_start_with_str(&columnType, SL("smallint"))) { + ZEPHIR_INIT_NVAR(&_71$$52); + ZVAL_LONG(&_71$$52, 22); + zephir_array_update_string(&definition, SL("type"), &_71$$52, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_72$$52); + ZVAL_LONG(&_72$$52, 1); + zephir_array_update_string(&definition, SL("bindType"), &_72$$52, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("tinyint"))) { + ZEPHIR_INIT_NVAR(&_73$$53); + ZVAL_LONG(&_73$$53, 26); + zephir_array_update_string(&definition, SL("type"), &_73$$53, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_74$$53); + ZVAL_LONG(&_74$$53, 1); + zephir_array_update_string(&definition, SL("bindType"), &_74$$53, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("int"))) { + ZEPHIR_INIT_NVAR(&_75$$54); + ZVAL_LONG(&_75$$54, 0); + zephir_array_update_string(&definition, SL("type"), &_75$$54, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_76$$54); + ZVAL_LONG(&_76$$54, 1); + zephir_array_update_string(&definition, SL("bindType"), &_76$$54, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("bit"))) { + ZEPHIR_INIT_NVAR(&_77$$55); + ZVAL_LONG(&_77$$55, 19); + zephir_array_update_string(&definition, SL("type"), &_77$$55, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_78$$55); + ZVAL_LONG(&_78$$55, 1); + zephir_array_update_string(&definition, SL("bindType"), &_78$$55, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("enum"))) { + ZEPHIR_INIT_NVAR(&_79$$56); + ZVAL_LONG(&_79$$56, 18); + zephir_array_update_string(&definition, SL("type"), &_79$$56, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("datetime"))) { + ZEPHIR_INIT_NVAR(&_80$$57); + ZVAL_LONG(&_80$$57, 4); + zephir_array_update_string(&definition, SL("type"), &_80$$57, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("date"))) { + ZEPHIR_INIT_NVAR(&_81$$58); + ZVAL_LONG(&_81$$58, 1); + zephir_array_update_string(&definition, SL("type"), &_81$$58, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("decimal"))) { + ZEPHIR_INIT_NVAR(&_82$$59); + ZVAL_LONG(&_82$$59, 3); + zephir_array_update_string(&definition, SL("type"), &_82$$59, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("double"))) { + ZEPHIR_INIT_NVAR(&_83$$60); + ZVAL_LONG(&_83$$60, 9); + zephir_array_update_string(&definition, SL("type"), &_83$$60, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_84$$60); + ZVAL_LONG(&_84$$60, 32); + zephir_array_update_string(&definition, SL("bindType"), &_84$$60, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("float"))) { + ZEPHIR_INIT_NVAR(&_85$$61); + ZVAL_LONG(&_85$$61, 7); + zephir_array_update_string(&definition, SL("type"), &_85$$61, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_86$$61); + ZVAL_LONG(&_86$$61, 32); + zephir_array_update_string(&definition, SL("bindType"), &_86$$61, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("mediumblob"))) { + ZEPHIR_INIT_NVAR(&_87$$62); + ZVAL_LONG(&_87$$62, 12); + zephir_array_update_string(&definition, SL("type"), &_87$$62, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("longblob"))) { + ZEPHIR_INIT_NVAR(&_88$$63); + ZVAL_LONG(&_88$$63, 13); + zephir_array_update_string(&definition, SL("type"), &_88$$63, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("tinyblob"))) { + ZEPHIR_INIT_NVAR(&_89$$64); + ZVAL_LONG(&_89$$64, 10); + zephir_array_update_string(&definition, SL("type"), &_89$$64, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("blob"))) { + ZEPHIR_INIT_NVAR(&_90$$65); + ZVAL_LONG(&_90$$65, 11); + zephir_array_update_string(&definition, SL("type"), &_90$$65, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("timestamp"))) { + ZEPHIR_INIT_NVAR(&_91$$66); + ZVAL_LONG(&_91$$66, 17); + zephir_array_update_string(&definition, SL("type"), &_91$$66, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("time"))) { + ZEPHIR_INIT_NVAR(&_92$$67); + ZVAL_LONG(&_92$$67, 20); + zephir_array_update_string(&definition, SL("type"), &_92$$67, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("json"))) { + ZEPHIR_INIT_NVAR(&_93$$68); + ZVAL_LONG(&_93$$68, 15); + zephir_array_update_string(&definition, SL("type"), &_93$$68, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("longtext"))) { + ZEPHIR_INIT_NVAR(&_94$$69); + ZVAL_LONG(&_94$$69, 24); + zephir_array_update_string(&definition, SL("type"), &_94$$69, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("mediumtext"))) { + ZEPHIR_INIT_NVAR(&_95$$70); + ZVAL_LONG(&_95$$70, 23); + zephir_array_update_string(&definition, SL("type"), &_95$$70, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("tinytext"))) { + ZEPHIR_INIT_NVAR(&_96$$71); + ZVAL_LONG(&_96$$71, 25); + zephir_array_update_string(&definition, SL("type"), &_96$$71, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("text"))) { + ZEPHIR_INIT_NVAR(&_97$$72); + ZVAL_LONG(&_97$$72, 6); + zephir_array_update_string(&definition, SL("type"), &_97$$72, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("varchar"))) { + ZEPHIR_INIT_NVAR(&_98$$73); + ZVAL_LONG(&_98$$73, 2); + zephir_array_update_string(&definition, SL("type"), &_98$$73, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("char"))) { + ZEPHIR_INIT_NVAR(&_99$$74); + ZVAL_LONG(&_99$$74, 5); + zephir_array_update_string(&definition, SL("type"), &_99$$74, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("varbinary"))) { + ZEPHIR_INIT_NVAR(&_100$$75); + ZVAL_LONG(&_100$$75, 26); + zephir_array_update_string(&definition, SL("type"), &_100$$75, PH_COPY | PH_SEPARATE); + break; + } + if (_66$$49 == zephir_start_with_str(&columnType, SL("binary"))) { + ZEPHIR_INIT_NVAR(&_101$$76); + ZVAL_LONG(&_101$$76, 26); + zephir_array_update_string(&definition, SL("type"), &_101$$76, PH_COPY | PH_SEPARATE); + break; + } + ZEPHIR_INIT_NVAR(&_102$$77); + ZVAL_LONG(&_102$$77, 2); + zephir_array_update_string(&definition, SL("type"), &_102$$77, PH_COPY | PH_SEPARATE); + break; + } while(0); + + if (zephir_memnstr_str(&columnType, SL("("), "phalcon/Db/Adapter/Pdo/Mysql.zep", 417)) { + ZEPHIR_INIT_NVAR(&matches); + ZVAL_NULL(&matches); + zephir_array_fetch_string(&_103$$78, &definition, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 420); + ZEPHIR_INIT_NVAR(&_104$$78); + zephir_preg_match(&_104$$78, &sizePattern, &columnType, &matches, 0, 0 , 0 ); + if (ZEPHIR_IS_LONG(&_103$$78, 18)) { + ZVAL_LONG(&_105$$79, 5); + ZVAL_LONG(&_106$$79, -1); + ZEPHIR_INIT_NVAR(&_107$$79); + zephir_substr(&_107$$79, &columnType, 5 , -1 , 0); + zephir_array_update_string(&definition, SL("size"), &_107$$79, PH_COPY | PH_SEPARATE); + } else if (zephir_is_true(&_104$$78)) { + ZEPHIR_OBS_NVAR(&matchOne); + if (zephir_array_isset_long_fetch(&matchOne, &matches, 1, 0)) { + ZEPHIR_INIT_NVAR(&_108$$81); + ZVAL_LONG(&_108$$81, zephir_get_intval(&matchOne)); + zephir_array_update_string(&definition, SL("size"), &_108$$81, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&joinModel); - ZVAL_COPY(&joinModel, _76$$55); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_80, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_81, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_82$$60); - object_init_ex(&_82$$60, phalcon_mvc_model_exception_ce); - zephir_read_property(&_83$$60, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_84$$60); - ZEPHIR_CONCAT_SVSVSV(&_84$$60, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_83$$60); - ZEPHIR_CALL_METHOD(NULL, &_82$$60, "__construct", &_8, 32, &_84$$60); - zephir_check_call_status(); - zephir_throw_exception_debug(&_82$$60, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_85$$61, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_85$$61))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 467, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _86$$64) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _86$$64); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_87$$64, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_87$$64)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_88$$68); - zephir_create_array(&_88$$68, 3, 0); - zephir_array_update_string(&_88$$68, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_88$$68, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_89$$68); - array_init(&_89$$68); - zephir_array_update_string(&_88$$68, SL("conditions"), &_89$$68, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_88$$68, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_90$$69); - zephir_create_array(&_90$$69, 3, 0); - zephir_array_update_string(&_90$$69, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_90$$69, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_91$$69); - zephir_create_array(&_91$$69, 1, 0); - zephir_array_fast_append(&_91$$69, &preCondition); - zephir_array_update_string(&_90$$69, SL("conditions"), &_91$$69, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_90$$69, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); + ZEPHIR_OBS_NVAR(&matchTwo); + if (zephir_array_isset_long_fetch(&matchTwo, &matches, 2, 0)) { + ZEPHIR_INIT_NVAR(&_109$$82); + ZVAL_LONG(&_109$$82, zephir_get_intval(&matchTwo)); + zephir_array_update_string(&definition, SL("scale"), &_109$$82, PH_COPY | PH_SEPARATE); } - } ZEND_HASH_FOREACH_END(); + } + } + if (zephir_memnstr_str(&columnType, SL("unsigned"), "phalcon/Db/Adapter/Pdo/Mysql.zep", 436)) { + zephir_array_update_string(&definition, SL("unsigned"), &__$true, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&oldColumn) == IS_NULL) { + zephir_array_update_string(&definition, SL("first"), &__$true, PH_COPY | PH_SEPARATE); } else { - ZEPHIR_CALL_METHOD(NULL, &joinModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_77$$55, &joinModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_77$$55)) { - break; - } - ZEPHIR_CALL_METHOD(&joinAlias, &joinModels, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinModel, &joinModels, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_92, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_93, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_94$$74); - object_init_ex(&_94$$74, phalcon_mvc_model_exception_ce); - zephir_read_property(&_95$$74, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_96$$74); - ZEPHIR_CONCAT_SVSVSV(&_96$$74, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_95$$74); - ZEPHIR_CALL_METHOD(NULL, &_94$$74, "__construct", &_8, 32, &_96$$74); - zephir_check_call_status(); - zephir_throw_exception_debug(&_94$$74, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_97$$75, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_97$$75))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 467, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _98$$78) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _98$$78); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_99$$78, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_99$$78)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_100$$82); - zephir_create_array(&_100$$82, 3, 0); - zephir_array_update_string(&_100$$82, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_100$$82, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_101$$82); - array_init(&_101$$82); - zephir_array_update_string(&_100$$82, SL("conditions"), &_101$$82, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_100$$82, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_102$$83); - zephir_create_array(&_102$$83, 3, 0); - zephir_array_update_string(&_102$$83, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_102$$83, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_103$$83); - zephir_create_array(&_103$$83, 1, 0); - zephir_array_fast_append(&_103$$83, &preCondition); - zephir_array_update_string(&_102$$83, SL("conditions"), &_103$$83, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_102$$83, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); - } - ZEPHIR_CALL_METHOD(NULL, &joinModels, "next", NULL, 0); - zephir_check_call_status(); + zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_110$$49, &field, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 452); + if (ZEPHIR_IS_STRING(&_110$$49, "PRI")) { + zephir_array_update_string(&definition, SL("primary"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_111$$49, &field, 3, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 459); + if (ZEPHIR_IS_STRING(&_111$$49, "YES")) { + zephir_array_update_string(&definition, SL("notNull"), &__$false, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_112$$49, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 466); + if (ZEPHIR_IS_STRING(&_112$$49, "auto_increment")) { + zephir_array_update_string(&definition, SL("autoIncrement"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_113$$49, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 473); + if (Z_TYPE_P(&_113$$49) != IS_NULL) { + zephir_array_fetch_long(&_114$$89, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 474); + if (zephir_memnstr_str(&_114$$89, SL("on update"), "phalcon/Db/Adapter/Pdo/Mysql.zep", 474)) { + zephir_array_fetch_long(&_115$$90, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 475); + zephir_array_fetch_long(&_116$$90, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 475); + ZEPHIR_INIT_NVAR(&_117$$90); + ZEPHIR_CONCAT_VSV(&_117$$90, &_115$$90, " ", &_116$$90); + zephir_array_update_string(&definition, SL("default"), &_117$$90, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_long(&_118$$91, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 477); + zephir_array_update_string(&definition, SL("default"), &_118$$91, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_fetch_long(&_119$$92, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 480); + if (zephir_memnstr_str(&_119$$92, SL("on update"), "phalcon/Db/Adapter/Pdo/Mysql.zep", 480)) { + zephir_array_fetch_long(&_120$$93, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 481); + ZEPHIR_INIT_NVAR(&_121$$93); + ZEPHIR_CONCAT_SV(&_121$$93, "NULL ", &_120$$93); + zephir_array_update_string(&definition, SL("default"), &_121$$93, PH_COPY | PH_SEPARATE); } } - ZEPHIR_INIT_NVAR(&joinModel); - ZEPHIR_INIT_NVAR(&joinAlias); - ZEPHIR_CALL_METHOD(NULL, &fromModels, "next", NULL, 0); + zephir_array_fetch_long(&_122$$49, &field, 8, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 488); + if (Z_TYPE_P(&_122$$49) != IS_NULL) { + zephir_array_fetch_long(&_123$$94, &field, 8, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 489); + zephir_array_update_string(&definition, SL("comment"), &_123$$94, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&columnName); + zephir_array_fetch_long(&columnName, &field, 0, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 495); + ZEPHIR_INIT_NVAR(&_124$$49); + object_init_ex(&_124$$49, phalcon_db_column_ce); + ZEPHIR_CALL_METHOD(NULL, &_124$$49, "__construct", &_64, 212, &columnName, &definition); + zephir_check_call_status(); + zephir_array_append(&columns, &_124$$49, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 496); + ZEPHIR_CPY_WRT(&oldColumn, &columnName); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&_41); - ZEPHIR_INIT_NVAR(&fromModelName); - RETURN_CTOR(&sqlJoins); + ZEPHIR_INIT_NVAR(&field); + RETURN_CCTOR(&columns); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getMultiJoin) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeIndexes) { - zend_string *_4$$3; - zend_ulong _3$$3; - zval sqlJoins, _10$$4, _12$$4, _18$$6, _19$$6, _21$$8, _22$$8, _23$$8, _25$$8, _26$$8, _27$$8, _28$$8; + zend_string *_27; + zend_ulong _26; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_11 = NULL; + zephir_fcall_cache_entry *_31 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *joinType_param = NULL, *joinSource, joinSource_sub, *modelAlias_param = NULL, *joinAlias_param = NULL, *relation, relation_sub, fields, referencedFields, intermediateModelName, intermediateModel, intermediateSource, intermediateSchema, intermediateFields, intermediateReferencedFields, referencedModelName, manager, field, position, intermediateField, sqlEqualsJoinCondition, _0, *_1$$3, _2$$3, _5$$5, _6$$5, _7$$5, _9$$4, _13$$7, _14$$7, _15$$7, _16$$6, _17$$6, _20$$8, _24$$8; - zval joinType, modelAlias, joinAlias; + zval *table_param = NULL, *schema_param = NULL, indexes, index, keyName, indexType, indexObjects, columns, name, _0, _1, _2, _3, *_4, _5, *_24, _25, _6$$4, _7$$3, _9$$3, _10$$3, _8$$6, _11$$7, _12$$8, _13$$9, _14$$10, _15$$12, _16$$11, _18$$11, _19$$11, _17$$14, _20$$15, _21$$16, _22$$17, _23$$18, _28$$19, _29$$19, _30$$19, _32$$20, _33$$20, _34$$20; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinSource_sub); - ZVAL_UNDEF(&relation_sub); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&intermediateModelName); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&intermediateSource); - ZVAL_UNDEF(&intermediateSchema); - ZVAL_UNDEF(&intermediateFields); - ZVAL_UNDEF(&intermediateReferencedFields); - ZVAL_UNDEF(&referencedModelName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&intermediateField); - ZVAL_UNDEF(&sqlEqualsJoinCondition); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&indexes); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&indexType); + ZVAL_UNDEF(&indexObjects); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_15$$7); - ZVAL_UNDEF(&_16$$6); - ZVAL_UNDEF(&_17$$6); - ZVAL_UNDEF(&_20$$8); - ZVAL_UNDEF(&_24$$8); - ZVAL_UNDEF(&sqlJoins); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_18$$6); - ZVAL_UNDEF(&_19$$6); - ZVAL_UNDEF(&_21$$8); - ZVAL_UNDEF(&_22$$8); - ZVAL_UNDEF(&_23$$8); - ZVAL_UNDEF(&_25$$8); - ZVAL_UNDEF(&_26$$8); - ZVAL_UNDEF(&_27$$8); - ZVAL_UNDEF(&_28$$8); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_25); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&_14$$10); + ZVAL_UNDEF(&_15$$12); + ZVAL_UNDEF(&_16$$11); + ZVAL_UNDEF(&_18$$11); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_17$$14); + ZVAL_UNDEF(&_20$$15); + ZVAL_UNDEF(&_21$$16); + ZVAL_UNDEF(&_22$$17); + ZVAL_UNDEF(&_23$$18); + ZVAL_UNDEF(&_28$$19); + ZVAL_UNDEF(&_29$$19); + ZVAL_UNDEF(&_30$$19); + ZVAL_UNDEF(&_32$$20); + ZVAL_UNDEF(&_33$$20); + ZVAL_UNDEF(&_34$$20); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(joinType) - Z_PARAM_ZVAL(joinSource) - Z_PARAM_STR(modelAlias) - Z_PARAM_STR(joinAlias) - Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias_param, &joinAlias_param, &relation); - if (UNEXPECTED(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be of the type string")); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(joinType_param) == IS_STRING)) { - zephir_get_strval(&joinType, joinType_param); + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_INIT_VAR(&joinType); + ZEPHIR_INIT_VAR(&table); + } + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); + } } - zephir_get_strval(&modelAlias, modelAlias_param); - zephir_get_strval(&joinAlias, joinAlias_param); - ZEPHIR_INIT_VAR(&sqlJoins); - array_init(&sqlJoins); - ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateModelName, relation, "getintermediatemodel", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&intermediateModel, &manager, "load", NULL, 0, &intermediateModelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateSource, &intermediateModel, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateSchema, &intermediateModel, "getschema", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("sqlAliases"), &intermediateModelName, &intermediateSource); - zephir_update_property_array(this_ptr, SL("sqlAliasesModelsInstances"), &intermediateModelName, &intermediateModel); - ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateReferencedFields, relation, "getintermediatereferencedfields", NULL, 0); + ZEPHIR_INIT_VAR(&indexes); + array_init(&indexes); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describeindexes", NULL, 0, &table, &schema); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModelName, relation, "getreferencedmodel", NULL, 0); + ZVAL_LONG(&_3, 2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); zephir_check_call_status(); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 2803); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _3$$3, _4$$3, _1$$3) - { - ZEPHIR_INIT_NVAR(&field); - if (_4$$3 != NULL) { - ZVAL_STR_COPY(&field, _4$$3); + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/Pdo/Mysql.zep", 546); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _4) + { + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _4); + zephir_array_fetch_string(&keyName, &index, SL("Key_name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 519); + zephir_array_fetch_string(&indexType, &index, SL("Index_type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 520); + if (!(zephir_array_isset(&indexes, &keyName))) { + ZEPHIR_INIT_NVAR(&_6$$4); + array_init(&_6$$4); + zephir_array_update_zval(&indexes, &keyName, &_6$$4, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch(&_7$$3, &indexes, &keyName, PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 526); + if (!(zephir_array_isset_string(&_7$$3, SL("columns")))) { + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + } else { + zephir_array_fetch(&_8$$6, &indexes, &keyName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 529); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_8$$6, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 529); + } + zephir_array_fetch_string(&_9$$3, &index, SL("Column_name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 532); + zephir_array_append(&columns, &_9$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 532); + zephir_array_update_multi(&indexes, &columns, SL("zs"), 3, &keyName, SL("columns")); + zephir_array_fetch_string(&_10$$3, &index, SL("Non_unique"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 539); + if (ZEPHIR_IS_STRING(&keyName, "PRIMARY")) { + ZEPHIR_INIT_NVAR(&_11$$7); + ZVAL_STRING(&_11$$7, "PRIMARY"); + zephir_array_update_multi(&indexes, &_11$$7, SL("zs"), 3, &keyName, SL("type")); + } else if (ZEPHIR_IS_STRING(&indexType, "FULLTEXT")) { + ZEPHIR_INIT_NVAR(&_12$$8); + ZVAL_STRING(&_12$$8, "FULLTEXT"); + zephir_array_update_multi(&indexes, &_12$$8, SL("zs"), 3, &keyName, SL("type")); + } else if (ZEPHIR_IS_LONG(&_10$$3, 0)) { + ZEPHIR_INIT_NVAR(&_13$$9); + ZVAL_STRING(&_13$$9, "UNIQUE"); + zephir_array_update_multi(&indexes, &_13$$9, SL("zs"), 3, &keyName, SL("type")); + } else { + ZEPHIR_INIT_NVAR(&_14$$10); + ZVAL_STRING(&_14$$10, ""); + zephir_array_update_multi(&indexes, &_14$$10, SL("zs"), 3, &keyName, SL("type")); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&index, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&keyName); + zephir_array_fetch_string(&keyName, &index, SL("Key_name"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 519); + ZEPHIR_OBS_NVAR(&indexType); + zephir_array_fetch_string(&indexType, &index, SL("Index_type"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 520); + if (!(zephir_array_isset(&indexes, &keyName))) { + ZEPHIR_INIT_NVAR(&_15$$12); + array_init(&_15$$12); + zephir_array_update_zval(&indexes, &keyName, &_15$$12, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch(&_16$$11, &indexes, &keyName, PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 526); + if (!(zephir_array_isset_string(&_16$$11, SL("columns")))) { + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); } else { - ZVAL_LONG(&field, _3$$3); + zephir_array_fetch(&_17$$14, &indexes, &keyName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 529); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_17$$14, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 529); } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _1$$3); - if (UNEXPECTED(!(zephir_array_isset(&referencedFields, &position)))) { - ZEPHIR_INIT_NVAR(&_5$$5); - object_init_ex(&_5$$5, phalcon_mvc_model_exception_ce); - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$5); - ZEPHIR_CONCAT_SVSVSV(&_7$$5, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_6$$5); - ZEPHIR_CALL_METHOD(NULL, &_5$$5, "__construct", &_8, 32, &_7$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$5, "phalcon/Mvc/Model/Query.zep", 2770); - ZEPHIR_MM_RESTORE(); - return; + zephir_array_fetch_string(&_18$$11, &index, SL("Column_name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 532); + zephir_array_append(&columns, &_18$$11, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 532); + zephir_array_update_multi(&indexes, &columns, SL("zs"), 3, &keyName, SL("columns")); + zephir_array_fetch_string(&_19$$11, &index, SL("Non_unique"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 539); + if (ZEPHIR_IS_STRING(&keyName, "PRIMARY")) { + ZEPHIR_INIT_NVAR(&_20$$15); + ZVAL_STRING(&_20$$15, "PRIMARY"); + zephir_array_update_multi(&indexes, &_20$$15, SL("zs"), 3, &keyName, SL("type")); + } else if (ZEPHIR_IS_STRING(&indexType, "FULLTEXT")) { + ZEPHIR_INIT_NVAR(&_21$$16); + ZVAL_STRING(&_21$$16, "FULLTEXT"); + zephir_array_update_multi(&indexes, &_21$$16, SL("zs"), 3, &keyName, SL("type")); + } else if (ZEPHIR_IS_LONG(&_19$$11, 0)) { + ZEPHIR_INIT_NVAR(&_22$$17); + ZVAL_STRING(&_22$$17, "UNIQUE"); + zephir_array_update_multi(&indexes, &_22$$17, SL("zs"), 3, &keyName, SL("type")); + } else { + ZEPHIR_INIT_NVAR(&_23$$18); + ZVAL_STRING(&_23$$18, ""); + zephir_array_update_multi(&indexes, &_23$$18, SL("zs"), 3, &keyName, SL("type")); } - ZEPHIR_OBS_NVAR(&intermediateField); - zephir_array_fetch(&intermediateField, &intermediateFields, &position, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2776); - ZEPHIR_INIT_NVAR(&sqlEqualsJoinCondition); - zephir_create_array(&sqlEqualsJoinCondition, 4, 0); - add_assoc_stringl_ex(&sqlEqualsJoinCondition, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&sqlEqualsJoinCondition, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_10$$4); - zephir_create_array(&_10$$4, 3, 0); - add_assoc_long_ex(&_10$$4, SL("type"), 355); - zephir_array_update_string(&_10$$4, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10$$4, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getqualified", &_11, 460, &_10$$4); - zephir_check_call_status(); - zephir_array_update_string(&sqlEqualsJoinCondition, SL("left"), &_9$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_12$$4); - zephir_create_array(&_12$$4, 3, 0); - add_assoc_stringl_ex(&_12$$4, SL("type"), SL("qualified")); - zephir_array_update_string(&_12$$4, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_12$$4, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getqualified", &_11, 460, &_12$$4); - zephir_check_call_status(); - zephir_array_update_string(&sqlEqualsJoinCondition, SL("right"), &_9$$4, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$3, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &fields, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_array_isset(&referencedFields, &position)))) { - ZEPHIR_INIT_NVAR(&_13$$7); - object_init_ex(&_13$$7, phalcon_mvc_model_exception_ce); - zephir_read_property(&_14$$7, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_15$$7); - ZEPHIR_CONCAT_SVSVSV(&_15$$7, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_14$$7); - ZEPHIR_CALL_METHOD(NULL, &_13$$7, "__construct", &_8, 32, &_15$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$7, "phalcon/Mvc/Model/Query.zep", 2770); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&intermediateField); - zephir_array_fetch(&intermediateField, &intermediateFields, &position, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2776); - ZEPHIR_INIT_NVAR(&_16$$6); - zephir_create_array(&_16$$6, 4, 0); - add_assoc_stringl_ex(&_16$$6, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_16$$6, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_18$$6); - zephir_create_array(&_18$$6, 3, 0); - add_assoc_long_ex(&_18$$6, SL("type"), 355); - zephir_array_update_string(&_18$$6, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_18$$6, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_17$$6, this_ptr, "getqualified", &_11, 460, &_18$$6); - zephir_check_call_status(); - zephir_array_update_string(&_16$$6, SL("left"), &_17$$6, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_19$$6); - zephir_create_array(&_19$$6, 3, 0); - add_assoc_stringl_ex(&_19$$6, SL("type"), SL("qualified")); - zephir_array_update_string(&_19$$6, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_19$$6, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_17$$6, this_ptr, "getqualified", &_11, 460, &_19$$6); - zephir_check_call_status(); - zephir_array_update_string(&_16$$6, SL("right"), &_17$$6, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&sqlEqualsJoinCondition, &_16$$6); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&field); + } + ZEPHIR_INIT_NVAR(&index); + ZEPHIR_INIT_VAR(&indexObjects); + array_init(&indexObjects); + zephir_is_iterable(&indexes, 0, "phalcon/Db/Adapter/Pdo/Mysql.zep", 556); + if (Z_TYPE_P(&indexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&indexes), _26, _27, _24) + { + ZEPHIR_INIT_NVAR(&name); + if (_27 != NULL) { + ZVAL_STR_COPY(&name, _27); + } else { + ZVAL_LONG(&name, _26); + } + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _24); + ZEPHIR_INIT_NVAR(&_28$$19); + object_init_ex(&_28$$19, phalcon_db_index_ce); + zephir_array_fetch_string(&_29$$19, &index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 551); + zephir_array_fetch_string(&_30$$19, &index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 553); + ZEPHIR_CALL_METHOD(NULL, &_28$$19, "__construct", &_31, 33, &name, &_29$$19, &_30$$19); + zephir_check_call_status(); + zephir_array_update_zval(&indexObjects, &name, &_28$$19, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&_20$$8); - zephir_create_array(&_20$$8, 2, 0); - ZEPHIR_INIT_VAR(&_21$$8); - zephir_create_array(&_21$$8, 3, 0); - zephir_array_update_string(&_21$$8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_22$$8); - zephir_create_array(&_22$$8, 2, 0); - zephir_array_fast_append(&_22$$8, &intermediateSource); - zephir_array_fast_append(&_22$$8, &intermediateSchema); - zephir_array_update_string(&_21$$8, SL("source"), &_22$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_22$$8); - zephir_create_array(&_22$$8, 1, 0); - ZEPHIR_INIT_VAR(&_23$$8); - zephir_create_array(&_23$$8, 4, 0); - add_assoc_stringl_ex(&_23$$8, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_23$$8, SL("op"), SL("=")); - ZEPHIR_INIT_VAR(&_25$$8); - zephir_create_array(&_25$$8, 3, 0); - add_assoc_long_ex(&_25$$8, SL("type"), 355); - zephir_array_update_string(&_25$$8, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_25$$8, SL("name"), &fields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 460, &_25$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("left"), &_24$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_26$$8); - zephir_create_array(&_26$$8, 3, 0); - add_assoc_stringl_ex(&_26$$8, SL("type"), SL("qualified")); - zephir_array_update_string(&_26$$8, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_26$$8, SL("name"), &intermediateFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 460, &_26$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("right"), &_24$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_22$$8, &_23$$8); - zephir_array_update_string(&_21$$8, SL("conditions"), &_22$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_20$$8, &_21$$8); - ZEPHIR_INIT_NVAR(&_21$$8); - zephir_create_array(&_21$$8, 3, 0); - zephir_array_update_string(&_21$$8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$8, SL("source"), joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_22$$8); - zephir_create_array(&_22$$8, 1, 0); - ZEPHIR_INIT_NVAR(&_23$$8); - zephir_create_array(&_23$$8, 4, 0); - add_assoc_stringl_ex(&_23$$8, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_23$$8, SL("op"), SL("=")); - ZEPHIR_INIT_VAR(&_27$$8); - zephir_create_array(&_27$$8, 3, 0); - add_assoc_long_ex(&_27$$8, SL("type"), 355); - zephir_array_update_string(&_27$$8, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_27$$8, SL("name"), &intermediateReferencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 460, &_27$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("left"), &_24$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_28$$8); - zephir_create_array(&_28$$8, 3, 0); - add_assoc_stringl_ex(&_28$$8, SL("type"), SL("qualified")); - zephir_array_update_string(&_28$$8, SL("domain"), &referencedModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_28$$8, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 460, &_28$$8); + ZEPHIR_CALL_METHOD(NULL, &indexes, "rewind", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("right"), &_24$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_22$$8, &_23$$8); - zephir_array_update_string(&_21$$8, SL("conditions"), &_22$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_20$$8, &_21$$8); - ZEPHIR_CPY_WRT(&sqlJoins, &_20$$8); + while (1) { + ZEPHIR_CALL_METHOD(&_25, &indexes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_25)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &indexes, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&index, &indexes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_32$$20); + object_init_ex(&_32$$20, phalcon_db_index_ce); + zephir_array_fetch_string(&_33$$20, &index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 551); + zephir_array_fetch_string(&_34$$20, &index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 553); + ZEPHIR_CALL_METHOD(NULL, &_32$$20, "__construct", &_31, 33, &name, &_33$$20, &_34$$20); + zephir_check_call_status(); + zephir_array_update_zval(&indexObjects, &name, &_32$$20, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &indexes, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CTOR(&sqlJoins); + ZEPHIR_INIT_NVAR(&index); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&indexObjects); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getOrderClause) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeReferences) { - zval orderParts, orderPartSort; + zval _14$$3, _23$$6, _29$$9, _33$$10; + zend_string *_27; + zend_ulong _26; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; + zephir_fcall_cache_entry *_31 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *order, order_sub, orderColumns, orderItem, orderPartExpr, orderSort, *_0, _1, _2$$5, _4$$7, _5$$8, _6$$8, _7$$9, _8$$10, _9$$12, _10$$12, _11$$13, _12$$13, _13$$14; + zval *table_param = NULL, *schema_param = NULL, references, reference, arrayReference, constraintName, referenceObjects, name, referencedSchema, referencedTable, columns, referencedColumns, referenceUpdate, referenceDelete, _0, _1, _2, _3, *_4, _5, *_24, _25, _6$$5, _7$$5, _8$$5, _9$$5, _10$$5, _11$$5, _12$$3, _13$$3, _15$$8, _16$$8, _17$$8, _18$$8, _19$$8, _20$$8, _21$$6, _22$$6, _28$$9, _30$$9, _32$$10, _34$$10; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&order_sub); - ZVAL_UNDEF(&orderColumns); - ZVAL_UNDEF(&orderItem); - ZVAL_UNDEF(&orderPartExpr); - ZVAL_UNDEF(&orderSort); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&arrayReference); + ZVAL_UNDEF(&constraintName); + ZVAL_UNDEF(&referenceObjects); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&referencedSchema); + ZVAL_UNDEF(&referencedTable); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&referencedColumns); + ZVAL_UNDEF(&referenceUpdate); + ZVAL_UNDEF(&referenceDelete); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$8); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$12); - ZVAL_UNDEF(&_10$$12); - ZVAL_UNDEF(&_11$$13); - ZVAL_UNDEF(&_12$$13); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&orderParts); - ZVAL_UNDEF(&orderPartSort); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_25); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_18$$8); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_20$$8); + ZVAL_UNDEF(&_21$$6); + ZVAL_UNDEF(&_22$$6); + ZVAL_UNDEF(&_28$$9); + ZVAL_UNDEF(&_30$$9); + ZVAL_UNDEF(&_32$$10); + ZVAL_UNDEF(&_34$$10); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_23$$6); + ZVAL_UNDEF(&_29$$9); + ZVAL_UNDEF(&_33$$10); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(order) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &order); - - - if (!(zephir_array_isset_long(order, 0))) { - ZEPHIR_INIT_VAR(&orderColumns); - zephir_create_array(&orderColumns, 1, 0); - zephir_array_fast_append(&orderColumns, order); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_CPY_WRT(&orderColumns, order); + ZEPHIR_INIT_VAR(&table); } - ZEPHIR_INIT_VAR(&orderParts); - array_init(&orderParts); - zephir_is_iterable(&orderColumns, 0, "phalcon/Mvc/Model/Query.zep", 2912); - if (Z_TYPE_P(&orderColumns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&orderColumns), _0) + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); + } + } + + + ZEPHIR_INIT_VAR(&references); + array_init(&references); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describereferences", NULL, 0, &table, &schema); + zephir_check_call_status(); + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); + zephir_check_call_status(); + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/Pdo/Mysql.zep", 609); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _4) { - ZEPHIR_INIT_NVAR(&orderItem); - ZVAL_COPY(&orderItem, _0); - zephir_array_fetch_string(&_2$$5, &orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2894); - ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "getexpression", &_3, 459, &_2$$5); + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _4); + zephir_array_fetch_long(&constraintName, &reference, 2, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 578); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_long(&referencedSchema, &reference, 3, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 581); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 582); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_long(&referenceUpdate, &reference, 6, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 583); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_long(&referenceDelete, &reference, 7, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 584); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); + } else { + zephir_array_fetch(&_6$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 588); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_6$$5, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 588); + zephir_array_fetch(&_7$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 589); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_7$$5, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 589); + zephir_array_fetch(&_8$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 590); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_8$$5, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 590); + zephir_array_fetch(&_9$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 591); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_9$$5, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 591); + zephir_array_fetch(&_10$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 592); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_string(&referenceUpdate, &_10$$5, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 592); + zephir_array_fetch(&_11$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 593); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_string(&referenceDelete, &_11$$5, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 593); + } + zephir_array_fetch_long(&_12$$3, &reference, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 596); + zephir_array_append(&columns, &_12$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 596); + zephir_array_fetch_long(&_13$$3, &reference, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 597); + zephir_array_append(&referencedColumns, &_13$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 597); + ZEPHIR_INIT_NVAR(&_14$$3); + zephir_create_array(&_14$$3, 6, 0); + zephir_array_update_string(&_14$$3, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("onUpdate"), &referenceUpdate, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("onDelete"), &referenceDelete, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_14$$3, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); zephir_check_call_status(); - if (zephir_array_isset_string_fetch(&orderSort, &orderItem, SL("sort"), 1)) { - if (ZEPHIR_IS_LONG(&orderSort, 327)) { - ZEPHIR_INIT_NVAR(&orderPartSort); - zephir_create_array(&orderPartSort, 2, 0); - zephir_array_fast_append(&orderPartSort, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_4$$7); - ZVAL_STRING(&_4$$7, "ASC"); - zephir_array_fast_append(&orderPartSort, &_4$$7); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&reference, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&constraintName); + zephir_array_fetch_long(&constraintName, &reference, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 578); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_long(&referencedSchema, &reference, 3, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 581); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 582); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_long(&referenceUpdate, &reference, 6, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 583); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_long(&referenceDelete, &reference, 7, PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 584); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); } else { - ZEPHIR_INIT_NVAR(&_5$$8); - zephir_create_array(&_5$$8, 2, 0); - zephir_array_fast_append(&_5$$8, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_6$$8); - ZVAL_STRING(&_6$$8, "DESC"); - zephir_array_fast_append(&_5$$8, &_6$$8); - ZEPHIR_CPY_WRT(&orderPartSort, &_5$$8); + zephir_array_fetch(&_15$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 588); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_15$$8, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 588); + zephir_array_fetch(&_16$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 589); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_16$$8, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 589); + zephir_array_fetch(&_17$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 590); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_17$$8, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 590); + zephir_array_fetch(&_18$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 591); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_18$$8, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 591); + zephir_array_fetch(&_19$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 592); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_string(&referenceUpdate, &_19$$8, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 592); + zephir_array_fetch(&_20$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 593); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_string(&referenceDelete, &_20$$8, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 593); } + zephir_array_fetch_long(&_21$$6, &reference, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 596); + zephir_array_append(&columns, &_21$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 596); + zephir_array_fetch_long(&_22$$6, &reference, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 597); + zephir_array_append(&referencedColumns, &_22$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Mysql.zep", 597); + ZEPHIR_INIT_NVAR(&_23$$6); + zephir_create_array(&_23$$6, 6, 0); + zephir_array_update_string(&_23$$6, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("onUpdate"), &referenceUpdate, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("onDelete"), &referenceDelete, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_23$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&reference); + ZEPHIR_INIT_VAR(&referenceObjects); + array_init(&referenceObjects); + zephir_is_iterable(&references, 0, "phalcon/Db/Adapter/Pdo/Mysql.zep", 624); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&references), _26, _27, _24) + { + ZEPHIR_INIT_NVAR(&name); + if (_27 != NULL) { + ZVAL_STR_COPY(&name, _27); } else { - ZEPHIR_INIT_NVAR(&_7$$9); - zephir_create_array(&_7$$9, 1, 0); - zephir_array_fast_append(&_7$$9, &orderPartExpr); - ZEPHIR_CPY_WRT(&orderPartSort, &_7$$9); + ZVAL_LONG(&name, _26); } - zephir_array_append(&orderParts, &orderPartSort, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2909); + ZEPHIR_INIT_NVAR(&arrayReference); + ZVAL_COPY(&arrayReference, _24); + ZEPHIR_INIT_NVAR(&_28$$9); + object_init_ex(&_28$$9, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_29$$9); + zephir_create_array(&_29$$9, 6, 0); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 614); + zephir_array_update_string(&_29$$9, SL("referencedSchema"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 615); + zephir_array_update_string(&_29$$9, SL("referencedTable"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 616); + zephir_array_update_string(&_29$$9, SL("columns"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 617); + zephir_array_update_string(&_29$$9, SL("referencedColumns"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 618); + zephir_array_update_string(&_29$$9, SL("onUpdate"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 620); + zephir_array_update_string(&_29$$9, SL("onDelete"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_28$$9, "__construct", &_31, 34, &name, &_29$$9); + zephir_check_call_status(); + zephir_array_update_zval(&referenceObjects, &name, &_28$$9, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &orderColumns, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &orderColumns, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_25, &references, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1)) { + if (!zend_is_true(&_25)) { break; } - ZEPHIR_CALL_METHOD(&orderItem, &orderColumns, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&name, &references, "key", NULL, 0); zephir_check_call_status(); - zephir_array_fetch_string(&_8$$10, &orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2894); - ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "getexpression", &_3, 459, &_8$$10); + ZEPHIR_CALL_METHOD(&arrayReference, &references, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_32$$10); + object_init_ex(&_32$$10, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_33$$10); + zephir_create_array(&_33$$10, 6, 0); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 614); + zephir_array_update_string(&_33$$10, SL("referencedSchema"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 615); + zephir_array_update_string(&_33$$10, SL("referencedTable"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 616); + zephir_array_update_string(&_33$$10, SL("columns"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 617); + zephir_array_update_string(&_33$$10, SL("referencedColumns"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 618); + zephir_array_update_string(&_33$$10, SL("onUpdate"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Mysql.zep", 620); + zephir_array_update_string(&_33$$10, SL("onDelete"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_32$$10, "__construct", &_31, 34, &name, &_33$$10); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&orderSort); - if (zephir_array_isset_string_fetch(&orderSort, &orderItem, SL("sort"), 0)) { - if (ZEPHIR_IS_LONG(&orderSort, 327)) { - ZEPHIR_INIT_NVAR(&_9$$12); - zephir_create_array(&_9$$12, 2, 0); - zephir_array_fast_append(&_9$$12, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_10$$12); - ZVAL_STRING(&_10$$12, "ASC"); - zephir_array_fast_append(&_9$$12, &_10$$12); - ZEPHIR_CPY_WRT(&orderPartSort, &_9$$12); - } else { - ZEPHIR_INIT_NVAR(&_11$$13); - zephir_create_array(&_11$$13, 2, 0); - zephir_array_fast_append(&_11$$13, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_12$$13); - ZVAL_STRING(&_12$$13, "DESC"); - zephir_array_fast_append(&_11$$13, &_12$$13); - ZEPHIR_CPY_WRT(&orderPartSort, &_11$$13); - } - } else { - ZEPHIR_INIT_NVAR(&_13$$14); - zephir_create_array(&_13$$14, 1, 0); - zephir_array_fast_append(&_13$$14, &orderPartExpr); - ZEPHIR_CPY_WRT(&orderPartSort, &_13$$14); - } - zephir_array_append(&orderParts, &orderPartSort, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2909); - ZEPHIR_CALL_METHOD(NULL, &orderColumns, "next", NULL, 0); + zephir_array_update_zval(&referenceObjects, &name, &_32$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&orderItem); - RETURN_CTOR(&orderParts); + ZEPHIR_INIT_NVAR(&arrayReference); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&referenceObjects); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getQualified) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, getDsnDefaults) +{ + zval *this_ptr = getThis(); + + + + zephir_create_array(return_value, 1, 0); + add_assoc_stringl_ex(return_value, SL("charset"), SL("utf8mb4")); + return; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Postgresql) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Postgresql, phalcon, db_adapter_pdo_postgresql, phalcon_db_adapter_pdo_abstractpdo_ce, phalcon_db_adapter_pdo_postgresql_method_entry, 0); + + zend_declare_property_string(phalcon_db_adapter_pdo_postgresql_ce, SL("dialectType"), "postgresql", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_db_adapter_pdo_postgresql_ce, SL("type"), "pgsql", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, __construct) { - zend_bool _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_22 = NULL, *_27 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, number = 0; - zval *expr_param = NULL, columnName, nestingLevel, sqlColumnAliases, metaData, sqlAliases, source, sqlAliasesModelsInstances, realColumnName, columnDomain, model, models, columnMap, hasModel, className, _0, _5, _6, _1$$3, _2$$3, _7$$6, _8$$7, _9$$7, _10$$7, _11$$8, _12$$9, _13$$9, _14$$9, _15$$12, _16$$12, _17$$12, _18$$14, *_19$$14, _20$$14, _34$$14, _21$$15, _23$$17, _24$$17, _25$$17, _26$$18, _28$$20, _29$$20, _30$$20, _31$$21, _32$$21, _33$$21, _35$$23, _36$$23, _37$$23, _38$$27, _39$$27, _40$$27; - zval expr; + zephir_fcall_cache_entry *_1 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *descriptor_param = NULL, _0$$3; + zval descriptor; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&columnName); - ZVAL_UNDEF(&nestingLevel); - ZVAL_UNDEF(&sqlColumnAliases); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&realColumnName); - ZVAL_UNDEF(&columnDomain); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&hasModel); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_15$$12); - ZVAL_UNDEF(&_16$$12); - ZVAL_UNDEF(&_17$$12); - ZVAL_UNDEF(&_18$$14); - ZVAL_UNDEF(&_20$$14); - ZVAL_UNDEF(&_34$$14); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_23$$17); - ZVAL_UNDEF(&_24$$17); - ZVAL_UNDEF(&_25$$17); - ZVAL_UNDEF(&_26$$18); - ZVAL_UNDEF(&_28$$20); - ZVAL_UNDEF(&_29$$20); - ZVAL_UNDEF(&_30$$20); - ZVAL_UNDEF(&_31$$21); - ZVAL_UNDEF(&_32$$21); - ZVAL_UNDEF(&_33$$21); - ZVAL_UNDEF(&_35$$23); - ZVAL_UNDEF(&_36$$23); - ZVAL_UNDEF(&_37$$23); - ZVAL_UNDEF(&_38$$27); - ZVAL_UNDEF(&_39$$27); - ZVAL_UNDEF(&_40$$27); + ZVAL_UNDEF(&descriptor); + ZVAL_UNDEF(&_0$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) + Z_PARAM_ARRAY(descriptor) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); + zephir_fetch_params(1, 1, 0, &descriptor_param); + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); - ZEPHIR_OBS_VAR(&columnName); - zephir_array_fetch_string(&columnName, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2926); - zephir_read_property(&_0, this_ptr, ZEND_STRL("nestingLevel"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&nestingLevel, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &nestingLevel)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &nestingLevel, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2934); - ZEPHIR_CPY_WRT(&sqlColumnAliases, &_2$$3); - } else { - ZEPHIR_INIT_NVAR(&sqlColumnAliases); - array_init(&sqlColumnAliases); - } - _3 = zephir_array_isset(&sqlColumnAliases, &columnName); - if (_3) { - _4 = !(zephir_array_isset_string(&expr, SL("domain"))); - if (!(_4)) { - zephir_array_fetch_string(&_5, &expr, SL("domain"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2939); - _4 = ZEPHIR_IS_EMPTY(&_5); - } - _3 = _4; - } - if (_3) { - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("qualified")); - zephir_array_update_string(return_value, SL("name"), &columnName, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - zephir_read_property(&_6, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_6); - ZEPHIR_OBS_VAR(&columnDomain); - if (zephir_array_isset_string_fetch(&columnDomain, &expr, SL("domain"), 0)) { - zephir_read_property(&_7$$6, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliases, &_7$$6); - ZEPHIR_OBS_VAR(&source); - if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &sqlAliases, &columnDomain, 0)))) { - ZEPHIR_INIT_VAR(&_8$$7); - object_init_ex(&_8$$7, phalcon_mvc_model_exception_ce); - zephir_read_property(&_9$$7, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_10$$7); - ZEPHIR_CONCAT_SVSV(&_10$$7, "Unknown model or alias '", &columnDomain, "' (11), when preparing: ", &_9$$7); - ZEPHIR_CALL_METHOD(NULL, &_8$$7, "__construct", NULL, 32, &_10$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$7, "phalcon/Mvc/Model/Query.zep", 2960); - ZEPHIR_MM_RESTORE(); - return; - } - if (ZEPHIR_GLOBAL(orm).column_renaming) { - zephir_read_property(&_11$$8, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModelsInstances, &_11$$8); - ZEPHIR_OBS_VAR(&model); - if (UNEXPECTED(!(zephir_array_isset_fetch(&model, &sqlAliasesModelsInstances, &columnDomain, 0)))) { - ZEPHIR_INIT_VAR(&_12$$9); - object_init_ex(&_12$$9, phalcon_mvc_model_exception_ce); - zephir_read_property(&_13$$9, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$9); - ZEPHIR_CONCAT_SVSV(&_14$$9, "There is no model related to model or alias '", &columnDomain, "', when executing: ", &_13$$9); - ZEPHIR_CALL_METHOD(NULL, &_12$$9, "__construct", NULL, 32, &_14$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$9, "phalcon/Mvc/Model/Query.zep", 2979); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &model); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&realColumnName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&realColumnName, &columnMap, &columnName, 0)))) { - ZEPHIR_INIT_VAR(&_15$$12); - object_init_ex(&_15$$12, phalcon_mvc_model_exception_ce); - zephir_read_property(&_16$$12, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_17$$12); - ZEPHIR_CONCAT_SVSVSV(&_17$$12, "Column '", &columnName, "' doesn't belong to the model or alias '", &columnDomain, "', when executing: ", &_16$$12); - ZEPHIR_CALL_METHOD(NULL, &_15$$12, "__construct", NULL, 32, &_17$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_15$$12, "phalcon/Mvc/Model/Query.zep", 2991); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&realColumnName, &columnName); - } - } else { - number = 0; - ZEPHIR_INIT_VAR(&hasModel); - ZVAL_BOOL(&hasModel, 0); - zephir_read_property(&_18$$14, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_18$$14, 0, "phalcon/Mvc/Model/Query.zep", 3025); - if (Z_TYPE_P(&_18$$14) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_18$$14), _19$$14) - { - ZEPHIR_INIT_NVAR(&model); - ZVAL_COPY(&model, _19$$14); - ZEPHIR_CALL_METHOD(&_21$$15, &metaData, "hasattribute", &_22, 0, &model, &columnName); - zephir_check_call_status(); - if (zephir_is_true(&_21$$15)) { - number++; - if (UNEXPECTED(number > 1)) { - ZEPHIR_INIT_NVAR(&_23$$17); - object_init_ex(&_23$$17, phalcon_mvc_model_exception_ce); - zephir_read_property(&_24$$17, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_25$$17); - ZEPHIR_CONCAT_SVSV(&_25$$17, "The column '", &columnName, "' is ambiguous, when preparing: ", &_24$$17); - ZEPHIR_CALL_METHOD(NULL, &_23$$17, "__construct", NULL, 32, &_25$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$17, "phalcon/Mvc/Model/Query.zep", 3014); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CPY_WRT(&hasModel, &model); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_18$$14, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20$$14, &_18$$14, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20$$14)) { - break; - } - ZEPHIR_CALL_METHOD(&model, &_18$$14, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_26$$18, &metaData, "hasattribute", &_27, 0, &model, &columnName); - zephir_check_call_status(); - if (zephir_is_true(&_26$$18)) { - number++; - if (UNEXPECTED(number > 1)) { - ZEPHIR_INIT_NVAR(&_28$$20); - object_init_ex(&_28$$20, phalcon_mvc_model_exception_ce); - zephir_read_property(&_29$$20, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_30$$20); - ZEPHIR_CONCAT_SVSV(&_30$$20, "The column '", &columnName, "' is ambiguous, when preparing: ", &_29$$20); - ZEPHIR_CALL_METHOD(NULL, &_28$$20, "__construct", NULL, 32, &_30$$20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_28$$20, "phalcon/Mvc/Model/Query.zep", 3014); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CPY_WRT(&hasModel, &model); - } - ZEPHIR_CALL_METHOD(NULL, &_18$$14, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&model); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&hasModel))) { - ZEPHIR_INIT_VAR(&_31$$21); - object_init_ex(&_31$$21, phalcon_mvc_model_exception_ce); - zephir_read_property(&_32$$21, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_33$$21); - ZEPHIR_CONCAT_SVSV(&_33$$21, "Column '", &columnName, "' doesn't belong to any of the selected models (1), when preparing: ", &_32$$21); - ZEPHIR_CALL_METHOD(NULL, &_31$$21, "__construct", NULL, 32, &_33$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_31$$21, "phalcon/Mvc/Model/Query.zep", 3028); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_34$$14, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_34$$14); - if (UNEXPECTED(Z_TYPE_P(&models) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The models list was not loaded correctly", "phalcon/Mvc/Model/Query.zep", 3039); - return; - } - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, &hasModel, 0); - ZEPHIR_OBS_NVAR(&source); - if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &models, &className, 0)))) { - ZEPHIR_INIT_VAR(&_35$$23); - object_init_ex(&_35$$23, phalcon_mvc_model_exception_ce); - zephir_read_property(&_36$$23, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_37$$23); - ZEPHIR_CONCAT_SVSV(&_37$$23, "Can't obtain model's source from models list: '", &className, "', when preparing: ", &_36$$23); - ZEPHIR_CALL_METHOD(NULL, &_35$$23, "__construct", NULL, 32, &_37$$23); - zephir_check_call_status(); - zephir_throw_exception_debug(&_35$$23, "phalcon/Mvc/Model/Query.zep", 3050); - ZEPHIR_MM_RESTORE(); - return; - } - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &hasModel); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&realColumnName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&realColumnName, &columnMap, &columnName, 0)))) { - ZEPHIR_INIT_VAR(&_38$$27); - object_init_ex(&_38$$27, phalcon_mvc_model_exception_ce); - zephir_read_property(&_39$$27, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_40$$27); - ZEPHIR_CONCAT_SVSV(&_40$$27, "Column '", &columnName, "' doesn't belong to any of the selected models (3), when preparing: ", &_39$$27); - ZEPHIR_CALL_METHOD(NULL, &_38$$27, "__construct", NULL, 32, &_40$$27); - zephir_check_call_status(); - zephir_throw_exception_debug(&_38$$27, "phalcon/Mvc/Model/Query.zep", 3069); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&realColumnName, &columnName); - } + if (zephir_array_isset_string(&descriptor, SL("charset"))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "Postgres does not allow the charset to be changed in the DSN."); + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_0$$3); + zephir_check_call_status(); } - zephir_create_array(return_value, 4, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("qualified")); - zephir_array_update_string(return_value, SL("domain"), &source, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("name"), &realColumnName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("balias"), &columnName, PH_COPY | PH_SEPARATE); - RETURN_MM(); + ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_postgresql_ce, getThis(), "__construct", &_1, 0, &descriptor); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getReadConnection) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, connect) { - zend_bool _1; + zend_bool _2$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval intermediate, bindParams, bindTypes; - zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, connection, transaction, _0; + zephir_fcall_cache_entry *_4 = NULL; + zval *descriptor_param = NULL, __$null, schema, sql, _0$$3, _1$$6, _3$$6; + zval descriptor; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&descriptor); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_3$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + Z_PARAM_ARRAY(descriptor) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 3, &model, &intermediate_param, &bindParams_param, &bindTypes_param); - if (!intermediate_param) { - ZEPHIR_INIT_VAR(&intermediate); - } else { - zephir_get_arrval(&intermediate, intermediate_param); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); + zephir_fetch_params(1, 0, 1, &descriptor_param); + if (!descriptor_param) { + ZEPHIR_INIT_VAR(&descriptor); + array_init(&descriptor); } else { - zephir_get_arrval(&bindTypes, bindTypes_param); + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); } - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transaction, &_0); - _1 = Z_TYPE_P(&transaction) == IS_OBJECT; - if (_1) { - _1 = zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce); + if (ZEPHIR_IS_EMPTY(&descriptor)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("descriptor"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&descriptor, &_0$$3); } - if (_1) { - ZEPHIR_RETURN_CALL_METHOD(&transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_OBS_VAR(&schema); + if (zephir_array_isset_string_fetch(&schema, &descriptor, SL("schema"), 0)) { + zephir_array_unset_string(&descriptor, SL("schema"), PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&schema); + ZVAL_NULL(&schema); } - if ((zephir_method_exists_ex(model, ZEND_STRL("selectreadconnection")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&connection, model, "selectreadconnection", NULL, 0, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "selectReadConnection did not return a connection", "phalcon/Mvc/Model/Query.zep", 3113); - return; + if (zephir_array_isset_string(&descriptor, SL("password"))) { + ZEPHIR_OBS_VAR(&_1$$6); + zephir_array_fetch_string(&_1$$6, &descriptor, SL("password"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 85); + _2$$6 = Z_TYPE_P(&_1$$6) == IS_STRING; + if (_2$$6) { + zephir_array_fetch_string(&_3$$6, &descriptor, SL("password"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 85); + _2$$6 = zephir_fast_strlen_ev(&_3$$6) == 0; + } + if (_2$$6) { + zephir_array_update_string(&descriptor, SL("password"), &__$null, PH_COPY | PH_SEPARATE); } - RETURN_CCTOR(&connection); } - ZEPHIR_RETURN_CALL_METHOD(model, "getreadconnection", NULL, 0); + ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_postgresql_ce, getThis(), "connect", &_4, 0, &descriptor); zephir_check_call_status(); - RETURN_MM(); + if (!(ZEPHIR_IS_EMPTY(&schema))) { + ZEPHIR_INIT_VAR(&sql); + ZEPHIR_CONCAT_SVS(&sql, "SET search_path TO '", &schema, "'"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "execute", NULL, 0, &sql); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getRelatedRecords) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, createTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval intermediate, bindParams, bindTypes, _0, _1; - zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, selectIr, whereConditions, limitConditions, query, _2, _3, _4, _5, _6; + zval definition; + zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, sql, queries, query, exception, columns, _0, *_1$$6, _2$$6, _3$$7, _5$$9, _6$$5, _7$$12, _8$$12; + zval tableName, schemaName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&selectIr); - ZVAL_UNDEF(&whereConditions); - ZVAL_UNDEF(&limitConditions); + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&queries); ZVAL_UNDEF(&query); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&columns); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$6); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$12); + ZVAL_UNDEF(&_8$$12); + ZVAL_UNDEF(&definition); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_ARRAY(definition) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, &model, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); + zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); + } else { + ZEPHIR_INIT_VAR(&tableName); + } + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); + } else { + ZEPHIR_INIT_VAR(&schemaName); + } + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - ZEPHIR_INIT_VAR(&selectIr); - zephir_create_array(&selectIr, 3, 0); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 3, 0); - add_assoc_stringl_ex(&_1, SL("type"), SL("object")); - ZEPHIR_INIT_VAR(&_2); - zephir_get_class(&_2, model, 0); - zephir_array_update_string(&_1, SL("model"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_3, model, "getsource", NULL, 0); - zephir_check_call_status(); - zephir_array_update_string(&_1, SL("column"), &_3, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_0, &_1); - zephir_array_update_string(&selectIr, SL("columns"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_VAR(&_4); - zephir_array_fetch_string(&_4, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3143); - zephir_array_update_string(&selectIr, SL("models"), &_4, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_4); - zephir_array_fetch_string(&_4, &intermediate, SL("tables"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3145); - zephir_array_update_string(&selectIr, SL("tables"), &_4, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_VAR(&whereConditions); - if (zephir_array_isset_string_fetch(&whereConditions, &intermediate, SL("where"), 0)) { - zephir_array_update_string(&selectIr, SL("where"), &whereConditions, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_VAR(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/Db/Adapter/Pdo/Postgresql.zep", 107); + return; } - ZEPHIR_OBS_VAR(&limitConditions); - if (zephir_array_isset_string_fetch(&limitConditions, &intermediate, SL("limit"), 0)) { - zephir_array_update_string(&selectIr, SL("limit"), &limitConditions, PH_COPY | PH_SEPARATE); + if (UNEXPECTED(!(zephir_fast_count_int(&columns)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/Db/Adapter/Pdo/Postgresql.zep", 111); + return; } - ZEPHIR_INIT_VAR(&query); - object_init_ex(&query, phalcon_mvc_model_query_ce); - ZEPHIR_CALL_METHOD(NULL, &query, "__construct", NULL, 468); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&sql, &_0, "createtable", NULL, 0, &tableName, &schemaName, &definition); zephir_check_call_status(); - zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &query, "setdi", NULL, 469, &_5); - zephir_check_call_status(); - ZVAL_LONG(&_6, 309); - ZEPHIR_CALL_METHOD(NULL, &query, "settype", NULL, 470, &_6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &query, "setintermediate", NULL, 471, &selectIr); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 472, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSelectColumn) -{ - zend_string *_4$$4; - zend_ulong _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, columnType, sqlAliases, modelName, source, columnDomain, sqlColumnAlias, preparedAlias, sqlExprColumn, sqlAliasesModels, columnData, balias, eager, _19, _20, _0$$4, *_1$$4, _2$$4, _5$$5, _7$$6, _8$$7, _9$$7, _10$$8, _11$$10, _15$$10, _12$$11, _13$$11, _14$$11, _16$$15, _17$$16, _18$$18; - zval column, sqlColumns, sqlColumn; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&sqlColumns); - ZVAL_UNDEF(&sqlColumn); - ZVAL_UNDEF(&columnType); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&columnDomain); - ZVAL_UNDEF(&sqlColumnAlias); - ZVAL_UNDEF(&preparedAlias); - ZVAL_UNDEF(&sqlExprColumn); - ZVAL_UNDEF(&sqlAliasesModels); - ZVAL_UNDEF(&columnData); - ZVAL_UNDEF(&balias); - ZVAL_UNDEF(&eager); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_14$$11); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$18); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(column) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &column_param); - ZEPHIR_OBS_COPY_OR_DUP(&column, column_param); + ZEPHIR_INIT_VAR(&queries); + zephir_fast_explode_str(&queries, SL(";"), &sql, LONG_MAX); + if (zephir_fast_count_int(&queries) > 1) { + /* try_start_1: */ - ZEPHIR_OBS_VAR(&columnType); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columnType, &column, SL("type"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3185); - return; - } - ZEPHIR_INIT_VAR(&sqlColumns); - array_init(&sqlColumns); - ZEPHIR_OBS_VAR(&eager); - zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 0); - if (ZEPHIR_IS_LONG(&columnType, 352)) { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0$$4, 0, "phalcon/Mvc/Model/Query.zep", 3215); - if (Z_TYPE_P(&_0$$4) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0$$4), _3$$4, _4$$4, _1$$4) - { - ZEPHIR_INIT_NVAR(&modelName); - if (_4$$4 != NULL) { - ZVAL_STR_COPY(&modelName, _4$$4); - } else { - ZVAL_LONG(&modelName, _3$$4); - } - ZEPHIR_INIT_NVAR(&source); - ZVAL_COPY(&source, _1$$4); - ZEPHIR_INIT_NVAR(&sqlColumn); - zephir_create_array(&sqlColumn, 4, 0); - add_assoc_stringl_ex(&sqlColumn, SL("type"), SL("object")); - zephir_array_update_string(&sqlColumn, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("column"), &source, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_5$$5, "lcfirst", &_6, 76, &modelName); - zephir_check_call_status(); - zephir_array_update_string(&sqlColumn, SL("balias"), &_5$$5, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_7$$6, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3209); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_7$$6, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3212); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0$$4, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$4, &_0$$4, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&modelName, &_0$$4, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &_0$$4, "current", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + zephir_is_iterable(&queries, 0, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 130); + if (Z_TYPE_P(&queries) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queries), _1$$6) + { + ZEPHIR_INIT_NVAR(&query); + ZVAL_COPY(&query, _1$$6); + if (ZEPHIR_IS_EMPTY(&query)) { + continue; + } + ZEPHIR_INIT_NVAR(&_3$$7); + ZEPHIR_CONCAT_VS(&_3$$7, &query, ";"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_4, 0, &_3$$7); + zephir_check_call_status_or_jump(try_end_1); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &queries, "rewind", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$7); - zephir_create_array(&_8$$7, 4, 0); - add_assoc_stringl_ex(&_8$$7, SL("type"), SL("object")); - zephir_array_update_string(&_8$$7, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_8$$7, SL("column"), &source, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_9$$7, "lcfirst", &_6, 76, &modelName); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$6, &queries, "valid", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&_8$$7, SL("balias"), &_9$$7, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&sqlColumn, &_8$$7); - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_10$$8, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3209); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_10$$8, PH_COPY | PH_SEPARATE); + if (!zend_is_true(&_2$$6)) { + break; } - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3212); - ZEPHIR_CALL_METHOD(NULL, &_0$$4, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&query, &queries, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EMPTY(&query)) { + continue; + } + ZEPHIR_INIT_NVAR(&_5$$9); + ZEPHIR_CONCAT_VS(&_5$$9, &query, ";"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_4, 0, &_5$$9); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CALL_METHOD(NULL, &queries, "next", NULL, 0); + zephir_check_call_status(); + } } - } - ZEPHIR_INIT_NVAR(&source); - ZEPHIR_INIT_NVAR(&modelName); - RETURN_CTOR(&sqlColumns); - } - if (UNEXPECTED(!(zephir_array_isset_string(&column, SL("column"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3219); - return; - } - if (ZEPHIR_IS_LONG(&columnType, 353)) { - zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliases, &_11$$10); - ZEPHIR_OBS_VAR(&columnDomain); - zephir_array_fetch_string(&columnDomain, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3231); - ZEPHIR_OBS_NVAR(&source); - if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &sqlAliases, &columnDomain, 0)))) { - ZEPHIR_INIT_VAR(&_12$$11); - object_init_ex(&_12$$11, phalcon_mvc_model_exception_ce); - zephir_read_property(&_13$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$11); - ZEPHIR_CONCAT_SVSV(&_14$$11, "Unknown model or alias '", &columnDomain, "' (2), when preparing: ", &_13$$11); - ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", NULL, 32, &_14$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$11, "phalcon/Mvc/Model/Query.zep", 3236); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CPY_WRT(&sqlColumnAlias, &source); - ZEPHIR_OBS_VAR(&preparedAlias); - zephir_array_isset_string_fetch(&preparedAlias, &column, SL("balias"), 0); - zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModels, &_11$$10); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch(&modelName, &sqlAliasesModels, &columnDomain, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3250); - if (Z_TYPE_P(&preparedAlias) != IS_STRING) { - if (ZEPHIR_IS_EQUAL(&columnDomain, &modelName)) { - ZEPHIR_CALL_FUNCTION(&preparedAlias, "lcfirst", &_6, 76, &modelName); + ZEPHIR_INIT_NVAR(&query); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + RETURN_MM(); + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_6$$5); + ZVAL_OBJ(&_6$$5, EG(exception)); + Z_ADDREF_P(&_6$$5); + if (zephir_is_instance_of(&_6$$5, SL("Throwable"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&exception, &_6$$5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&preparedAlias, &columnDomain); + zephir_throw_exception_debug(&exception, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 134); + ZEPHIR_MM_RESTORE(); + return; } } - ZEPHIR_INIT_VAR(&_15$$10); - zephir_create_array(&_15$$10, 4, 0); - add_assoc_stringl_ex(&_15$$10, SL("type"), SL("object")); - zephir_array_update_string(&_15$$10, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$10, SL("column"), &sqlColumnAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$10, SL("balias"), &preparedAlias, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&sqlColumn, &_15$$10); - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_16$$15, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3277); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_16$$15, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3280); - RETURN_CTOR(&sqlColumns); - } - if (ZEPHIR_IS_LONG(&columnType, 354)) { - ZEPHIR_INIT_VAR(&_17$$16); - zephir_create_array(&_17$$16, 1, 0); - add_assoc_stringl_ex(&_17$$16, SL("type"), SL("scalar")); - ZEPHIR_CPY_WRT(&sqlColumn, &_17$$16); - ZEPHIR_OBS_VAR(&columnData); - zephir_array_fetch_string(&columnData, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3294); - ZEPHIR_CALL_METHOD(&sqlExprColumn, this_ptr, "getexpression", NULL, 459, &columnData); + } else { + zephir_array_fetch_long(&_7$$12, &queries, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 137); + ZEPHIR_INIT_VAR(&_8$$12); + ZEPHIR_CONCAT_VS(&_8$$12, &_7$$12, ";"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &_8$$12); zephir_check_call_status(); - ZEPHIR_OBS_VAR(&balias); - if (zephir_array_isset_string_fetch(&balias, &sqlExprColumn, SL("balias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &balias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &balias, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_18$$18, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3307); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_18$$18, PH_COPY | PH_SEPARATE); - } - zephir_array_update_string(&sqlColumn, SL("column"), &sqlExprColumn, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3311); - RETURN_CTOR(&sqlColumns); + RETURN_MM(); } - ZEPHIR_INIT_VAR(&_19); - object_init_ex(&_19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_20); - ZEPHIR_CONCAT_SV(&_20, "Unknown type of column ", &columnType); - ZEPHIR_CALL_METHOD(NULL, &_19, "__construct", NULL, 32, &_20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19, "phalcon/Mvc/Model/Query.zep", 3316); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleJoin) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns) { - zend_string *_8$$4; - zend_ulong _7$$4; - zval _1$$3, _3$$3, _4$$3, _13$$5, _15$$5, _16$$5, _20$$7, _22$$7, _23$$7; + zend_bool _5$$3, _64$$41; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_12 = NULL; + zephir_fcall_cache_entry *_55 = NULL, *_58 = NULL, *_62 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *joinType_param = NULL, *joinSource, joinSource_sub, *modelAlias_param = NULL, *joinAlias_param = NULL, *relation, relation_sub, fields, referencedFields, sqlJoinConditions, sqlJoinPartialConditions, position, field, referencedField, _0$$3, _2$$3, *_5$$4, _6$$4, _9$$6, _10$$6, _11$$6, _14$$5, _17$$8, _18$$8, _19$$8, _21$$7; - zval joinType, modelAlias, joinAlias; + zval *table_param = NULL, *schema_param = NULL, __$true, __$false, __$null, columns, columnType, fields, field, definition, oldColumn, columnName, charSize, numericSize, numericScale, _0, _1, _2, *_3, _4, _47$$3, _48$$3, _49$$3, _50$$3, _59$$3, _61$$3, _6$$4, _7$$4, _8$$5, _9$$5, _10$$6, _11$$6, _12$$7, _13$$7, _14$$8, _15$$8, _16$$9, _17$$9, _18$$10, _19$$11, _20$$12, _21$$12, _22$$13, _23$$13, _24$$14, _25$$14, _26$$15, _27$$15, _28$$16, _29$$16, _30$$17, _31$$18, _32$$19, _33$$20, _34$$21, _35$$22, _36$$23, _37$$24, _38$$25, _39$$26, _40$$27, _41$$28, _42$$29, _43$$30, _44$$31, _45$$31, _46$$32, _51$$38, _52$$38, _53$$38, _54$$38, _56$$38, _57$$38, _60$$40, _63$$41, _106$$41, _107$$41, _108$$41, _109$$41, _116$$41, _118$$41, _65$$42, _66$$42, _67$$43, _68$$43, _69$$44, _70$$44, _71$$45, _72$$45, _73$$46, _74$$46, _75$$47, _76$$47, _77$$48, _78$$49, _79$$50, _80$$50, _81$$51, _82$$51, _83$$52, _84$$52, _85$$53, _86$$53, _87$$54, _88$$54, _89$$55, _90$$56, _91$$57, _92$$58, _93$$59, _94$$60, _95$$61, _96$$62, _97$$63, _98$$64, _99$$65, _100$$66, _101$$67, _102$$68, _103$$69, _104$$69, _105$$70, _110$$76, _111$$76, _112$$76, _113$$76, _114$$76, _115$$76, _117$$78; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinSource_sub); - ZVAL_UNDEF(&relation_sub); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&columnType); ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&sqlJoinConditions); - ZVAL_UNDEF(&sqlJoinPartialConditions); - ZVAL_UNDEF(&position); ZVAL_UNDEF(&field); - ZVAL_UNDEF(&referencedField); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&oldColumn); + ZVAL_UNDEF(&columnName); + ZVAL_UNDEF(&charSize); + ZVAL_UNDEF(&numericSize); + ZVAL_UNDEF(&numericScale); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_47$$3); + ZVAL_UNDEF(&_48$$3); + ZVAL_UNDEF(&_49$$3); + ZVAL_UNDEF(&_50$$3); + ZVAL_UNDEF(&_59$$3); + ZVAL_UNDEF(&_61$$3); ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); ZVAL_UNDEF(&_10$$6); ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_17$$8); - ZVAL_UNDEF(&_18$$8); - ZVAL_UNDEF(&_19$$8); - ZVAL_UNDEF(&_21$$7); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_15$$5); - ZVAL_UNDEF(&_16$$5); - ZVAL_UNDEF(&_20$$7); - ZVAL_UNDEF(&_22$$7); - ZVAL_UNDEF(&_23$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$9); + ZVAL_UNDEF(&_17$$9); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_20$$12); + ZVAL_UNDEF(&_21$$12); + ZVAL_UNDEF(&_22$$13); + ZVAL_UNDEF(&_23$$13); + ZVAL_UNDEF(&_24$$14); + ZVAL_UNDEF(&_25$$14); + ZVAL_UNDEF(&_26$$15); + ZVAL_UNDEF(&_27$$15); + ZVAL_UNDEF(&_28$$16); + ZVAL_UNDEF(&_29$$16); + ZVAL_UNDEF(&_30$$17); + ZVAL_UNDEF(&_31$$18); + ZVAL_UNDEF(&_32$$19); + ZVAL_UNDEF(&_33$$20); + ZVAL_UNDEF(&_34$$21); + ZVAL_UNDEF(&_35$$22); + ZVAL_UNDEF(&_36$$23); + ZVAL_UNDEF(&_37$$24); + ZVAL_UNDEF(&_38$$25); + ZVAL_UNDEF(&_39$$26); + ZVAL_UNDEF(&_40$$27); + ZVAL_UNDEF(&_41$$28); + ZVAL_UNDEF(&_42$$29); + ZVAL_UNDEF(&_43$$30); + ZVAL_UNDEF(&_44$$31); + ZVAL_UNDEF(&_45$$31); + ZVAL_UNDEF(&_46$$32); + ZVAL_UNDEF(&_51$$38); + ZVAL_UNDEF(&_52$$38); + ZVAL_UNDEF(&_53$$38); + ZVAL_UNDEF(&_54$$38); + ZVAL_UNDEF(&_56$$38); + ZVAL_UNDEF(&_57$$38); + ZVAL_UNDEF(&_60$$40); + ZVAL_UNDEF(&_63$$41); + ZVAL_UNDEF(&_106$$41); + ZVAL_UNDEF(&_107$$41); + ZVAL_UNDEF(&_108$$41); + ZVAL_UNDEF(&_109$$41); + ZVAL_UNDEF(&_116$$41); + ZVAL_UNDEF(&_118$$41); + ZVAL_UNDEF(&_65$$42); + ZVAL_UNDEF(&_66$$42); + ZVAL_UNDEF(&_67$$43); + ZVAL_UNDEF(&_68$$43); + ZVAL_UNDEF(&_69$$44); + ZVAL_UNDEF(&_70$$44); + ZVAL_UNDEF(&_71$$45); + ZVAL_UNDEF(&_72$$45); + ZVAL_UNDEF(&_73$$46); + ZVAL_UNDEF(&_74$$46); + ZVAL_UNDEF(&_75$$47); + ZVAL_UNDEF(&_76$$47); + ZVAL_UNDEF(&_77$$48); + ZVAL_UNDEF(&_78$$49); + ZVAL_UNDEF(&_79$$50); + ZVAL_UNDEF(&_80$$50); + ZVAL_UNDEF(&_81$$51); + ZVAL_UNDEF(&_82$$51); + ZVAL_UNDEF(&_83$$52); + ZVAL_UNDEF(&_84$$52); + ZVAL_UNDEF(&_85$$53); + ZVAL_UNDEF(&_86$$53); + ZVAL_UNDEF(&_87$$54); + ZVAL_UNDEF(&_88$$54); + ZVAL_UNDEF(&_89$$55); + ZVAL_UNDEF(&_90$$56); + ZVAL_UNDEF(&_91$$57); + ZVAL_UNDEF(&_92$$58); + ZVAL_UNDEF(&_93$$59); + ZVAL_UNDEF(&_94$$60); + ZVAL_UNDEF(&_95$$61); + ZVAL_UNDEF(&_96$$62); + ZVAL_UNDEF(&_97$$63); + ZVAL_UNDEF(&_98$$64); + ZVAL_UNDEF(&_99$$65); + ZVAL_UNDEF(&_100$$66); + ZVAL_UNDEF(&_101$$67); + ZVAL_UNDEF(&_102$$68); + ZVAL_UNDEF(&_103$$69); + ZVAL_UNDEF(&_104$$69); + ZVAL_UNDEF(&_105$$70); + ZVAL_UNDEF(&_110$$76); + ZVAL_UNDEF(&_111$$76); + ZVAL_UNDEF(&_112$$76); + ZVAL_UNDEF(&_113$$76); + ZVAL_UNDEF(&_114$$76); + ZVAL_UNDEF(&_115$$76); + ZVAL_UNDEF(&_117$$78); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(joinType) - Z_PARAM_ZVAL(joinSource) - Z_PARAM_STR(modelAlias) - Z_PARAM_STR(joinAlias) - Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias_param, &joinAlias_param, &relation); - if (UNEXPECTED(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(joinType_param) == IS_STRING)) { - zephir_get_strval(&joinType, joinType_param); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + zephir_get_strval(&table, table_param); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - ZEPHIR_INIT_VAR(&joinType); + zephir_get_strval(&schema, schema_param); } - zephir_get_strval(&modelAlias, modelAlias_param); - zephir_get_strval(&joinAlias, joinAlias_param); - ZEPHIR_INIT_VAR(&sqlJoinConditions); - ZVAL_NULL(&sqlJoinConditions); - ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); + ZEPHIR_INIT_VAR(&oldColumn); + ZVAL_NULL(&oldColumn); + ZEPHIR_INIT_VAR(&columns); + array_init(&columns); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "describecolumns", NULL, 0, &table, &schema); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); + ZVAL_LONG(&_2, 3); + ZEPHIR_CALL_METHOD(&fields, this_ptr, "fetchall", NULL, 0, &_1, &_2); zephir_check_call_status(); - if (Z_TYPE_P(&fields) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 4, 0); - add_assoc_stringl_ex(&_1$$3, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_1$$3, SL("op"), SL("=")); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 3, 0); - add_assoc_long_ex(&_3$$3, SL("type"), 355); - zephir_array_update_string(&_3$$3, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_3$$3, SL("name"), &fields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getqualified", NULL, 460, &_3$$3); - zephir_check_call_status(); - zephir_array_update_string(&_1$$3, SL("left"), &_2$$3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_4$$3); - zephir_create_array(&_4$$3, 3, 0); - add_assoc_stringl_ex(&_4$$3, SL("type"), SL("qualified")); - zephir_array_update_string(&_4$$3, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4$$3, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getqualified", NULL, 460, &_4$$3); - zephir_check_call_status(); - zephir_array_update_string(&_1$$3, SL("right"), &_2$$3, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_0$$3, &_1$$3); - ZEPHIR_CPY_WRT(&sqlJoinConditions, &_0$$3); - } else { - ZEPHIR_INIT_VAR(&sqlJoinPartialConditions); - array_init(&sqlJoinPartialConditions); - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 3406); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _7$$4, _8$$4, _5$$4) - { - ZEPHIR_INIT_NVAR(&position); - if (_8$$4 != NULL) { - ZVAL_STR_COPY(&position, _8$$4); - } else { - ZVAL_LONG(&position, _7$$4); + zephir_is_iterable(&fields, 0, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 529); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fields), _3) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _3); + ZEPHIR_INIT_NVAR(&definition); + zephir_create_array(&definition, 1, 0); + add_assoc_long_ex(&definition, SL("bindType"), 2); + ZEPHIR_OBS_NVAR(&columnType); + zephir_array_fetch_long(&columnType, &field, 1, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 182); + ZEPHIR_OBS_NVAR(&charSize); + zephir_array_fetch_long(&charSize, &field, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 183); + ZEPHIR_OBS_NVAR(&numericSize); + zephir_array_fetch_long(&numericSize, &field, 3, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 184); + ZEPHIR_OBS_NVAR(&numericScale); + zephir_array_fetch_long(&numericScale, &field, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 185); + do { + _5$$3 = 1; + if (_5$$3 == zephir_memnstr_str(&columnType, SL("boolean"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 203)) { + ZEPHIR_INIT_NVAR(&_6$$4); + ZVAL_LONG(&_6$$4, 8); + zephir_array_update_string(&definition, SL("type"), &_6$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_LONG(&_7$$4, 5); + zephir_array_update_string(&definition, SL("bindType"), &_7$$4, PH_COPY | PH_SEPARATE); + break; } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _5$$4); - ZEPHIR_OBS_NVAR(&referencedField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&referencedField, &referencedFields, &position, 0)))) { - ZEPHIR_INIT_NVAR(&_9$$6); - object_init_ex(&_9$$6, phalcon_mvc_model_exception_ce); - zephir_read_property(&_10$$6, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + if (_5$$3 == zephir_memnstr_str(&columnType, SL("bigint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 215)) { + ZEPHIR_INIT_NVAR(&_8$$5); + ZVAL_LONG(&_8$$5, 14); + zephir_array_update_string(&definition, SL("type"), &_8$$5, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_9$$5); + ZVAL_LONG(&_9$$5, 2); + zephir_array_update_string(&definition, SL("bindType"), &_9$$5, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("mediumint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 225)) { + ZEPHIR_INIT_NVAR(&_10$$6); + ZVAL_LONG(&_10$$6, 21); + zephir_array_update_string(&definition, SL("type"), &_10$$6, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_11$$6); - ZEPHIR_CONCAT_SVSVSV(&_11$$6, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_10$$6); - ZEPHIR_CALL_METHOD(NULL, &_9$$6, "__construct", &_12, 32, &_11$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$6, "phalcon/Mvc/Model/Query.zep", 3378); - ZEPHIR_MM_RESTORE(); - return; + ZVAL_LONG(&_11$$6, 1); + zephir_array_update_string(&definition, SL("bindType"), &_11$$6, PH_COPY | PH_SEPARATE); + break; } - ZEPHIR_INIT_NVAR(&_13$$5); - zephir_create_array(&_13$$5, 4, 0); - add_assoc_stringl_ex(&_13$$5, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_13$$5, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_15$$5); - zephir_create_array(&_15$$5, 3, 0); - add_assoc_long_ex(&_15$$5, SL("type"), 355); - zephir_array_update_string(&_15$$5, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$5, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getqualified", NULL, 460, &_15$$5); - zephir_check_call_status(); - zephir_array_update_string(&_13$$5, SL("left"), &_14$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_16$$5); - zephir_create_array(&_16$$5, 3, 0); - add_assoc_stringl_ex(&_16$$5, SL("type"), SL("qualified")); - zephir_array_update_string(&_16$$5, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_16$$5, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getqualified", NULL, 460, &_16$$5); - zephir_check_call_status(); - zephir_array_update_string(&_13$$5, SL("right"), &_14$$5, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoinPartialConditions, &_13$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3403); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6$$4, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6$$4)) { + if (_5$$3 == zephir_memnstr_str(&columnType, SL("smallint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 235)) { + ZEPHIR_INIT_NVAR(&_12$$7); + ZVAL_LONG(&_12$$7, 22); + zephir_array_update_string(&definition, SL("type"), &_12$$7, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_13$$7); + ZVAL_LONG(&_13$$7, 1); + zephir_array_update_string(&definition, SL("bindType"), &_13$$7, PH_COPY | PH_SEPARATE); break; } - ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); + if (_5$$3 == zephir_memnstr_str(&columnType, SL("tinyint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 245)) { + ZEPHIR_INIT_NVAR(&_14$$8); + ZVAL_LONG(&_14$$8, 26); + zephir_array_update_string(&definition, SL("type"), &_14$$8, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_15$$8); + ZVAL_LONG(&_15$$8, 1); + zephir_array_update_string(&definition, SL("bindType"), &_15$$8, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("int"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 258)) { + ZEPHIR_INIT_NVAR(&_16$$9); + ZVAL_LONG(&_16$$9, 0); + zephir_array_update_string(&definition, SL("type"), &_16$$9, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_17$$9); + ZVAL_LONG(&_17$$9, 1); + zephir_array_update_string(&definition, SL("bindType"), &_17$$9, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("bit"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 268)) { + ZEPHIR_INIT_NVAR(&_18$$10); + ZVAL_LONG(&_18$$10, 19); + zephir_array_update_string(&definition, SL("type"), &_18$$10, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("enum"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 277)) { + ZEPHIR_INIT_NVAR(&_19$$11); + ZVAL_LONG(&_19$$11, 18); + zephir_array_update_string(&definition, SL("type"), &_19$$11, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("datetime"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 285)) { + ZEPHIR_INIT_NVAR(&_20$$12); + ZVAL_LONG(&_20$$12, 4); + zephir_array_update_string(&definition, SL("type"), &_20$$12, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_21$$12); + ZVAL_LONG(&_21$$12, 0); + zephir_array_update_string(&definition, SL("size"), &_21$$12, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("date"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 294)) { + ZEPHIR_INIT_NVAR(&_22$$13); + ZVAL_LONG(&_22$$13, 1); + zephir_array_update_string(&definition, SL("type"), &_22$$13, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_23$$13); + ZVAL_LONG(&_23$$13, 0); + zephir_array_update_string(&definition, SL("size"), &_23$$13, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("decimal"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 304) || _5$$3 == zephir_memnstr_str(&columnType, SL("numeric"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 305)) { + ZEPHIR_INIT_NVAR(&_24$$14); + ZVAL_LONG(&_24$$14, 3); + zephir_array_update_string(&definition, SL("type"), &_24$$14, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_25$$14); + ZVAL_LONG(&_25$$14, 32); + zephir_array_update_string(&definition, SL("bindType"), &_25$$14, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("double precision"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 316)) { + ZEPHIR_INIT_NVAR(&_26$$15); + ZVAL_LONG(&_26$$15, 9); + zephir_array_update_string(&definition, SL("type"), &_26$$15, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_27$$15); + ZVAL_LONG(&_27$$15, 32); + zephir_array_update_string(&definition, SL("bindType"), &_27$$15, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("float"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 327) || _5$$3 == zephir_memnstr_str(&columnType, SL("real"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 328)) { + ZEPHIR_INIT_NVAR(&_28$$16); + ZVAL_LONG(&_28$$16, 7); + zephir_array_update_string(&definition, SL("type"), &_28$$16, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_29$$16); + ZVAL_LONG(&_29$$16, 32); + zephir_array_update_string(&definition, SL("bindType"), &_29$$16, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("mediumblob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 339)) { + ZEPHIR_INIT_NVAR(&_30$$17); + ZVAL_LONG(&_30$$17, 6); + zephir_array_update_string(&definition, SL("type"), &_30$$17, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("longblob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 347)) { + ZEPHIR_INIT_NVAR(&_31$$18); + ZVAL_LONG(&_31$$18, 13); + zephir_array_update_string(&definition, SL("type"), &_31$$18, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("tinyblob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 355)) { + ZEPHIR_INIT_NVAR(&_32$$19); + ZVAL_LONG(&_32$$19, 10); + zephir_array_update_string(&definition, SL("type"), &_32$$19, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("blob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 363)) { + ZEPHIR_INIT_NVAR(&_33$$20); + ZVAL_LONG(&_33$$20, 11); + zephir_array_update_string(&definition, SL("type"), &_33$$20, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("timestamp"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 371)) { + ZEPHIR_INIT_NVAR(&_34$$21); + ZVAL_LONG(&_34$$21, 17); + zephir_array_update_string(&definition, SL("type"), &_34$$21, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("time"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 379)) { + ZEPHIR_INIT_NVAR(&_35$$22); + ZVAL_LONG(&_35$$22, 20); + zephir_array_update_string(&definition, SL("type"), &_35$$22, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("jsonb"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 387)) { + ZEPHIR_INIT_NVAR(&_36$$23); + ZVAL_LONG(&_36$$23, 16); + zephir_array_update_string(&definition, SL("type"), &_36$$23, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("json"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 395)) { + ZEPHIR_INIT_NVAR(&_37$$24); + ZVAL_LONG(&_37$$24, 15); + zephir_array_update_string(&definition, SL("type"), &_37$$24, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("longtext"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 403)) { + ZEPHIR_INIT_NVAR(&_38$$25); + ZVAL_LONG(&_38$$25, 24); + zephir_array_update_string(&definition, SL("type"), &_38$$25, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("mediumtext"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 411)) { + ZEPHIR_INIT_NVAR(&_39$$26); + ZVAL_LONG(&_39$$26, 23); + zephir_array_update_string(&definition, SL("type"), &_39$$26, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("tinytext"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 419)) { + ZEPHIR_INIT_NVAR(&_40$$27); + ZVAL_LONG(&_40$$27, 25); + zephir_array_update_string(&definition, SL("type"), &_40$$27, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("text"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 427)) { + ZEPHIR_INIT_NVAR(&_41$$28); + ZVAL_LONG(&_41$$28, 6); + zephir_array_update_string(&definition, SL("type"), &_41$$28, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("varying"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 435) || _5$$3 == zephir_memnstr_str(&columnType, SL("varchar"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 436)) { + ZEPHIR_INIT_NVAR(&_42$$29); + ZVAL_LONG(&_42$$29, 2); + zephir_array_update_string(&definition, SL("type"), &_42$$29, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("char"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 445)) { + ZEPHIR_INIT_NVAR(&_43$$30); + ZVAL_LONG(&_43$$30, 5); + zephir_array_update_string(&definition, SL("type"), &_43$$30, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); + break; + } + if (_5$$3 == zephir_memnstr_str(&columnType, SL("uuid"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 454)) { + ZEPHIR_INIT_NVAR(&_44$$31); + ZVAL_LONG(&_44$$31, 5); + zephir_array_update_string(&definition, SL("type"), &_44$$31, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_45$$31); + ZVAL_LONG(&_45$$31, 36); + zephir_array_update_string(&definition, SL("size"), &_45$$31, PH_COPY | PH_SEPARATE); + break; + } + ZEPHIR_INIT_NVAR(&_46$$32); + ZVAL_LONG(&_46$$32, 2); + zephir_array_update_string(&definition, SL("type"), &_46$$32, PH_COPY | PH_SEPARATE); + break; + } while(0); + + if (Z_TYPE_P(&oldColumn) == IS_NULL) { + zephir_array_update_string(&definition, SL("first"), &__$true, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_47$$3, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 481); + if (ZEPHIR_IS_STRING(&_47$$3, "PRI")) { + zephir_array_update_string(&definition, SL("primary"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_48$$3, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 488); + if (ZEPHIR_IS_STRING(&_48$$3, "YES")) { + zephir_array_update_string(&definition, SL("notNull"), &__$false, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_49$$3, &field, 7, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 495); + if (ZEPHIR_IS_STRING(&_49$$3, "auto_increment")) { + zephir_array_update_string(&definition, SL("autoIncrement"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_50$$3, &field, 9, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 502); + if (Z_TYPE_P(&_50$$3) != IS_NULL) { + zephir_array_fetch_long(&_51$$38, &field, 9, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 507); + ZEPHIR_INIT_NVAR(&_52$$38); + ZVAL_STRING(&_52$$38, "/^'|'?::[[:alnum:][:space:]]+$/"); + ZEPHIR_INIT_NVAR(&_53$$38); + ZVAL_STRING(&_53$$38, ""); + ZEPHIR_CALL_FUNCTION(&_54$$38, "preg_replace", &_55, 40, &_52$$38, &_53$$38, &_51$$38); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&referencedField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&referencedField, &referencedFields, &position, 0)))) { - ZEPHIR_INIT_NVAR(&_17$$8); - object_init_ex(&_17$$8, phalcon_mvc_model_exception_ce); - zephir_read_property(&_18$$8, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_19$$8); - ZEPHIR_CONCAT_SVSVSV(&_19$$8, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_18$$8); - ZEPHIR_CALL_METHOD(NULL, &_17$$8, "__construct", &_12, 32, &_19$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$8, "phalcon/Mvc/Model/Query.zep", 3378); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_20$$7); - zephir_create_array(&_20$$7, 4, 0); - add_assoc_stringl_ex(&_20$$7, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_20$$7, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_22$$7); - zephir_create_array(&_22$$7, 3, 0); - add_assoc_long_ex(&_22$$7, SL("type"), 355); - zephir_array_update_string(&_22$$7, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$7, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_21$$7, this_ptr, "getqualified", NULL, 460, &_22$$7); - zephir_check_call_status(); - zephir_array_update_string(&_20$$7, SL("left"), &_21$$7, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_23$$7); - zephir_create_array(&_23$$7, 3, 0); - add_assoc_stringl_ex(&_23$$7, SL("type"), SL("qualified")); - zephir_array_update_string(&_23$$7, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_23$$7, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_21$$7, this_ptr, "getqualified", NULL, 460, &_23$$7); - zephir_check_call_status(); - zephir_array_update_string(&_20$$7, SL("right"), &_21$$7, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoinPartialConditions, &_20$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3403); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); + zephir_array_update_string(&definition, SL("default"), &_54$$38, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_56$$38, &definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 509); + ZEPHIR_INIT_NVAR(&_52$$38); + ZVAL_STRING(&_52$$38, "null"); + ZEPHIR_CALL_FUNCTION(&_57$$38, "strcasecmp", &_58, 38, &_56$$38, &_52$$38); zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_57$$38, 0)) { + zephir_array_update_string(&definition, SL("default"), &__$null, PH_COPY | PH_SEPARATE); + } } - } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&position); - } - zephir_create_array(return_value, 3, 0); - zephir_array_update_string(return_value, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("source"), joinSource, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("conditions"), &sqlJoinConditions, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getTable) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval qualifiedName; - zval *manager, manager_sub, *qualifiedName_param = NULL, modelName, model, source, schema; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&manager_sub); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&qualifiedName); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_managerinterface_ce) - Z_PARAM_ARRAY(qualifiedName) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &manager, &qualifiedName_param); - zephir_get_arrval(&qualifiedName, qualifiedName_param); - - - ZEPHIR_OBS_VAR(&modelName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&modelName, &qualifiedName, SL("name"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3428); - return; - } - ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - zephir_create_array(return_value, 2, 0); - zephir_array_fast_append(return_value, &schema); - zephir_array_fast_append(return_value, &source); - RETURN_MM(); - } - RETURN_CCTOR(&source); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getWriteConnection) -{ - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval intermediate, bindParams, bindTypes; - zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, connection, transaction, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 3, &model, &intermediate_param, &bindParams_param, &bindTypes_param); - if (!intermediate_param) { - ZEPHIR_INIT_VAR(&intermediate); - } else { - zephir_get_arrval(&intermediate, intermediate_param); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); + zephir_array_fetch_long(&_59$$3, &field, 10, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 517); + if (Z_TYPE_P(&_59$$3) != IS_NULL) { + zephir_array_fetch_long(&_60$$40, &field, 10, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 518); + zephir_array_update_string(&definition, SL("comment"), &_60$$40, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&columnName, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 524); + ZEPHIR_INIT_NVAR(&_61$$3); + object_init_ex(&_61$$3, phalcon_db_column_ce); + ZEPHIR_CALL_METHOD(NULL, &_61$$3, "__construct", &_62, 212, &columnName, &definition); + zephir_check_call_status(); + zephir_array_append(&columns, &_61$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 525); + ZEPHIR_CPY_WRT(&oldColumn, &columnName); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - - - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transaction, &_0); - _1 = Z_TYPE_P(&transaction) == IS_OBJECT; - if (_1) { - _1 = zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce); - } - if (_1) { - ZEPHIR_RETURN_CALL_METHOD(&transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - if ((zephir_method_exists_ex(model, ZEND_STRL("selectwriteconnection")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "selectWriteConnection did not return a connection", "phalcon/Mvc/Model/Query.zep", 3466); - return; - } - RETURN_CCTOR(&connection); - } - ZEPHIR_RETURN_CALL_METHOD(model, "getwriteconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareDelete) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, ast, delete, tables, models, modelsInstances, sqlTables, sqlModels, sqlAliases, sqlAliasesModelsInstances, deleteTables, manager, table, qualifiedName, modelName, model, source, schema, completeSource, alias, sqlDelete, where, limit, _0, *_1, _2, _4$$8, _5$$9, _7$$13, _8$$14, _9$$17, _10$$17, _11$$18; - zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&delete); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&sqlTables); - ZVAL_UNDEF(&sqlModels); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&deleteTables); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&sqlDelete); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_9$$17); - ZVAL_UNDEF(&_10$$17); - ZVAL_UNDEF(&_11$$18); - - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ast, &_0); - ZEPHIR_OBS_VAR(&delete); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&delete, &ast, SL("delete"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/Mvc/Model/Query.zep", 3488); - return; - } - ZEPHIR_OBS_VAR(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &delete, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/Mvc/Model/Query.zep", 3492); - return; - } - ZEPHIR_INIT_VAR(&models); - array_init(&models); - ZEPHIR_INIT_VAR(&modelsInstances); - array_init(&modelsInstances); - ZEPHIR_INIT_VAR(&sqlTables); - array_init(&sqlTables); - ZEPHIR_INIT_VAR(&sqlModels); - array_init(&sqlModels); - ZEPHIR_INIT_VAR(&sqlAliases); - array_init(&sqlAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); - array_init(&sqlAliasesModelsInstances); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&deleteTables); - zephir_create_array(&deleteTables, 1, 0); - zephir_array_fast_append(&deleteTables, &tables); - } else { - ZEPHIR_CPY_WRT(&deleteTables, &tables); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_is_iterable(&deleteTables, 0, "phalcon/Mvc/Model/Query.zep", 3552); - if (Z_TYPE_P(&deleteTables) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&deleteTables), _1) - { - ZEPHIR_INIT_NVAR(&table); - ZVAL_COPY(&table, _1); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3516); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3517); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_3, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&completeSource); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_4$$8); - zephir_create_array(&_4$$8, 2, 0); - zephir_array_fast_append(&_4$$8, &source); - zephir_array_fast_append(&_4$$8, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_4$$8); - } else { - ZEPHIR_INIT_NVAR(&_5$$9); - zephir_create_array(&_5$$9, 2, 0); - zephir_array_fast_append(&_5$$9, &source); - zephir_array_fast_append(&_5$$9, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_5$$9); - } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3534); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3535); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3541); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3545); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &deleteTables, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &deleteTables, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_4, &fields, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2)) { + if (!zend_is_true(&_4)) { break; } - ZEPHIR_CALL_METHOD(&table, &deleteTables, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3516); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3517); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_6, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_7$$13); - zephir_create_array(&_7$$13, 2, 0); - zephir_array_fast_append(&_7$$13, &source); - zephir_array_fast_append(&_7$$13, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_7$$13); + ZEPHIR_INIT_NVAR(&_63$$41); + zephir_create_array(&_63$$41, 1, 0); + add_assoc_long_ex(&_63$$41, SL("bindType"), 2); + ZEPHIR_CPY_WRT(&definition, &_63$$41); + ZEPHIR_OBS_NVAR(&columnType); + zephir_array_fetch_long(&columnType, &field, 1, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 182); + ZEPHIR_OBS_NVAR(&charSize); + zephir_array_fetch_long(&charSize, &field, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 183); + ZEPHIR_OBS_NVAR(&numericSize); + zephir_array_fetch_long(&numericSize, &field, 3, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 184); + ZEPHIR_OBS_NVAR(&numericScale); + zephir_array_fetch_long(&numericScale, &field, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 185); + do { + _64$$41 = 1; + if (_64$$41 == zephir_memnstr_str(&columnType, SL("boolean"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 203)) { + ZEPHIR_INIT_NVAR(&_65$$42); + ZVAL_LONG(&_65$$42, 8); + zephir_array_update_string(&definition, SL("type"), &_65$$42, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_66$$42); + ZVAL_LONG(&_66$$42, 5); + zephir_array_update_string(&definition, SL("bindType"), &_66$$42, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("bigint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 215)) { + ZEPHIR_INIT_NVAR(&_67$$43); + ZVAL_LONG(&_67$$43, 14); + zephir_array_update_string(&definition, SL("type"), &_67$$43, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_68$$43); + ZVAL_LONG(&_68$$43, 2); + zephir_array_update_string(&definition, SL("bindType"), &_68$$43, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("mediumint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 225)) { + ZEPHIR_INIT_NVAR(&_69$$44); + ZVAL_LONG(&_69$$44, 21); + zephir_array_update_string(&definition, SL("type"), &_69$$44, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_70$$44); + ZVAL_LONG(&_70$$44, 1); + zephir_array_update_string(&definition, SL("bindType"), &_70$$44, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("smallint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 235)) { + ZEPHIR_INIT_NVAR(&_71$$45); + ZVAL_LONG(&_71$$45, 22); + zephir_array_update_string(&definition, SL("type"), &_71$$45, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_72$$45); + ZVAL_LONG(&_72$$45, 1); + zephir_array_update_string(&definition, SL("bindType"), &_72$$45, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("tinyint"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 245)) { + ZEPHIR_INIT_NVAR(&_73$$46); + ZVAL_LONG(&_73$$46, 26); + zephir_array_update_string(&definition, SL("type"), &_73$$46, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_74$$46); + ZVAL_LONG(&_74$$46, 1); + zephir_array_update_string(&definition, SL("bindType"), &_74$$46, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("int"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 258)) { + ZEPHIR_INIT_NVAR(&_75$$47); + ZVAL_LONG(&_75$$47, 0); + zephir_array_update_string(&definition, SL("type"), &_75$$47, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_76$$47); + ZVAL_LONG(&_76$$47, 1); + zephir_array_update_string(&definition, SL("bindType"), &_76$$47, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("bit"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 268)) { + ZEPHIR_INIT_NVAR(&_77$$48); + ZVAL_LONG(&_77$$48, 19); + zephir_array_update_string(&definition, SL("type"), &_77$$48, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("enum"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 277)) { + ZEPHIR_INIT_NVAR(&_78$$49); + ZVAL_LONG(&_78$$49, 18); + zephir_array_update_string(&definition, SL("type"), &_78$$49, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("datetime"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 285)) { + ZEPHIR_INIT_NVAR(&_79$$50); + ZVAL_LONG(&_79$$50, 4); + zephir_array_update_string(&definition, SL("type"), &_79$$50, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_80$$50); + ZVAL_LONG(&_80$$50, 0); + zephir_array_update_string(&definition, SL("size"), &_80$$50, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("date"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 294)) { + ZEPHIR_INIT_NVAR(&_81$$51); + ZVAL_LONG(&_81$$51, 1); + zephir_array_update_string(&definition, SL("type"), &_81$$51, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_82$$51); + ZVAL_LONG(&_82$$51, 0); + zephir_array_update_string(&definition, SL("size"), &_82$$51, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("decimal"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 304) || _64$$41 == zephir_memnstr_str(&columnType, SL("numeric"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 305)) { + ZEPHIR_INIT_NVAR(&_83$$52); + ZVAL_LONG(&_83$$52, 3); + zephir_array_update_string(&definition, SL("type"), &_83$$52, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_84$$52); + ZVAL_LONG(&_84$$52, 32); + zephir_array_update_string(&definition, SL("bindType"), &_84$$52, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("double precision"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 316)) { + ZEPHIR_INIT_NVAR(&_85$$53); + ZVAL_LONG(&_85$$53, 9); + zephir_array_update_string(&definition, SL("type"), &_85$$53, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_86$$53); + ZVAL_LONG(&_86$$53, 32); + zephir_array_update_string(&definition, SL("bindType"), &_86$$53, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("float"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 327) || _64$$41 == zephir_memnstr_str(&columnType, SL("real"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 328)) { + ZEPHIR_INIT_NVAR(&_87$$54); + ZVAL_LONG(&_87$$54, 7); + zephir_array_update_string(&definition, SL("type"), &_87$$54, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_88$$54); + ZVAL_LONG(&_88$$54, 32); + zephir_array_update_string(&definition, SL("bindType"), &_88$$54, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("mediumblob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 339)) { + ZEPHIR_INIT_NVAR(&_89$$55); + ZVAL_LONG(&_89$$55, 6); + zephir_array_update_string(&definition, SL("type"), &_89$$55, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("longblob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 347)) { + ZEPHIR_INIT_NVAR(&_90$$56); + ZVAL_LONG(&_90$$56, 13); + zephir_array_update_string(&definition, SL("type"), &_90$$56, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("tinyblob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 355)) { + ZEPHIR_INIT_NVAR(&_91$$57); + ZVAL_LONG(&_91$$57, 10); + zephir_array_update_string(&definition, SL("type"), &_91$$57, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("blob"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 363)) { + ZEPHIR_INIT_NVAR(&_92$$58); + ZVAL_LONG(&_92$$58, 11); + zephir_array_update_string(&definition, SL("type"), &_92$$58, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("timestamp"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 371)) { + ZEPHIR_INIT_NVAR(&_93$$59); + ZVAL_LONG(&_93$$59, 17); + zephir_array_update_string(&definition, SL("type"), &_93$$59, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("time"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 379)) { + ZEPHIR_INIT_NVAR(&_94$$60); + ZVAL_LONG(&_94$$60, 20); + zephir_array_update_string(&definition, SL("type"), &_94$$60, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("jsonb"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 387)) { + ZEPHIR_INIT_NVAR(&_95$$61); + ZVAL_LONG(&_95$$61, 16); + zephir_array_update_string(&definition, SL("type"), &_95$$61, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("json"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 395)) { + ZEPHIR_INIT_NVAR(&_96$$62); + ZVAL_LONG(&_96$$62, 15); + zephir_array_update_string(&definition, SL("type"), &_96$$62, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("longtext"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 403)) { + ZEPHIR_INIT_NVAR(&_97$$63); + ZVAL_LONG(&_97$$63, 24); + zephir_array_update_string(&definition, SL("type"), &_97$$63, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("mediumtext"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 411)) { + ZEPHIR_INIT_NVAR(&_98$$64); + ZVAL_LONG(&_98$$64, 23); + zephir_array_update_string(&definition, SL("type"), &_98$$64, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("tinytext"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 419)) { + ZEPHIR_INIT_NVAR(&_99$$65); + ZVAL_LONG(&_99$$65, 25); + zephir_array_update_string(&definition, SL("type"), &_99$$65, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("text"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 427)) { + ZEPHIR_INIT_NVAR(&_100$$66); + ZVAL_LONG(&_100$$66, 6); + zephir_array_update_string(&definition, SL("type"), &_100$$66, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("varying"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 435) || _64$$41 == zephir_memnstr_str(&columnType, SL("varchar"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 436)) { + ZEPHIR_INIT_NVAR(&_101$$67); + ZVAL_LONG(&_101$$67, 2); + zephir_array_update_string(&definition, SL("type"), &_101$$67, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("char"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 445)) { + ZEPHIR_INIT_NVAR(&_102$$68); + ZVAL_LONG(&_102$$68, 5); + zephir_array_update_string(&definition, SL("type"), &_102$$68, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); + break; + } + if (_64$$41 == zephir_memnstr_str(&columnType, SL("uuid"), "phalcon/Db/Adapter/Pdo/Postgresql.zep", 454)) { + ZEPHIR_INIT_NVAR(&_103$$69); + ZVAL_LONG(&_103$$69, 5); + zephir_array_update_string(&definition, SL("type"), &_103$$69, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_104$$69); + ZVAL_LONG(&_104$$69, 36); + zephir_array_update_string(&definition, SL("size"), &_104$$69, PH_COPY | PH_SEPARATE); + break; + } + ZEPHIR_INIT_NVAR(&_105$$70); + ZVAL_LONG(&_105$$70, 2); + zephir_array_update_string(&definition, SL("type"), &_105$$70, PH_COPY | PH_SEPARATE); + break; + } while(0); + + if (Z_TYPE_P(&oldColumn) == IS_NULL) { + zephir_array_update_string(&definition, SL("first"), &__$true, PH_COPY | PH_SEPARATE); } else { - ZEPHIR_INIT_NVAR(&_8$$14); - zephir_create_array(&_8$$14, 2, 0); - zephir_array_fast_append(&_8$$14, &source); - zephir_array_fast_append(&_8$$14, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_8$$14); + zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3534); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3535); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3541); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_106$$41, &field, 6, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 481); + if (ZEPHIR_IS_STRING(&_106$$41, "PRI")) { + zephir_array_update_string(&definition, SL("primary"), &__$true, PH_COPY | PH_SEPARATE); } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3545); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &deleteTables, "next", NULL, 0); + zephir_array_fetch_long(&_107$$41, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 488); + if (ZEPHIR_IS_STRING(&_107$$41, "YES")) { + zephir_array_update_string(&definition, SL("notNull"), &__$false, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_108$$41, &field, 7, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 495); + if (ZEPHIR_IS_STRING(&_108$$41, "auto_increment")) { + zephir_array_update_string(&definition, SL("autoIncrement"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_109$$41, &field, 9, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 502); + if (Z_TYPE_P(&_109$$41) != IS_NULL) { + zephir_array_fetch_long(&_110$$76, &field, 9, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 507); + ZEPHIR_INIT_NVAR(&_111$$76); + ZVAL_STRING(&_111$$76, "/^'|'?::[[:alnum:][:space:]]+$/"); + ZEPHIR_INIT_NVAR(&_112$$76); + ZVAL_STRING(&_112$$76, ""); + ZEPHIR_CALL_FUNCTION(&_113$$76, "preg_replace", &_55, 40, &_111$$76, &_112$$76, &_110$$76); + zephir_check_call_status(); + zephir_array_update_string(&definition, SL("default"), &_113$$76, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_114$$76, &definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 509); + ZEPHIR_INIT_NVAR(&_111$$76); + ZVAL_STRING(&_111$$76, "null"); + ZEPHIR_CALL_FUNCTION(&_115$$76, "strcasecmp", &_58, 38, &_114$$76, &_111$$76); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_115$$76, 0)) { + zephir_array_update_string(&definition, SL("default"), &__$null, PH_COPY | PH_SEPARATE); + } + } + zephir_array_fetch_long(&_116$$41, &field, 10, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 517); + if (Z_TYPE_P(&_116$$41) != IS_NULL) { + zephir_array_fetch_long(&_117$$78, &field, 10, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 518); + zephir_array_update_string(&definition, SL("comment"), &_117$$78, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&columnName); + zephir_array_fetch_long(&columnName, &field, 0, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 524); + ZEPHIR_INIT_NVAR(&_118$$41); + object_init_ex(&_118$$41, phalcon_db_column_ce); + ZEPHIR_CALL_METHOD(NULL, &_118$$41, "__construct", &_62, 212, &columnName, &definition); + zephir_check_call_status(); + zephir_array_append(&columns, &_118$$41, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 525); + ZEPHIR_CPY_WRT(&oldColumn, &columnName); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&table); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - ZEPHIR_INIT_VAR(&sqlDelete); - array_init(&sqlDelete); - zephir_array_update_string(&sqlDelete, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlDelete, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_VAR(&where); - if (zephir_array_isset_string_fetch(&where, &ast, SL("where"), 0)) { - ZVAL_BOOL(&_10$$17, 1); - ZEPHIR_CALL_METHOD(&_9$$17, this_ptr, "getexpression", NULL, 459, &where, &_10$$17); - zephir_check_call_status(); - zephir_array_update_string(&sqlDelete, SL("where"), &_9$$17, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&limit); - if (zephir_array_isset_string_fetch(&limit, &ast, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(&_11$$18, this_ptr, "getlimitclause", NULL, 473, &limit); - zephir_check_call_status(); - zephir_array_update_string(&sqlDelete, SL("limit"), &_11$$18, PH_COPY | PH_SEPARATE); - } - RETURN_CCTOR(&sqlDelete); + ZEPHIR_INIT_NVAR(&field); + RETURN_CCTOR(&columns); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareInsert) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeReferences) { - zval _5$$7, _10$$8; - zend_bool notQuoting = 0; - zval ast, qualifiedName, manager, modelName, model, source, schema, exprValues, exprValue, sqlInsert, metaData, fields, sqlFields, field, name, _0, _2, *_3, _4, _1$$6, _6$$7, _7$$7, _8$$7, _11$$8, _12$$8, _13$$8, *_14$$9, _15$$9, _16$$10, _18$$11, _19$$11, _20$$11, _22$$12, _24$$13, _25$$13, _26$$13; + zval _14$$3, _23$$6, _29$$9, _33$$10; + zend_string *_27; + zend_ulong _26; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_17 = NULL, *_21 = NULL, *_23 = NULL; + zephir_fcall_cache_entry *_31 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, references, reference, arrayReference, constraintName, referenceObjects, name, referencedSchema, referencedTable, columns, referencedColumns, referenceUpdate, referenceDelete, _0, _1, _2, _3, *_4, _5, *_24, _25, _6$$5, _7$$5, _8$$5, _9$$5, _10$$5, _11$$5, _12$$3, _13$$3, _15$$8, _16$$8, _17$$8, _18$$8, _19$$8, _20$$8, _21$$6, _22$$6, _28$$9, _30$$9, _32$$10, _34$$10; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); + ZVAL_UNDEF(&table); ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&exprValues); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&sqlInsert); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&sqlFields); - ZVAL_UNDEF(&field); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&arrayReference); + ZVAL_UNDEF(&constraintName); + ZVAL_UNDEF(&referenceObjects); ZVAL_UNDEF(&name); + ZVAL_UNDEF(&referencedSchema); + ZVAL_UNDEF(&referencedTable); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&referencedColumns); + ZVAL_UNDEF(&referenceUpdate); + ZVAL_UNDEF(&referenceDelete); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_13$$8); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_16$$10); - ZVAL_UNDEF(&_18$$11); - ZVAL_UNDEF(&_19$$11); - ZVAL_UNDEF(&_20$$11); - ZVAL_UNDEF(&_22$$12); - ZVAL_UNDEF(&_24$$13); - ZVAL_UNDEF(&_25$$13); - ZVAL_UNDEF(&_26$$13); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_25); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_18$$8); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_20$$8); + ZVAL_UNDEF(&_21$$6); + ZVAL_UNDEF(&_22$$6); + ZVAL_UNDEF(&_28$$9); + ZVAL_UNDEF(&_30$$9); + ZVAL_UNDEF(&_32$$10); + ZVAL_UNDEF(&_34$$10); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_23$$6); + ZVAL_UNDEF(&_29$$9); + ZVAL_UNDEF(&_33$$10); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ast, &_0); - if (UNEXPECTED(!(zephir_array_isset_string(&ast, SL("qualifiedName"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3586); - return; + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); } - if (UNEXPECTED(!(zephir_array_isset_string(&ast, SL("values"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3590); - return; + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); } - ZEPHIR_OBS_VAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &ast, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3593); - if (UNEXPECTED(!(zephir_array_isset_string(&qualifiedName, SL("name"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3597); - return; + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_OBS_VAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3601); - ZEPHIR_CALL_METHOD(&model, &manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); + } + } + + + ZEPHIR_INIT_VAR(&references); + array_init(&references); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describereferences", NULL, 0, &table, &schema); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&_1$$6); - zephir_create_array(&_1$$6, 2, 0); - zephir_array_fast_append(&_1$$6, &schema); - zephir_array_fast_append(&_1$$6, &source); - ZEPHIR_CPY_WRT(&source, &_1$$6); - } - notQuoting = 0; - ZEPHIR_INIT_VAR(&exprValues); - array_init(&exprValues); - zephir_array_fetch_string(&_2, &ast, SL("values"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3614); - zephir_is_iterable(&_2, 0, "phalcon/Mvc/Model/Query.zep", 3622); - if (Z_TYPE_P(&_2) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 581); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _4) { - ZEPHIR_INIT_NVAR(&exprValue); - ZVAL_COPY(&exprValue, _3); - ZEPHIR_INIT_NVAR(&_5$$7); - zephir_create_array(&_5$$7, 2, 0); - ZEPHIR_OBS_NVAR(&_6$$7); - zephir_array_fetch_string(&_6$$7, &exprValue, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3617); - zephir_array_update_string(&_5$$7, SL("type"), &_6$$7, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_8$$7, 1); + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _4); + zephir_array_fetch_long(&constraintName, &reference, 2, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 550); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_long(&referencedSchema, &reference, 3, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 553); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 554); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_long(&referenceUpdate, &reference, 6, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 555); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_long(&referenceDelete, &reference, 7, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 556); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); } else { - ZVAL_BOOL(&_8$$7, 0); + zephir_array_fetch(&_6$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 560); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_6$$5, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 560); + zephir_array_fetch(&_7$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 561); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_7$$5, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 561); + zephir_array_fetch(&_8$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 562); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_8$$5, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 562); + zephir_array_fetch(&_9$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 563); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_9$$5, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 563); + zephir_array_fetch(&_10$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 564); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_string(&referenceUpdate, &_10$$5, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 564); + zephir_array_fetch(&_11$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 565); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_string(&referenceDelete, &_11$$5, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 565); } - ZEPHIR_CALL_METHOD(&_7$$7, this_ptr, "getexpression", &_9, 459, &exprValue, &_8$$7); - zephir_check_call_status(); - zephir_array_update_string(&_5$$7, SL("value"), &_7$$7, PH_COPY | PH_SEPARATE); - zephir_array_append(&exprValues, &_5$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3619); + zephir_array_fetch_long(&_12$$3, &reference, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 568); + zephir_array_append(&columns, &_12$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 568); + zephir_array_fetch_long(&_13$$3, &reference, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 569); + zephir_array_append(&referencedColumns, &_13$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 569); + ZEPHIR_INIT_NVAR(&_14$$3); + zephir_create_array(&_14$$3, 6, 0); + zephir_array_update_string(&_14$$3, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("onUpdate"), &referenceUpdate, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("onDelete"), &referenceDelete, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_14$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_4)) { + if (!zend_is_true(&_5)) { break; } - ZEPHIR_CALL_METHOD(&exprValue, &_2, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&reference, &_0, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$8); - zephir_create_array(&_10$$8, 2, 0); - ZEPHIR_OBS_NVAR(&_11$$8); - zephir_array_fetch_string(&_11$$8, &exprValue, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3617); - zephir_array_update_string(&_10$$8, SL("type"), &_11$$8, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_13$$8, 1); + ZEPHIR_OBS_NVAR(&constraintName); + zephir_array_fetch_long(&constraintName, &reference, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 550); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_long(&referencedSchema, &reference, 3, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 553); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 554); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_long(&referenceUpdate, &reference, 6, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 555); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_long(&referenceDelete, &reference, 7, PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 556); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); } else { - ZVAL_BOOL(&_13$$8, 0); + zephir_array_fetch(&_15$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 560); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_15$$8, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 560); + zephir_array_fetch(&_16$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 561); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_16$$8, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 561); + zephir_array_fetch(&_17$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 562); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_17$$8, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 562); + zephir_array_fetch(&_18$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 563); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_18$$8, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 563); + zephir_array_fetch(&_19$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 564); + ZEPHIR_OBS_NVAR(&referenceUpdate); + zephir_array_fetch_string(&referenceUpdate, &_19$$8, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 564); + zephir_array_fetch(&_20$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 565); + ZEPHIR_OBS_NVAR(&referenceDelete); + zephir_array_fetch_string(&referenceDelete, &_20$$8, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 565); } - ZEPHIR_CALL_METHOD(&_12$$8, this_ptr, "getexpression", &_9, 459, &exprValue, &_13$$8); - zephir_check_call_status(); - zephir_array_update_string(&_10$$8, SL("value"), &_12$$8, PH_COPY | PH_SEPARATE); - zephir_array_append(&exprValues, &_10$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3619); - ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); + zephir_array_fetch_long(&_21$$6, &reference, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 568); + zephir_array_append(&columns, &_21$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 568); + zephir_array_fetch_long(&_22$$6, &reference, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 569); + zephir_array_append(&referencedColumns, &_22$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 569); + ZEPHIR_INIT_NVAR(&_23$$6); + zephir_create_array(&_23$$6, 6, 0); + zephir_array_update_string(&_23$$6, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("onUpdate"), &referenceUpdate, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$6, SL("onDelete"), &referenceDelete, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_23$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&exprValue); - ZEPHIR_INIT_VAR(&sqlInsert); - zephir_create_array(&sqlInsert, 2, 0); - zephir_array_update_string(&sqlInsert, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlInsert, SL("table"), &source, PH_COPY | PH_SEPARATE); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_0); - ZEPHIR_OBS_VAR(&fields); - if (zephir_array_isset_string_fetch(&fields, &ast, SL("fields"), 0)) { - ZEPHIR_INIT_VAR(&sqlFields); - array_init(&sqlFields); - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 3646); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fields), _14$$9) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _14$$9); - ZEPHIR_OBS_NVAR(&name); - zephir_array_fetch_string(&name, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3633); - ZEPHIR_CALL_METHOD(&_16$$10, &metaData, "hasattribute", &_17, 0, &model, &name); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_16$$10))) { - ZEPHIR_INIT_NVAR(&_18$$11); - object_init_ex(&_18$$11, phalcon_mvc_model_exception_ce); - zephir_read_property(&_19$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_20$$11); - ZEPHIR_CONCAT_SVSVSV(&_20$$11, "The model '", &modelName, "' doesn't have the attribute '", &name, "', when preparing: ", &_19$$11); - ZEPHIR_CALL_METHOD(NULL, &_18$$11, "__construct", &_21, 32, &_20$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$11, "phalcon/Mvc/Model/Query.zep", 3639); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&sqlFields, &name, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3643); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + ZEPHIR_INIT_NVAR(&reference); + ZEPHIR_INIT_VAR(&referenceObjects); + array_init(&referenceObjects); + zephir_is_iterable(&references, 0, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 597); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&references), _26, _27, _24) + { + ZEPHIR_INIT_NVAR(&name); + if (_27 != NULL) { + ZVAL_STR_COPY(&name, _27); + } else { + ZVAL_LONG(&name, _26); + } + ZEPHIR_INIT_NVAR(&arrayReference); + ZVAL_COPY(&arrayReference, _24); + ZEPHIR_INIT_NVAR(&_28$$9); + object_init_ex(&_28$$9, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_29$$9); + zephir_create_array(&_29$$9, 6, 0); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 587); + zephir_array_update_string(&_29$$9, SL("referencedSchema"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 588); + zephir_array_update_string(&_29$$9, SL("referencedTable"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 589); + zephir_array_update_string(&_29$$9, SL("columns"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 590); + zephir_array_update_string(&_29$$9, SL("referencedColumns"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 591); + zephir_array_update_string(&_29$$9, SL("onUpdate"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_30$$9); + zephir_array_fetch_string(&_30$$9, &arrayReference, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 593); + zephir_array_update_string(&_29$$9, SL("onDelete"), &_30$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_28$$9, "__construct", &_31, 34, &name, &_29$$9); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$9, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$9)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&name); - zephir_array_fetch_string(&name, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3633); - ZEPHIR_CALL_METHOD(&_22$$12, &metaData, "hasattribute", &_23, 0, &model, &name); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_22$$12))) { - ZEPHIR_INIT_NVAR(&_24$$13); - object_init_ex(&_24$$13, phalcon_mvc_model_exception_ce); - zephir_read_property(&_25$$13, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_26$$13); - ZEPHIR_CONCAT_SVSVSV(&_26$$13, "The model '", &modelName, "' doesn't have the attribute '", &name, "', when preparing: ", &_25$$13); - ZEPHIR_CALL_METHOD(NULL, &_24$$13, "__construct", &_21, 32, &_26$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_24$$13, "phalcon/Mvc/Model/Query.zep", 3639); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&sqlFields, &name, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3643); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); + zephir_array_update_zval(&referenceObjects, &name, &_28$$9, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_25, &references, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_25)) { + break; } + ZEPHIR_CALL_METHOD(&name, &references, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&arrayReference, &references, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_32$$10); + object_init_ex(&_32$$10, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_33$$10); + zephir_create_array(&_33$$10, 6, 0); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 587); + zephir_array_update_string(&_33$$10, SL("referencedSchema"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 588); + zephir_array_update_string(&_33$$10, SL("referencedTable"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 589); + zephir_array_update_string(&_33$$10, SL("columns"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 590); + zephir_array_update_string(&_33$$10, SL("referencedColumns"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("onUpdate"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 591); + zephir_array_update_string(&_33$$10, SL("onUpdate"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_34$$10); + zephir_array_fetch_string(&_34$$10, &arrayReference, SL("onDelete"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 593); + zephir_array_update_string(&_33$$10, SL("onDelete"), &_34$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_32$$10, "__construct", &_31, 34, &name, &_33$$10); + zephir_check_call_status(); + zephir_array_update_zval(&referenceObjects, &name, &_32$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(&field); - zephir_array_update_string(&sqlInsert, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); } - zephir_array_update_string(&sqlInsert, SL("values"), &exprValues, PH_COPY | PH_SEPARATE); - RETURN_CCTOR(&sqlInsert); + ZEPHIR_INIT_NVAR(&arrayReference); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&referenceObjects); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareSelect) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, getDefaultIdValue) { - zval _13$$24, _25$$28, _46$$43, _58$$47, _90$$66, _93$$73, _99$$81, _102$$88; - zval sqlModels, sqlTables, sqlAliases, sqlColumns, sqlAliasesModels, sqlModelsAliases, sqlAliasesModelsInstances, models, modelsInstances, _21$$24, _22$$24, _23$$24, _33$$28, _34$$28, _35$$28, _54$$43, _55$$43, _56$$43, _66$$47, _67$$47, _68$$47; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_8 = NULL, *_14 = NULL, *_16 = NULL, *_26 = NULL, *_28 = NULL, *_36 = NULL, *_47 = NULL, *_49 = NULL, *_59 = NULL, *_61 = NULL, *_85 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, position = 0, number = 0; - zend_bool merge; - zval *ast = NULL, ast_sub, *merge_param = NULL, __$null, __$true, select, tables, columns, selectedModels, manager, metaData, selectedModel, qualifiedName, modelName, model, schema, source, completeSource, alias, joins, sqlJoins, selectColumns, sqlColumnAliases, column, sqlColumn, sqlSelect, distinct, having, where, groupBy, order, limit, tempModels, tempModelsInstances, tempSqlAliases, tempSqlModelsAliases, tempSqlAliasesModelsInstances, tempSqlAliasesModels, with, withs, withItem, automaticJoins, relation, joinAlias, relationModel, bestAlias, eagerType, _1, *_2, _3, *_82, _83, _103, _0$$3, _5$$17, _6$$17, _7$$17, _9$$19, *_10$$21, _11$$21, _12$$24, _15$$25, _17$$27, _18$$27, _19$$27, _20$$26, _24$$28, _27$$29, _29$$31, _30$$31, _31$$31, _32$$30, _37$$33, _38$$36, _39$$36, _40$$36, _41$$38, _42$$41, *_43$$40, _44$$40, _45$$43, _48$$44, _50$$46, _51$$46, _52$$46, _53$$45, _57$$47, _60$$48, _62$$50, _63$$50, _64$$50, _65$$49, _69$$52, _70$$52, _71$$52, _72$$52, _73$$52, _74$$52, _75$$52, _76$$52, _77$$52, _78$$52, _79$$52, _80$$52, _81$$55, _84$$60, *_86$$60, _87$$60, _88$$65, _89$$66, _91$$72, _92$$73, _94$$75, *_95$$75, _96$$75, _97$$80, _98$$81, _100$$87, _101$$88, _104$$92, _105$$93, _106$$94, _107$$95, _108$$96; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&ast_sub); + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + object_init_ex(return_value, phalcon_db_rawvalue_ce); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "DEFAULT"); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 35, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, modifyColumn) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tableName_param = NULL, *schemaName_param = NULL, *column, column_sub, *currentColumn = NULL, currentColumn_sub, __$null, sql, queries, query, exception, _0, *_1$$4, _2$$4, _3$$5, _5$$7, _6$$3, _7$$10, _8$$10, _9$$10; + zval tableName, schemaName; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tableName); + ZVAL_UNDEF(&schemaName); + ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(¤tColumn_sub); ZVAL_NULL(&__$null); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&select); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&selectedModels); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&selectedModel); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&sqlJoins); - ZVAL_UNDEF(&selectColumns); - ZVAL_UNDEF(&sqlColumnAliases); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&sqlColumn); - ZVAL_UNDEF(&sqlSelect); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&groupBy); - ZVAL_UNDEF(&order); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&tempModels); - ZVAL_UNDEF(&tempModelsInstances); - ZVAL_UNDEF(&tempSqlAliases); - ZVAL_UNDEF(&tempSqlModelsAliases); - ZVAL_UNDEF(&tempSqlAliasesModelsInstances); - ZVAL_UNDEF(&tempSqlAliasesModels); - ZVAL_UNDEF(&with); - ZVAL_UNDEF(&withs); - ZVAL_UNDEF(&withItem); - ZVAL_UNDEF(&automaticJoins); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&relationModel); - ZVAL_UNDEF(&bestAlias); - ZVAL_UNDEF(&eagerType); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_83); - ZVAL_UNDEF(&_103); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_5$$17); - ZVAL_UNDEF(&_6$$17); - ZVAL_UNDEF(&_7$$17); - ZVAL_UNDEF(&_9$$19); - ZVAL_UNDEF(&_11$$21); - ZVAL_UNDEF(&_12$$24); - ZVAL_UNDEF(&_15$$25); - ZVAL_UNDEF(&_17$$27); - ZVAL_UNDEF(&_18$$27); - ZVAL_UNDEF(&_19$$27); - ZVAL_UNDEF(&_20$$26); - ZVAL_UNDEF(&_24$$28); - ZVAL_UNDEF(&_27$$29); - ZVAL_UNDEF(&_29$$31); - ZVAL_UNDEF(&_30$$31); - ZVAL_UNDEF(&_31$$31); - ZVAL_UNDEF(&_32$$30); - ZVAL_UNDEF(&_37$$33); - ZVAL_UNDEF(&_38$$36); - ZVAL_UNDEF(&_39$$36); - ZVAL_UNDEF(&_40$$36); - ZVAL_UNDEF(&_41$$38); - ZVAL_UNDEF(&_42$$41); - ZVAL_UNDEF(&_44$$40); - ZVAL_UNDEF(&_45$$43); - ZVAL_UNDEF(&_48$$44); - ZVAL_UNDEF(&_50$$46); - ZVAL_UNDEF(&_51$$46); - ZVAL_UNDEF(&_52$$46); - ZVAL_UNDEF(&_53$$45); - ZVAL_UNDEF(&_57$$47); - ZVAL_UNDEF(&_60$$48); - ZVAL_UNDEF(&_62$$50); - ZVAL_UNDEF(&_63$$50); - ZVAL_UNDEF(&_64$$50); - ZVAL_UNDEF(&_65$$49); - ZVAL_UNDEF(&_69$$52); - ZVAL_UNDEF(&_70$$52); - ZVAL_UNDEF(&_71$$52); - ZVAL_UNDEF(&_72$$52); - ZVAL_UNDEF(&_73$$52); - ZVAL_UNDEF(&_74$$52); - ZVAL_UNDEF(&_75$$52); - ZVAL_UNDEF(&_76$$52); - ZVAL_UNDEF(&_77$$52); - ZVAL_UNDEF(&_78$$52); - ZVAL_UNDEF(&_79$$52); - ZVAL_UNDEF(&_80$$52); - ZVAL_UNDEF(&_81$$55); - ZVAL_UNDEF(&_84$$60); - ZVAL_UNDEF(&_87$$60); - ZVAL_UNDEF(&_88$$65); - ZVAL_UNDEF(&_89$$66); - ZVAL_UNDEF(&_91$$72); - ZVAL_UNDEF(&_92$$73); - ZVAL_UNDEF(&_94$$75); - ZVAL_UNDEF(&_96$$75); - ZVAL_UNDEF(&_97$$80); - ZVAL_UNDEF(&_98$$81); - ZVAL_UNDEF(&_100$$87); - ZVAL_UNDEF(&_101$$88); - ZVAL_UNDEF(&_104$$92); - ZVAL_UNDEF(&_105$$93); - ZVAL_UNDEF(&_106$$94); - ZVAL_UNDEF(&_107$$95); - ZVAL_UNDEF(&_108$$96); - ZVAL_UNDEF(&sqlModels); - ZVAL_UNDEF(&sqlTables); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlColumns); - ZVAL_UNDEF(&sqlAliasesModels); - ZVAL_UNDEF(&sqlModelsAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&_21$$24); - ZVAL_UNDEF(&_22$$24); - ZVAL_UNDEF(&_23$$24); - ZVAL_UNDEF(&_33$$28); - ZVAL_UNDEF(&_34$$28); - ZVAL_UNDEF(&_35$$28); - ZVAL_UNDEF(&_54$$43); - ZVAL_UNDEF(&_55$$43); - ZVAL_UNDEF(&_56$$43); - ZVAL_UNDEF(&_66$$47); - ZVAL_UNDEF(&_67$$47); - ZVAL_UNDEF(&_68$$47); - ZVAL_UNDEF(&_13$$24); - ZVAL_UNDEF(&_25$$28); - ZVAL_UNDEF(&_46$$43); - ZVAL_UNDEF(&_58$$47); - ZVAL_UNDEF(&_90$$66); - ZVAL_UNDEF(&_93$$73); - ZVAL_UNDEF(&_99$$81); - ZVAL_UNDEF(&_102$$88); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&queries); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$10); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(tableName) + Z_PARAM_STR(schemaName) + Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ast) - Z_PARAM_BOOL(merge) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(currentColumn, phalcon_db_columninterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, &ast, &merge_param); - if (!ast) { - ast = &ast_sub; - ZEPHIR_CPY_WRT(ast, &__$null); + zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); + if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { + zephir_get_strval(&tableName, tableName_param); } else { - ZEPHIR_SEPARATE_PARAM(ast); + ZEPHIR_INIT_VAR(&tableName); } - if (!merge_param) { - merge = 0; + if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { + zephir_get_strval(&schemaName, schemaName_param); } else { - merge = zephir_get_boolval(merge_param); + ZEPHIR_INIT_VAR(&schemaName); + } + if (!currentColumn) { + currentColumn = ¤tColumn_sub; + currentColumn = &__$null; } - if (ZEPHIR_IS_EMPTY(ast)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(ast, &_0$$3); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&sql, &_0, "modifycolumn", NULL, 0, &tableName, &schemaName, column, currentColumn); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&queries); + zephir_fast_explode_str(&queries, SL(";"), &sql, LONG_MAX); + if (zephir_fast_count_int(&queries) > 1) { + + /* try_start_1: */ + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + zephir_is_iterable(&queries, 0, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 653); + if (Z_TYPE_P(&queries) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queries), _1$$4) + { + ZEPHIR_INIT_NVAR(&query); + ZVAL_COPY(&query, _1$$4); + if (ZEPHIR_IS_EMPTY(&query)) { + continue; + } + ZEPHIR_INIT_NVAR(&_3$$5); + ZEPHIR_CONCAT_VS(&_3$$5, &query, ";"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_4, 0, &_3$$5); + zephir_check_call_status_or_jump(try_end_1); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &queries, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$4, &queries, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&query, &queries, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EMPTY(&query)) { + continue; + } + ZEPHIR_INIT_NVAR(&_5$$7); + ZEPHIR_CONCAT_VS(&_5$$7, &query, ";"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_4, 0, &_5$$7); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CALL_METHOD(NULL, &queries, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&query); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + RETURN_MM(); + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_OBJ(&_6$$3, EG(exception)); + Z_ADDREF_P(&_6$$3); + if (zephir_is_instance_of(&_6$$3, SL("Throwable"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&exception, &_6$$3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); + zephir_check_call_status(); + zephir_throw_exception_debug(&exception, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 657); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_INIT_VAR(&_7$$10); + if (!(ZEPHIR_IS_EMPTY(&sql))) { + zephir_array_fetch_long(&_8$$10, &queries, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Postgresql.zep", 660); + ZEPHIR_INIT_VAR(&_9$$10); + ZEPHIR_CONCAT_VS(&_9$$10, &_8$$10, ";"); + ZEPHIR_CALL_METHOD(&_7$$10, this_ptr, "execute", NULL, 0, &_9$$10); + zephir_check_call_status(); + } else { + ZVAL_BOOL(&_7$$10, 1); + } + RETURN_CCTOR(&_7$$10); } - ZEPHIR_OBS_VAR(&select); - if (!(zephir_array_isset_string_fetch(&select, ast, SL("select"), 0))) { - ZEPHIR_CPY_WRT(&select, ast); + RETURN_MM_BOOL(1); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, supportSequences) +{ + zval *this_ptr = getThis(); + + + + RETURN_BOOL(1); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, useExplicitIdValue) +{ + zval *this_ptr = getThis(); + + + + RETURN_BOOL(1); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, getDsnDefaults) +{ + zval *this_ptr = getThis(); + + + + array_init(return_value); + return; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Sqlite) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Sqlite, phalcon, db_adapter_pdo_sqlite, phalcon_db_adapter_pdo_abstractpdo_ce, phalcon_db_adapter_pdo_sqlite_method_entry, 0); + + zend_declare_property_string(phalcon_db_adapter_pdo_sqlite_ce, SL("dialectType"), "sqlite", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_db_adapter_pdo_sqlite_ce, SL("type"), "sqlite", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_1 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *descriptor_param = NULL, _0$$3; + zval descriptor; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&descriptor); + ZVAL_UNDEF(&_0$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(descriptor) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &descriptor_param); + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); + + + if (zephir_array_isset_string(&descriptor, SL("charset"))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "SQLite does not allow the charset to be changed in the DSN."); + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_0$$3); + zephir_check_call_status(); } - ZEPHIR_OBS_VAR(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &select, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3682); - return; + ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_sqlite_ce, getThis(), "__construct", &_1, 0, &descriptor); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, connect) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_1 = NULL; + zval *descriptor_param = NULL, dbname, _0$$3; + zval descriptor; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&descriptor); + ZVAL_UNDEF(&dbname); + ZVAL_UNDEF(&_0$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(descriptor) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &descriptor_param); + if (!descriptor_param) { + ZEPHIR_INIT_VAR(&descriptor); + array_init(&descriptor); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); } - ZEPHIR_OBS_VAR(&columns); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &select, SL("columns"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3686); + + + if (ZEPHIR_IS_EMPTY(&descriptor)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("descriptor"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&descriptor, &_0$$3); + } + ZEPHIR_OBS_VAR(&dbname); + if (zephir_array_isset_string_fetch(&dbname, &descriptor, SL("dbname"), 0)) { + zephir_array_update_string(&descriptor, SL("dsn"), &dbname, PH_COPY | PH_SEPARATE); + zephir_array_unset_string(&descriptor, SL("dbname"), PH_SEPARATE); + } else if (UNEXPECTED(!(zephir_array_isset_string(&descriptor, SL("dsn"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The database must be specified with either 'dbname' or 'dsn'.", "phalcon/Db/Adapter/Pdo/Sqlite.zep", 82); return; } - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("nestingLevel"))); - ZEPHIR_INIT_VAR(&sqlModels); - array_init(&sqlModels); - ZEPHIR_INIT_VAR(&sqlTables); - array_init(&sqlTables); - ZEPHIR_INIT_VAR(&sqlColumns); - array_init(&sqlColumns); - ZEPHIR_INIT_VAR(&sqlAliases); - array_init(&sqlAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModels); - array_init(&sqlAliasesModels); - ZEPHIR_INIT_VAR(&sqlModelsAliases); - array_init(&sqlModelsAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); - array_init(&sqlAliasesModelsInstances); - ZEPHIR_INIT_VAR(&models); - array_init(&models); - ZEPHIR_INIT_VAR(&modelsInstances); - array_init(&modelsInstances); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&selectedModels); - zephir_create_array(&selectedModels, 1, 0); - zephir_array_fast_append(&selectedModels, &tables); + ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_sqlite_ce, getThis(), "connect", &_1, 0, &descriptor); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns) +{ + zend_bool _5$$3, _31$$3, _43$$28, _69$$28; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_35 = NULL, *_40 = NULL, *_41 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, __$true, __$false, columns, columnType, fields, field, definition, oldColumn, sizePattern, matches, matchOne, matchTwo, columnName, _0, _1, _2, *_3, _4, _28$$3, _29$$3, _30$$3, _32$$3, _33$$3, _34$$3, _6$$4, _7$$4, _8$$5, _9$$5, _10$$5, _11$$7, _12$$7, _13$$8, _14$$9, _15$$10, _16$$11, _17$$11, _18$$12, _19$$12, _20$$13, _21$$14, _22$$15, _23$$16, _24$$17, _25$$18, _26$$20, _27$$21, _36$$27, _37$$27, _38$$27, _39$$27, _42$$28, _66$$28, _67$$28, _68$$28, _70$$28, _71$$28, _72$$28, _44$$29, _45$$29, _46$$30, _47$$30, _48$$30, _49$$32, _50$$32, _51$$33, _52$$34, _53$$35, _54$$36, _55$$36, _56$$37, _57$$37, _58$$38, _59$$39, _60$$40, _61$$41, _62$$42, _63$$43, _64$$45, _65$$46, _73$$52, _74$$52, _75$$52, _76$$52; + zval table, schema; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&columnType); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&oldColumn); + ZVAL_UNDEF(&sizePattern); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&matchOne); + ZVAL_UNDEF(&matchTwo); + ZVAL_UNDEF(&columnName); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_28$$3); + ZVAL_UNDEF(&_29$$3); + ZVAL_UNDEF(&_30$$3); + ZVAL_UNDEF(&_32$$3); + ZVAL_UNDEF(&_33$$3); + ZVAL_UNDEF(&_34$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_13$$8); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_16$$11); + ZVAL_UNDEF(&_17$$11); + ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_19$$12); + ZVAL_UNDEF(&_20$$13); + ZVAL_UNDEF(&_21$$14); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_23$$16); + ZVAL_UNDEF(&_24$$17); + ZVAL_UNDEF(&_25$$18); + ZVAL_UNDEF(&_26$$20); + ZVAL_UNDEF(&_27$$21); + ZVAL_UNDEF(&_36$$27); + ZVAL_UNDEF(&_37$$27); + ZVAL_UNDEF(&_38$$27); + ZVAL_UNDEF(&_39$$27); + ZVAL_UNDEF(&_42$$28); + ZVAL_UNDEF(&_66$$28); + ZVAL_UNDEF(&_67$$28); + ZVAL_UNDEF(&_68$$28); + ZVAL_UNDEF(&_70$$28); + ZVAL_UNDEF(&_71$$28); + ZVAL_UNDEF(&_72$$28); + ZVAL_UNDEF(&_44$$29); + ZVAL_UNDEF(&_45$$29); + ZVAL_UNDEF(&_46$$30); + ZVAL_UNDEF(&_47$$30); + ZVAL_UNDEF(&_48$$30); + ZVAL_UNDEF(&_49$$32); + ZVAL_UNDEF(&_50$$32); + ZVAL_UNDEF(&_51$$33); + ZVAL_UNDEF(&_52$$34); + ZVAL_UNDEF(&_53$$35); + ZVAL_UNDEF(&_54$$36); + ZVAL_UNDEF(&_55$$36); + ZVAL_UNDEF(&_56$$37); + ZVAL_UNDEF(&_57$$37); + ZVAL_UNDEF(&_58$$38); + ZVAL_UNDEF(&_59$$39); + ZVAL_UNDEF(&_60$$40); + ZVAL_UNDEF(&_61$$41); + ZVAL_UNDEF(&_62$$42); + ZVAL_UNDEF(&_63$$43); + ZVAL_UNDEF(&_64$$45); + ZVAL_UNDEF(&_65$$46); + ZVAL_UNDEF(&_73$$52); + ZVAL_UNDEF(&_74$$52); + ZVAL_UNDEF(&_75$$52); + ZVAL_UNDEF(&_76$$52); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_CPY_WRT(&selectedModels, &tables); + ZEPHIR_INIT_VAR(&table); } - if (!(zephir_array_isset_long(&columns, 0))) { - ZEPHIR_INIT_VAR(&selectColumns); - zephir_create_array(&selectColumns, 1, 0); - zephir_array_fast_append(&selectColumns, &columns); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - ZEPHIR_CPY_WRT(&selectColumns, &columns); + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_1); - if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A models-manager is required to execute the query", "phalcon/Mvc/Model/Query.zep", 3753); - return; + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); } - if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A meta-data is required to execute the query", "phalcon/Mvc/Model/Query.zep", 3759); - return; } - number = 0; - ZEPHIR_INIT_VAR(&automaticJoins); - array_init(&automaticJoins); - zephir_is_iterable(&selectedModels, 0, "phalcon/Mvc/Model/Query.zep", 3889); - if (Z_TYPE_P(&selectedModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectedModels), _2) + + + ZEPHIR_INIT_VAR(&oldColumn); + ZVAL_NULL(&oldColumn); + ZEPHIR_INIT_VAR(&sizePattern); + ZVAL_STRING(&sizePattern, "#\\(([0-9]+)(?:,\\s*([0-9]+))*\\)#"); + ZEPHIR_INIT_VAR(&columns); + array_init(&columns); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "describecolumns", NULL, 0, &table, &schema); + zephir_check_call_status(); + ZVAL_LONG(&_2, 3); + ZEPHIR_CALL_METHOD(&fields, this_ptr, "fetchall", NULL, 0, &_1, &_2); + zephir_check_call_status(); + zephir_is_iterable(&fields, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 311); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fields), _3) { - ZEPHIR_INIT_NVAR(&selectedModel); - ZVAL_COPY(&selectedModel, _2); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3767); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3768); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_4, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&completeSource); - zephir_create_array(&completeSource, 2, 0); - zephir_array_fast_append(&completeSource, &source); - zephir_array_fast_append(&completeSource, &schema); - } else { - ZEPHIR_CPY_WRT(&completeSource, &source); + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _3); + ZEPHIR_INIT_NVAR(&definition); + zephir_create_array(&definition, 1, 0); + add_assoc_long_ex(&definition, SL("bindType"), 2); + ZEPHIR_OBS_NVAR(&columnType); + zephir_array_fetch_long(&columnType, &field, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 127); + _5$$3 = zephir_memnstr_str(&columnType, SL("int"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 149); + if (!(_5$$3)) { + _5$$3 = zephir_memnstr_str(&columnType, SL("INT"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 149); } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &selectedModel, SL("alias"), 0)) { - if (UNEXPECTED(zephir_array_isset(&sqlAliases, &alias))) { - ZEPHIR_INIT_NVAR(&_5$$17); - object_init_ex(&_5$$17, phalcon_mvc_model_exception_ce); - zephir_read_property(&_6$$17, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$17); - ZEPHIR_CONCAT_SVSV(&_7$$17, "Alias '", &alias, "' is used more than once, when preparing: ", &_6$$17); - ZEPHIR_CALL_METHOD(NULL, &_5$$17, "__construct", &_8, 32, &_7$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$17, "phalcon/Mvc/Model/Query.zep", 3793); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&completeSource) == IS_ARRAY) { - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3805); - } else { - ZEPHIR_INIT_NVAR(&_9$$19); - zephir_create_array(&_9$$19, 3, 0); - zephir_array_fast_append(&_9$$19, &source); - zephir_array_fast_append(&_9$$19, &__$null); - zephir_array_fast_append(&_9$$19, &alias); - ZEPHIR_CPY_WRT(&completeSource, &_9$$19); + if (zephir_memnstr_str(&columnType, SL("bigint"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 142)) { + ZEPHIR_INIT_NVAR(&_6$$4); + ZVAL_LONG(&_6$$4, 14); + zephir_array_update_string(&definition, SL("type"), &_6$$4, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_LONG(&_7$$4, 2); + zephir_array_update_string(&definition, SL("bindType"), &_7$$4, PH_COPY | PH_SEPARATE); + } else if (_5$$3) { + ZEPHIR_INIT_NVAR(&_8$$5); + ZVAL_LONG(&_8$$5, 0); + zephir_array_update_string(&definition, SL("type"), &_8$$5, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_9$$5); + ZVAL_LONG(&_9$$5, 1); + zephir_array_update_string(&definition, SL("bindType"), &_9$$5, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_10$$5, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 157); + if (zephir_is_true(&_10$$5)) { + zephir_array_update_string(&definition, SL("autoIncrement"), &__$true, PH_COPY | PH_SEPARATE); } - zephir_array_update_zval(&models, &modelName, &alias, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("tinyint(1)"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 160)) { + ZEPHIR_INIT_NVAR(&_11$$7); + ZVAL_LONG(&_11$$7, 8); + zephir_array_update_string(&definition, SL("type"), &_11$$7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_12$$7); + ZVAL_LONG(&_12$$7, 5); + zephir_array_update_string(&definition, SL("bindType"), &_12$$7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&columnType); + ZVAL_STRING(&columnType, "boolean"); + } else if (zephir_memnstr_str(&columnType, SL("enum"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 171)) { + ZEPHIR_INIT_NVAR(&_13$$8); + ZVAL_LONG(&_13$$8, 5); + zephir_array_update_string(&definition, SL("type"), &_13$$8, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("datetime"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 180)) { + ZEPHIR_INIT_NVAR(&_14$$9); + ZVAL_LONG(&_14$$9, 4); + zephir_array_update_string(&definition, SL("type"), &_14$$9, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("date"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 185)) { + ZEPHIR_INIT_NVAR(&_15$$10); + ZVAL_LONG(&_15$$10, 1); + zephir_array_update_string(&definition, SL("type"), &_15$$10, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("decimal"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 194)) { + ZEPHIR_INIT_NVAR(&_16$$11); + ZVAL_LONG(&_16$$11, 3); + zephir_array_update_string(&definition, SL("type"), &_16$$11, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_17$$11); + ZVAL_LONG(&_17$$11, 32); + zephir_array_update_string(&definition, SL("bindType"), &_17$$11, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("float"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 201)) { + ZEPHIR_INIT_NVAR(&_18$$12); + ZVAL_LONG(&_18$$12, 7); + zephir_array_update_string(&definition, SL("type"), &_18$$12, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_19$$12); + ZVAL_LONG(&_19$$12, 3); + zephir_array_update_string(&definition, SL("bindType"), &_19$$12, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("timestamp"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 212)) { + ZEPHIR_INIT_NVAR(&_20$$13); + ZVAL_LONG(&_20$$13, 17); + zephir_array_update_string(&definition, SL("type"), &_20$$13, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("varchar"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 221)) { + ZEPHIR_INIT_NVAR(&_21$$14); + ZVAL_LONG(&_21$$14, 2); + zephir_array_update_string(&definition, SL("type"), &_21$$14, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("char"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 226)) { + ZEPHIR_INIT_NVAR(&_22$$15); + ZVAL_LONG(&_22$$15, 5); + zephir_array_update_string(&definition, SL("type"), &_22$$15, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("text"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 231)) { + ZEPHIR_INIT_NVAR(&_23$$16); + ZVAL_LONG(&_23$$16, 6); + zephir_array_update_string(&definition, SL("type"), &_23$$16, PH_COPY | PH_SEPARATE); } else { - ZEPHIR_CPY_WRT(&alias, &source); - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_24$$17); + ZVAL_LONG(&_24$$17, 2); + zephir_array_update_string(&definition, SL("type"), &_24$$17, PH_COPY | PH_SEPARATE); } - ZEPHIR_OBS_NVAR(&with); - if (zephir_array_isset_string_fetch(&with, &selectedModel, SL("with"), 0)) { - if (!(zephir_array_isset_long(&with, 0))) { - ZEPHIR_INIT_NVAR(&withs); - zephir_create_array(&withs, 1, 0); - zephir_array_fast_append(&withs, &with); - } else { - ZEPHIR_CPY_WRT(&withs, &with); - } - zephir_is_iterable(&withs, 0, "phalcon/Mvc/Model/Query.zep", 3881); - if (Z_TYPE_P(&withs) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&withs), _10$$21) - { - ZEPHIR_INIT_NVAR(&withItem); - ZVAL_COPY(&withItem, _10$$21); - ZEPHIR_INIT_NVAR(&_12$$24); - ZVAL_LONG(&_12$$24, number); - ZEPHIR_INIT_NVAR(&_13$$24); - ZEPHIR_CONCAT_SV(&_13$$24, "AA", &_12$$24); - ZEPHIR_CPY_WRT(&joinAlias, &_13$$24); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_14, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_15$$25); - ZVAL_STRING(&_15$$25, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_15$$25); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_16, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_17$$27); - object_init_ex(&_17$$27, phalcon_mvc_model_exception_ce); - zephir_read_property(&_18$$27, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_19$$27); - ZEPHIR_CONCAT_SVSVSV(&_19$$27, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_18$$27); - ZEPHIR_CALL_METHOD(NULL, &_17$$27, "__construct", &_8, 32, &_19$$27); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$27, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_20$$26); - ZVAL_STRING(&_20$$26, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_20$$26); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_21$$24); - zephir_create_array(&_21$$24, 5, 0); - add_assoc_long_ex(&_21$$24, SL("type"), 353); - zephir_array_update_string(&_21$$24, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$24, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$24, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$24, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_21$$24, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_22$$24); - zephir_create_array(&_22$$24, 3, 0); - add_assoc_long_ex(&_22$$24, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_23$$24); - zephir_create_array(&_23$$24, 2, 0); - add_assoc_long_ex(&_23$$24, SL("type"), 355); - zephir_array_update_string(&_23$$24, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$24, SL("qualified"), &_23$$24, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_23$$24); - zephir_create_array(&_23$$24, 2, 0); - add_assoc_long_ex(&_23$$24, SL("type"), 355); - zephir_array_update_string(&_23$$24, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$24, SL("alias"), &_23$$24, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_22$$24, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &withs, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11$$21, &withs, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11$$21)) { - break; - } - ZEPHIR_CALL_METHOD(&withItem, &withs, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_24$$28); - ZVAL_LONG(&_24$$28, number); - ZEPHIR_INIT_NVAR(&_25$$28); - ZEPHIR_CONCAT_SV(&_25$$28, "AA", &_24$$28); - ZEPHIR_CPY_WRT(&joinAlias, &_25$$28); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_26, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_27$$29); - ZVAL_STRING(&_27$$29, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_27$$29); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_28, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_29$$31); - object_init_ex(&_29$$31, phalcon_mvc_model_exception_ce); - zephir_read_property(&_30$$31, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_31$$31); - ZEPHIR_CONCAT_SVSVSV(&_31$$31, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_30$$31); - ZEPHIR_CALL_METHOD(NULL, &_29$$31, "__construct", &_8, 32, &_31$$31); - zephir_check_call_status(); - zephir_throw_exception_debug(&_29$$31, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_32$$30); - ZVAL_STRING(&_32$$30, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_32$$30); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_33$$28); - zephir_create_array(&_33$$28, 5, 0); - add_assoc_long_ex(&_33$$28, SL("type"), 353); - zephir_array_update_string(&_33$$28, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$28, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$28, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$28, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_33$$28, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_34$$28); - zephir_create_array(&_34$$28, 3, 0); - add_assoc_long_ex(&_34$$28, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_35$$28); - zephir_create_array(&_35$$28, 2, 0); - add_assoc_long_ex(&_35$$28, SL("type"), 355); - zephir_array_update_string(&_35$$28, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_34$$28, SL("qualified"), &_35$$28, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_35$$28); - zephir_create_array(&_35$$28, 2, 0); - add_assoc_long_ex(&_35$$28, SL("type"), 355); - zephir_array_update_string(&_35$$28, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_34$$28, SL("alias"), &_35$$28, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_34$$28, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - ZEPHIR_CALL_METHOD(NULL, &withs, "next", NULL, 0); - zephir_check_call_status(); + if (zephir_memnstr_str(&columnType, SL("("), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 248)) { + ZEPHIR_INIT_NVAR(&matches); + ZVAL_NULL(&matches); + ZEPHIR_INIT_NVAR(&_25$$18); + zephir_preg_match(&_25$$18, &sizePattern, &columnType, &matches, 0, 0 , 0 ); + if (zephir_is_true(&_25$$18)) { + ZEPHIR_OBS_NVAR(&matchOne); + if (zephir_array_isset_long_fetch(&matchOne, &matches, 1, 0)) { + ZEPHIR_INIT_NVAR(&_26$$20); + ZVAL_LONG(&_26$$20, zephir_get_intval(&matchOne)); + zephir_array_update_string(&definition, SL("size"), &_26$$20, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&matchTwo); + if (zephir_array_isset_long_fetch(&matchTwo, &matches, 2, 0)) { + ZEPHIR_INIT_NVAR(&_27$$21); + ZVAL_LONG(&_27$$21, zephir_get_intval(&matchTwo)); + zephir_array_update_string(&definition, SL("scale"), &_27$$21, PH_COPY | PH_SEPARATE); } } - ZEPHIR_INIT_NVAR(&withItem); } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3883); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3884); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + if (zephir_memnstr_str(&columnType, SL("unsigned"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 264)) { + zephir_array_update_string(&definition, SL("unsigned"), &__$true, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&oldColumn) == IS_NULL) { + zephir_array_update_string(&definition, SL("first"), &__$true, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_28$$3, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 280); + if (zephir_is_true(&_28$$3)) { + zephir_array_update_string(&definition, SL("primary"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_29$$3, &field, 3, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 287); + if (ZEPHIR_IS_LONG(&_29$$3, 0)) { + zephir_array_update_string(&definition, SL("notNull"), &__$false, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&_30$$3); + zephir_array_fetch_long(&_30$$3, &field, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 295); + _31$$3 = !(ZEPHIR_IS_EMPTY(&_30$$3)); + if (_31$$3) { + zephir_array_fetch_long(&_32$$3, &field, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 295); + ZEPHIR_INIT_NVAR(&_33$$3); + ZVAL_STRING(&_33$$3, "null"); + ZEPHIR_CALL_FUNCTION(&_34$$3, "strcasecmp", &_35, 38, &_32$$3, &_33$$3); + zephir_check_call_status(); + _31$$3 = !ZEPHIR_IS_LONG_IDENTICAL(&_34$$3, 0); + } + if (_31$$3) { + zephir_array_fetch_long(&_36$$27, &field, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 300); + ZEPHIR_INIT_NVAR(&_37$$27); + ZVAL_STRING(&_37$$27, "/^'|'$/"); + ZEPHIR_INIT_NVAR(&_38$$27); + ZVAL_STRING(&_38$$27, ""); + ZEPHIR_CALL_FUNCTION(&_39$$27, "preg_replace", &_40, 40, &_37$$27, &_38$$27, &_36$$27); + zephir_check_call_status(); + zephir_array_update_string(&definition, SL("default"), &_39$$27, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&columnName, &field, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 306); + ZEPHIR_INIT_NVAR(&_33$$3); + object_init_ex(&_33$$3, phalcon_db_column_ce); + ZEPHIR_CALL_METHOD(NULL, &_33$$3, "__construct", &_41, 212, &columnName, &definition); + zephir_check_call_status(); + zephir_array_append(&columns, &_33$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 307); + ZEPHIR_CPY_WRT(&oldColumn, &columnName); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &selectedModels, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, &selectedModels, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_4, &fields, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_4)) { break; } - ZEPHIR_CALL_METHOD(&selectedModel, &selectedModels, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3767); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3768); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_36, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_37$$33); - zephir_create_array(&_37$$33, 2, 0); - zephir_array_fast_append(&_37$$33, &source); - zephir_array_fast_append(&_37$$33, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_37$$33); - } else { - ZEPHIR_CPY_WRT(&completeSource, &source); + ZEPHIR_INIT_NVAR(&_42$$28); + zephir_create_array(&_42$$28, 1, 0); + add_assoc_long_ex(&_42$$28, SL("bindType"), 2); + ZEPHIR_CPY_WRT(&definition, &_42$$28); + ZEPHIR_OBS_NVAR(&columnType); + zephir_array_fetch_long(&columnType, &field, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 127); + _43$$28 = zephir_memnstr_str(&columnType, SL("int"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 149); + if (!(_43$$28)) { + _43$$28 = zephir_memnstr_str(&columnType, SL("INT"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 149); } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &selectedModel, SL("alias"), 0)) { - if (UNEXPECTED(zephir_array_isset(&sqlAliases, &alias))) { - ZEPHIR_INIT_NVAR(&_38$$36); - object_init_ex(&_38$$36, phalcon_mvc_model_exception_ce); - zephir_read_property(&_39$$36, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_40$$36); - ZEPHIR_CONCAT_SVSV(&_40$$36, "Alias '", &alias, "' is used more than once, when preparing: ", &_39$$36); - ZEPHIR_CALL_METHOD(NULL, &_38$$36, "__construct", &_8, 32, &_40$$36); - zephir_check_call_status(); - zephir_throw_exception_debug(&_38$$36, "phalcon/Mvc/Model/Query.zep", 3793); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&completeSource) == IS_ARRAY) { - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3805); - } else { - ZEPHIR_INIT_NVAR(&_41$$38); - zephir_create_array(&_41$$38, 3, 0); - zephir_array_fast_append(&_41$$38, &source); - zephir_array_fast_append(&_41$$38, &__$null); - zephir_array_fast_append(&_41$$38, &alias); - ZEPHIR_CPY_WRT(&completeSource, &_41$$38); + if (zephir_memnstr_str(&columnType, SL("bigint"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 142)) { + ZEPHIR_INIT_NVAR(&_44$$29); + ZVAL_LONG(&_44$$29, 14); + zephir_array_update_string(&definition, SL("type"), &_44$$29, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_45$$29); + ZVAL_LONG(&_45$$29, 2); + zephir_array_update_string(&definition, SL("bindType"), &_45$$29, PH_COPY | PH_SEPARATE); + } else if (_43$$28) { + ZEPHIR_INIT_NVAR(&_46$$30); + ZVAL_LONG(&_46$$30, 0); + zephir_array_update_string(&definition, SL("type"), &_46$$30, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_47$$30); + ZVAL_LONG(&_47$$30, 1); + zephir_array_update_string(&definition, SL("bindType"), &_47$$30, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_48$$30, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 157); + if (zephir_is_true(&_48$$30)) { + zephir_array_update_string(&definition, SL("autoIncrement"), &__$true, PH_COPY | PH_SEPARATE); } - zephir_array_update_zval(&models, &modelName, &alias, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("tinyint(1)"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 160)) { + ZEPHIR_INIT_NVAR(&_49$$32); + ZVAL_LONG(&_49$$32, 8); + zephir_array_update_string(&definition, SL("type"), &_49$$32, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_50$$32); + ZVAL_LONG(&_50$$32, 5); + zephir_array_update_string(&definition, SL("bindType"), &_50$$32, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&columnType); + ZVAL_STRING(&columnType, "boolean"); + } else if (zephir_memnstr_str(&columnType, SL("enum"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 171)) { + ZEPHIR_INIT_NVAR(&_51$$33); + ZVAL_LONG(&_51$$33, 5); + zephir_array_update_string(&definition, SL("type"), &_51$$33, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("datetime"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 180)) { + ZEPHIR_INIT_NVAR(&_52$$34); + ZVAL_LONG(&_52$$34, 4); + zephir_array_update_string(&definition, SL("type"), &_52$$34, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("date"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 185)) { + ZEPHIR_INIT_NVAR(&_53$$35); + ZVAL_LONG(&_53$$35, 1); + zephir_array_update_string(&definition, SL("type"), &_53$$35, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("decimal"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 194)) { + ZEPHIR_INIT_NVAR(&_54$$36); + ZVAL_LONG(&_54$$36, 3); + zephir_array_update_string(&definition, SL("type"), &_54$$36, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_55$$36); + ZVAL_LONG(&_55$$36, 32); + zephir_array_update_string(&definition, SL("bindType"), &_55$$36, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("float"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 201)) { + ZEPHIR_INIT_NVAR(&_56$$37); + ZVAL_LONG(&_56$$37, 7); + zephir_array_update_string(&definition, SL("type"), &_56$$37, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&definition, SL("isNumeric"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_57$$37); + ZVAL_LONG(&_57$$37, 3); + zephir_array_update_string(&definition, SL("bindType"), &_57$$37, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("timestamp"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 212)) { + ZEPHIR_INIT_NVAR(&_58$$38); + ZVAL_LONG(&_58$$38, 17); + zephir_array_update_string(&definition, SL("type"), &_58$$38, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("varchar"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 221)) { + ZEPHIR_INIT_NVAR(&_59$$39); + ZVAL_LONG(&_59$$39, 2); + zephir_array_update_string(&definition, SL("type"), &_59$$39, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("char"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 226)) { + ZEPHIR_INIT_NVAR(&_60$$40); + ZVAL_LONG(&_60$$40, 5); + zephir_array_update_string(&definition, SL("type"), &_60$$40, PH_COPY | PH_SEPARATE); + } else if (zephir_memnstr_str(&columnType, SL("text"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 231)) { + ZEPHIR_INIT_NVAR(&_61$$41); + ZVAL_LONG(&_61$$41, 6); + zephir_array_update_string(&definition, SL("type"), &_61$$41, PH_COPY | PH_SEPARATE); } else { - ZEPHIR_CPY_WRT(&alias, &source); - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_62$$42); + ZVAL_LONG(&_62$$42, 2); + zephir_array_update_string(&definition, SL("type"), &_62$$42, PH_COPY | PH_SEPARATE); } - ZEPHIR_OBS_NVAR(&with); - if (zephir_array_isset_string_fetch(&with, &selectedModel, SL("with"), 0)) { - if (!(zephir_array_isset_long(&with, 0))) { - ZEPHIR_INIT_NVAR(&_42$$41); - zephir_create_array(&_42$$41, 1, 0); - zephir_array_fast_append(&_42$$41, &with); - ZEPHIR_CPY_WRT(&withs, &_42$$41); - } else { - ZEPHIR_CPY_WRT(&withs, &with); - } - zephir_is_iterable(&withs, 0, "phalcon/Mvc/Model/Query.zep", 3881); - if (Z_TYPE_P(&withs) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&withs), _43$$40) - { - ZEPHIR_INIT_NVAR(&withItem); - ZVAL_COPY(&withItem, _43$$40); - ZEPHIR_INIT_NVAR(&_45$$43); - ZVAL_LONG(&_45$$43, number); - ZEPHIR_INIT_NVAR(&_46$$43); - ZEPHIR_CONCAT_SV(&_46$$43, "AA", &_45$$43); - ZEPHIR_CPY_WRT(&joinAlias, &_46$$43); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_47, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_48$$44); - ZVAL_STRING(&_48$$44, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_48$$44); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_49, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_50$$46); - object_init_ex(&_50$$46, phalcon_mvc_model_exception_ce); - zephir_read_property(&_51$$46, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_52$$46); - ZEPHIR_CONCAT_SVSVSV(&_52$$46, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_51$$46); - ZEPHIR_CALL_METHOD(NULL, &_50$$46, "__construct", &_8, 32, &_52$$46); - zephir_check_call_status(); - zephir_throw_exception_debug(&_50$$46, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_53$$45); - ZVAL_STRING(&_53$$45, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_53$$45); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_54$$43); - zephir_create_array(&_54$$43, 5, 0); - add_assoc_long_ex(&_54$$43, SL("type"), 353); - zephir_array_update_string(&_54$$43, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_54$$43, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_54$$43, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_54$$43, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_54$$43, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_55$$43); - zephir_create_array(&_55$$43, 3, 0); - add_assoc_long_ex(&_55$$43, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_56$$43); - zephir_create_array(&_56$$43, 2, 0); - add_assoc_long_ex(&_56$$43, SL("type"), 355); - zephir_array_update_string(&_56$$43, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_55$$43, SL("qualified"), &_56$$43, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_56$$43); - zephir_create_array(&_56$$43, 2, 0); - add_assoc_long_ex(&_56$$43, SL("type"), 355); - zephir_array_update_string(&_56$$43, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_55$$43, SL("alias"), &_56$$43, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_55$$43, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &withs, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_44$$40, &withs, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_44$$40)) { - break; - } - ZEPHIR_CALL_METHOD(&withItem, &withs, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_57$$47); - ZVAL_LONG(&_57$$47, number); - ZEPHIR_INIT_NVAR(&_58$$47); - ZEPHIR_CONCAT_SV(&_58$$47, "AA", &_57$$47); - ZEPHIR_CPY_WRT(&joinAlias, &_58$$47); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_59, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_60$$48); - ZVAL_STRING(&_60$$48, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_60$$48); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_61, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_62$$50); - object_init_ex(&_62$$50, phalcon_mvc_model_exception_ce); - zephir_read_property(&_63$$50, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_64$$50); - ZEPHIR_CONCAT_SVSVSV(&_64$$50, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_63$$50); - ZEPHIR_CALL_METHOD(NULL, &_62$$50, "__construct", &_8, 32, &_64$$50); - zephir_check_call_status(); - zephir_throw_exception_debug(&_62$$50, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_65$$49); - ZVAL_STRING(&_65$$49, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_65$$49); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_66$$47); - zephir_create_array(&_66$$47, 5, 0); - add_assoc_long_ex(&_66$$47, SL("type"), 353); - zephir_array_update_string(&_66$$47, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$47, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$47, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$47, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_66$$47, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_67$$47); - zephir_create_array(&_67$$47, 3, 0); - add_assoc_long_ex(&_67$$47, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_68$$47); - zephir_create_array(&_68$$47, 2, 0); - add_assoc_long_ex(&_68$$47, SL("type"), 355); - zephir_array_update_string(&_68$$47, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_67$$47, SL("qualified"), &_68$$47, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_68$$47); - zephir_create_array(&_68$$47, 2, 0); - add_assoc_long_ex(&_68$$47, SL("type"), 355); - zephir_array_update_string(&_68$$47, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_67$$47, SL("alias"), &_68$$47, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_67$$47, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - ZEPHIR_CALL_METHOD(NULL, &withs, "next", NULL, 0); - zephir_check_call_status(); + if (zephir_memnstr_str(&columnType, SL("("), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 248)) { + ZEPHIR_INIT_NVAR(&matches); + ZVAL_NULL(&matches); + ZEPHIR_INIT_NVAR(&_63$$43); + zephir_preg_match(&_63$$43, &sizePattern, &columnType, &matches, 0, 0 , 0 ); + if (zephir_is_true(&_63$$43)) { + ZEPHIR_OBS_NVAR(&matchOne); + if (zephir_array_isset_long_fetch(&matchOne, &matches, 1, 0)) { + ZEPHIR_INIT_NVAR(&_64$$45); + ZVAL_LONG(&_64$$45, zephir_get_intval(&matchOne)); + zephir_array_update_string(&definition, SL("size"), &_64$$45, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&matchTwo); + if (zephir_array_isset_long_fetch(&matchTwo, &matches, 2, 0)) { + ZEPHIR_INIT_NVAR(&_65$$46); + ZVAL_LONG(&_65$$46, zephir_get_intval(&matchTwo)); + zephir_array_update_string(&definition, SL("scale"), &_65$$46, PH_COPY | PH_SEPARATE); } } - ZEPHIR_INIT_NVAR(&withItem); } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3883); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3884); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &selectedModels, "next", NULL, 0); + if (zephir_memnstr_str(&columnType, SL("unsigned"), "phalcon/Db/Adapter/Pdo/Sqlite.zep", 264)) { + zephir_array_update_string(&definition, SL("unsigned"), &__$true, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&oldColumn) == IS_NULL) { + zephir_array_update_string(&definition, SL("first"), &__$true, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_66$$28, &field, 5, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 280); + if (zephir_is_true(&_66$$28)) { + zephir_array_update_string(&definition, SL("primary"), &__$true, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch_long(&_67$$28, &field, 3, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 287); + if (ZEPHIR_IS_LONG(&_67$$28, 0)) { + zephir_array_update_string(&definition, SL("notNull"), &__$false, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&_68$$28); + zephir_array_fetch_long(&_68$$28, &field, 4, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 295); + _69$$28 = !(ZEPHIR_IS_EMPTY(&_68$$28)); + if (_69$$28) { + zephir_array_fetch_long(&_70$$28, &field, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 295); + ZEPHIR_INIT_NVAR(&_71$$28); + ZVAL_STRING(&_71$$28, "null"); + ZEPHIR_CALL_FUNCTION(&_72$$28, "strcasecmp", &_35, 38, &_70$$28, &_71$$28); + zephir_check_call_status(); + _69$$28 = !ZEPHIR_IS_LONG_IDENTICAL(&_72$$28, 0); + } + if (_69$$28) { + zephir_array_fetch_long(&_73$$52, &field, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 300); + ZEPHIR_INIT_NVAR(&_74$$52); + ZVAL_STRING(&_74$$52, "/^'|'$/"); + ZEPHIR_INIT_NVAR(&_75$$52); + ZVAL_STRING(&_75$$52, ""); + ZEPHIR_CALL_FUNCTION(&_76$$52, "preg_replace", &_40, 40, &_74$$52, &_75$$52, &_73$$52); + zephir_check_call_status(); + zephir_array_update_string(&definition, SL("default"), &_76$$52, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&columnName); + zephir_array_fetch_long(&columnName, &field, 1, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 306); + ZEPHIR_INIT_NVAR(&_71$$28); + object_init_ex(&_71$$28, phalcon_db_column_ce); + ZEPHIR_CALL_METHOD(NULL, &_71$$28, "__construct", &_41, 212, &columnName, &definition); + zephir_check_call_status(); + zephir_array_append(&columns, &_71$$28, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 307); + ZEPHIR_CPY_WRT(&oldColumn, &columnName); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&selectedModel); - if (!(merge)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &sqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &sqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); + ZEPHIR_INIT_NVAR(&field); + RETURN_CCTOR(&columns); +} + +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeIndexes) +{ + zend_string *_48; + zend_ulong _47; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_17 = NULL, *_52 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, indexes, index, keyName, indexObjects, name, columns, describeIndexes, describeIndex, indexSql, _0, _1, _2, _3, *_4, _5, *_45, _46, _6$$4, _7$$3, _9$$3, _10$$3, _11$$3, *_12$$3, _13$$3, _16$$3, _18$$3, _8$$6, _14$$7, _15$$8, _19$$9, _20$$9, _21$$9, _22$$9, _23$$10, _24$$11, _25$$12, _26$$14, _27$$13, _29$$13, _30$$13, _31$$13, *_32$$13, _33$$13, _36$$13, _37$$13, _28$$16, _34$$17, _35$$18, _38$$19, _39$$19, _40$$19, _41$$19, _42$$20, _43$$21, _44$$22, _49$$23, _50$$23, _51$$23, _53$$24, _54$$24, _55$$24; + zval table, schema; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&indexes); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&indexObjects); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&describeIndexes); + ZVAL_UNDEF(&describeIndex); + ZVAL_UNDEF(&indexSql); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_46); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_19$$9); + ZVAL_UNDEF(&_20$$9); + ZVAL_UNDEF(&_21$$9); + ZVAL_UNDEF(&_22$$9); + ZVAL_UNDEF(&_23$$10); + ZVAL_UNDEF(&_24$$11); + ZVAL_UNDEF(&_25$$12); + ZVAL_UNDEF(&_26$$14); + ZVAL_UNDEF(&_27$$13); + ZVAL_UNDEF(&_29$$13); + ZVAL_UNDEF(&_30$$13); + ZVAL_UNDEF(&_31$$13); + ZVAL_UNDEF(&_33$$13); + ZVAL_UNDEF(&_36$$13); + ZVAL_UNDEF(&_37$$13); + ZVAL_UNDEF(&_28$$16); + ZVAL_UNDEF(&_34$$17); + ZVAL_UNDEF(&_35$$18); + ZVAL_UNDEF(&_38$$19); + ZVAL_UNDEF(&_39$$19); + ZVAL_UNDEF(&_40$$19); + ZVAL_UNDEF(&_41$$19); + ZVAL_UNDEF(&_42$$20); + ZVAL_UNDEF(&_43$$21); + ZVAL_UNDEF(&_44$$22); + ZVAL_UNDEF(&_49$$23); + ZVAL_UNDEF(&_50$$23); + ZVAL_UNDEF(&_51$$23); + ZVAL_UNDEF(&_53$$24); + ZVAL_UNDEF(&_54$$24); + ZVAL_UNDEF(&_55$$24); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); } else { - ZEPHIR_OBS_VAR(&tempModels); - zephir_read_property(&tempModels, this_ptr, ZEND_STRL("models"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(&tempModelsInstances); - zephir_read_property(&tempModelsInstances, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(&tempSqlAliases); - zephir_read_property(&tempSqlAliases, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(&tempSqlAliasesModels); - zephir_read_property(&tempSqlAliasesModels, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(&tempSqlModelsAliases); - zephir_read_property(&tempSqlModelsAliases, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(&tempSqlAliasesModelsInstances); - zephir_read_property(&tempSqlAliasesModelsInstances, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&_69$$52); - zephir_read_property(&_70$$52, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_69$$52, &_70$$52, &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &_69$$52); - ZEPHIR_INIT_VAR(&_71$$52); - zephir_read_property(&_72$$52, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_71$$52, &_72$$52, &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &_71$$52); - ZEPHIR_INIT_VAR(&_73$$52); - zephir_read_property(&_74$$52, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_73$$52, &_74$$52, &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &_73$$52); - ZEPHIR_INIT_VAR(&_75$$52); - zephir_read_property(&_76$$52, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_75$$52, &_76$$52, &sqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &_75$$52); - ZEPHIR_INIT_VAR(&_77$$52); - zephir_read_property(&_78$$52, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_77$$52, &_78$$52, &sqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &_77$$52); - ZEPHIR_INIT_VAR(&_79$$52); - zephir_read_property(&_80$$52, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_79$$52, &_80$$52, &sqlAliasesModelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &_79$$52); + ZEPHIR_INIT_VAR(&table); } - ZEPHIR_OBS_VAR(&joins); - zephir_array_isset_string_fetch(&joins, &select, SL("joins"), 0); - if (zephir_fast_count_int(&joins)) { - if (zephir_fast_count_int(&automaticJoins)) { - if (zephir_array_isset_long(&joins, 0)) { - ZEPHIR_INIT_VAR(&_81$$55); - zephir_fast_array_merge(&_81$$55, &joins, &automaticJoins); - zephir_array_update_string(&select, SL("joins"), &_81$$55, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&automaticJoins, &joins, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3920); - zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "getjoins", NULL, 474, &select); - zephir_check_call_status(); + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); } else { - if (zephir_fast_count_int(&automaticJoins)) { - zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "getjoins", NULL, 474, &select); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&sqlJoins); - array_init(&sqlJoins); - } + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); } - position = 0; - ZEPHIR_INIT_VAR(&sqlColumnAliases); - array_init(&sqlColumnAliases); - zephir_is_iterable(&selectColumns, 0, "phalcon/Mvc/Model/Query.zep", 3971); - if (Z_TYPE_P(&selectColumns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectColumns), _82) + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); + } + } + + + ZEPHIR_INIT_VAR(&indexes); + array_init(&indexes); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describeindexes", NULL, 0, &table, &schema); + zephir_check_call_status(); + ZVAL_LONG(&_3, 2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); + zephir_check_call_status(); + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 369); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _4) { - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _82); - ZEPHIR_CALL_METHOD(&_84$$60, this_ptr, "getselectcolumn", &_85, 475, &column); + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _4); + ZEPHIR_OBS_NVAR(&keyName); + zephir_array_fetch_string(&keyName, &index, SL("name"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 331); + if (!(zephir_array_isset(&indexes, &keyName))) { + ZEPHIR_INIT_NVAR(&_6$$4); + array_init(&_6$$4); + zephir_array_update_zval(&indexes, &keyName, &_6$$4, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch(&_7$$3, &indexes, &keyName, PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 337); + if (!(zephir_array_isset_string(&_7$$3, SL("columns")))) { + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + } else { + zephir_array_fetch(&_8$$6, &indexes, &keyName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 340); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_8$$6, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 340); + } + zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_10$$3, &_9$$3, "describeindex", NULL, 0, &keyName); zephir_check_call_status(); - zephir_is_iterable(&_84$$60, 0, "phalcon/Mvc/Model/Query.zep", 3969); - if (Z_TYPE_P(&_84$$60) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_84$$60), _86$$60) + ZVAL_LONG(&_11$$3, 2); + ZEPHIR_CALL_METHOD(&describeIndexes, this_ptr, "fetchall", NULL, 0, &_10$$3, &_11$$3); + zephir_check_call_status(); + zephir_is_iterable(&describeIndexes, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 352); + if (Z_TYPE_P(&describeIndexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&describeIndexes), _12$$3) { - ZEPHIR_INIT_NVAR(&sqlColumn); - ZVAL_COPY(&sqlColumn, _86$$60); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_88$$65, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_88$$65, "scalar")) { - ZEPHIR_INIT_NVAR(&_89$$66); - ZVAL_LONG(&_89$$66, position); - ZEPHIR_INIT_NVAR(&_90$$66); - ZEPHIR_CONCAT_SV(&_90$$66, "_", &_89$$66); - zephir_array_update_zval(&sqlColumns, &_90$$66, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; + ZEPHIR_INIT_NVAR(&describeIndex); + ZVAL_COPY(&describeIndex, _12$$3); + zephir_array_fetch_string(&_14$$7, &describeIndex, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); + zephir_array_append(&columns, &_14$$7, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_84$$60, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &describeIndexes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_87$$60, &_84$$60, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_13$$3, &describeIndexes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_87$$60)) { + if (!zend_is_true(&_13$$3)) { break; } - ZEPHIR_CALL_METHOD(&sqlColumn, &_84$$60, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&describeIndex, &describeIndexes, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_91$$72, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_91$$72, "scalar")) { - ZEPHIR_INIT_NVAR(&_92$$73); - ZVAL_LONG(&_92$$73, position); - ZEPHIR_INIT_NVAR(&_93$$73); - ZEPHIR_CONCAT_SV(&_93$$73, "_", &_92$$73); - zephir_array_update_zval(&sqlColumns, &_93$$73, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; - ZEPHIR_CALL_METHOD(NULL, &_84$$60, "next", NULL, 0); + zephir_array_fetch_string(&_15$$8, &describeIndex, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); + zephir_array_append(&columns, &_15$$8, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); + ZEPHIR_CALL_METHOD(NULL, &describeIndexes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&sqlColumn); + ZEPHIR_INIT_NVAR(&describeIndex); + zephir_array_update_multi(&indexes, &columns, SL("zs"), 3, &keyName, SL("columns")); + zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_16$$3, &_11$$3, "listindexessql", NULL, 0, &table, &schema, &keyName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexSql, this_ptr, "fetchcolumn", &_17, 0, &_16$$3); + zephir_check_call_status(); + zephir_array_fetch_string(&_18$$3, &index, SL("unique"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 358); + if (zephir_is_true(&_18$$3)) { + ZEPHIR_INIT_NVAR(&_19$$9); + ZEPHIR_INIT_NVAR(&_20$$9); + ZVAL_STRING(&_20$$9, "# UNIQUE #i"); + ZEPHIR_INIT_NVAR(&_21$$9); + ZEPHIR_INIT_NVAR(&_22$$9); + ZVAL_STRING(&_22$$9, "# UNIQUE #i"); + zephir_preg_match(&_21$$9, &_22$$9, &indexSql, &_19$$9, 0, 0 , 0 ); + if (zephir_is_true(&_21$$9)) { + ZEPHIR_INIT_NVAR(&_23$$10); + ZVAL_STRING(&_23$$10, "UNIQUE"); + zephir_array_update_multi(&indexes, &_23$$10, SL("zs"), 3, &keyName, SL("type")); + } else { + ZEPHIR_INIT_NVAR(&_24$$11); + ZVAL_STRING(&_24$$11, "PRIMARY"); + zephir_array_update_multi(&indexes, &_24$$11, SL("zs"), 3, &keyName, SL("type")); + } + } else { + ZEPHIR_INIT_NVAR(&_25$$12); + ZVAL_STRING(&_25$$12, ""); + zephir_array_update_multi(&indexes, &_25$$12, SL("zs"), 3, &keyName, SL("type")); + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &selectColumns, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_83, &selectColumns, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_83)) { + if (!zend_is_true(&_5)) { break; } - ZEPHIR_CALL_METHOD(&column, &selectColumns, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&index, &_0, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_94$$75, this_ptr, "getselectcolumn", &_85, 475, &column); + ZEPHIR_OBS_NVAR(&keyName); + zephir_array_fetch_string(&keyName, &index, SL("name"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 331); + if (!(zephir_array_isset(&indexes, &keyName))) { + ZEPHIR_INIT_NVAR(&_26$$14); + array_init(&_26$$14); + zephir_array_update_zval(&indexes, &keyName, &_26$$14, PH_COPY | PH_SEPARATE); + } + zephir_array_fetch(&_27$$13, &indexes, &keyName, PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 337); + if (!(zephir_array_isset_string(&_27$$13, SL("columns")))) { + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + } else { + zephir_array_fetch(&_28$$16, &indexes, &keyName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 340); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_28$$16, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 340); + } + zephir_read_property(&_29$$13, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_30$$13, &_29$$13, "describeindex", NULL, 0, &keyName); zephir_check_call_status(); - zephir_is_iterable(&_94$$75, 0, "phalcon/Mvc/Model/Query.zep", 3969); - if (Z_TYPE_P(&_94$$75) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_94$$75), _95$$75) + ZVAL_LONG(&_31$$13, 2); + ZEPHIR_CALL_METHOD(&describeIndexes, this_ptr, "fetchall", NULL, 0, &_30$$13, &_31$$13); + zephir_check_call_status(); + zephir_is_iterable(&describeIndexes, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 352); + if (Z_TYPE_P(&describeIndexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&describeIndexes), _32$$13) { - ZEPHIR_INIT_NVAR(&sqlColumn); - ZVAL_COPY(&sqlColumn, _95$$75); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_97$$80, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_97$$80, "scalar")) { - ZEPHIR_INIT_NVAR(&_98$$81); - ZVAL_LONG(&_98$$81, position); - ZEPHIR_INIT_NVAR(&_99$$81); - ZEPHIR_CONCAT_SV(&_99$$81, "_", &_98$$81); - zephir_array_update_zval(&sqlColumns, &_99$$81, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; + ZEPHIR_INIT_NVAR(&describeIndex); + ZVAL_COPY(&describeIndex, _32$$13); + zephir_array_fetch_string(&_34$$17, &describeIndex, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); + zephir_array_append(&columns, &_34$$17, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_94$$75, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &describeIndexes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_96$$75, &_94$$75, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_33$$13, &describeIndexes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_96$$75)) { + if (!zend_is_true(&_33$$13)) { break; } - ZEPHIR_CALL_METHOD(&sqlColumn, &_94$$75, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&describeIndex, &describeIndexes, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_100$$87, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_100$$87, "scalar")) { - ZEPHIR_INIT_NVAR(&_101$$88); - ZVAL_LONG(&_101$$88, position); - ZEPHIR_INIT_NVAR(&_102$$88); - ZEPHIR_CONCAT_SV(&_102$$88, "_", &_101$$88); - zephir_array_update_zval(&sqlColumns, &_102$$88, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; - ZEPHIR_CALL_METHOD(NULL, &_94$$75, "next", NULL, 0); + zephir_array_fetch_string(&_35$$18, &describeIndex, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); + zephir_array_append(&columns, &_35$$18, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 349); + ZEPHIR_CALL_METHOD(NULL, &describeIndexes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&sqlColumn); - ZEPHIR_CALL_METHOD(NULL, &selectColumns, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&describeIndex); + zephir_array_update_multi(&indexes, &columns, SL("zs"), 3, &keyName, SL("columns")); + zephir_read_property(&_31$$13, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_36$$13, &_31$$13, "listindexessql", NULL, 0, &table, &schema, &keyName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&indexSql, this_ptr, "fetchcolumn", &_17, 0, &_36$$13); + zephir_check_call_status(); + zephir_array_fetch_string(&_37$$13, &index, SL("unique"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 358); + if (zephir_is_true(&_37$$13)) { + ZEPHIR_INIT_NVAR(&_38$$19); + ZEPHIR_INIT_NVAR(&_39$$19); + ZVAL_STRING(&_39$$19, "# UNIQUE #i"); + ZEPHIR_INIT_NVAR(&_40$$19); + ZEPHIR_INIT_NVAR(&_41$$19); + ZVAL_STRING(&_41$$19, "# UNIQUE #i"); + zephir_preg_match(&_40$$19, &_41$$19, &indexSql, &_38$$19, 0, 0 , 0 ); + if (zephir_is_true(&_40$$19)) { + ZEPHIR_INIT_NVAR(&_42$$20); + ZVAL_STRING(&_42$$20, "UNIQUE"); + zephir_array_update_multi(&indexes, &_42$$20, SL("zs"), 3, &keyName, SL("type")); + } else { + ZEPHIR_INIT_NVAR(&_43$$21); + ZVAL_STRING(&_43$$21, "PRIMARY"); + zephir_array_update_multi(&indexes, &_43$$21, SL("zs"), 3, &keyName, SL("type")); + } + } else { + ZEPHIR_INIT_NVAR(&_44$$22); + ZVAL_STRING(&_44$$22, ""); + zephir_array_update_multi(&indexes, &_44$$22, SL("zs"), 3, &keyName, SL("type")); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_OBS_VAR(&_103); - zephir_read_property(&_103, this_ptr, ZEND_STRL("nestingLevel"), PH_NOISY_CC); - zephir_update_property_array(this_ptr, SL("sqlColumnAliases"), &_103, &sqlColumnAliases); - ZEPHIR_INIT_VAR(&sqlSelect); - zephir_create_array(&sqlSelect, 3, 0); - zephir_array_update_string(&sqlSelect, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlSelect, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlSelect, SL("columns"), &sqlColumns, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_VAR(&distinct); - if (zephir_array_isset_string_fetch(&distinct, &select, SL("distinct"), 0)) { - zephir_array_update_string(&sqlSelect, SL("distinct"), &distinct, PH_COPY | PH_SEPARATE); - } - if (zephir_fast_count_int(&sqlJoins)) { - zephir_array_update_string(&sqlSelect, SL("joins"), &sqlJoins, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&where); - if (zephir_array_isset_string_fetch(&where, ast, SL("where"), 0)) { - ZEPHIR_CALL_METHOD(&_104$$92, this_ptr, "getexpression", NULL, 459, &where); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("where"), &_104$$92, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&groupBy); - if (zephir_array_isset_string_fetch(&groupBy, ast, SL("groupBy"), 0)) { - ZEPHIR_CALL_METHOD(&_105$$93, this_ptr, "getgroupclause", NULL, 476, &groupBy); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("group"), &_105$$93, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&having); - if (zephir_array_isset_string_fetch(&having, ast, SL("having"), 0)) { - ZEPHIR_CALL_METHOD(&_106$$94, this_ptr, "getexpression", NULL, 459, &having); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("having"), &_106$$94, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&order); - if (zephir_array_isset_string_fetch(&order, ast, SL("orderBy"), 0)) { - ZEPHIR_CALL_METHOD(&_107$$95, this_ptr, "getorderclause", NULL, 477, &order); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("order"), &_107$$95, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&limit); - if (zephir_array_isset_string_fetch(&limit, ast, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(&_108$$96, this_ptr, "getlimitclause", NULL, 473, &limit); + ZEPHIR_INIT_NVAR(&index); + ZEPHIR_INIT_VAR(&indexObjects); + array_init(&indexObjects); + zephir_is_iterable(&indexes, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 379); + if (Z_TYPE_P(&indexes) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&indexes), _47, _48, _45) + { + ZEPHIR_INIT_NVAR(&name); + if (_48 != NULL) { + ZVAL_STR_COPY(&name, _48); + } else { + ZVAL_LONG(&name, _47); + } + ZEPHIR_INIT_NVAR(&index); + ZVAL_COPY(&index, _45); + ZEPHIR_INIT_NVAR(&_49$$23); + object_init_ex(&_49$$23, phalcon_db_index_ce); + zephir_array_fetch_string(&_50$$23, &index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 374); + zephir_array_fetch_string(&_51$$23, &index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 376); + ZEPHIR_CALL_METHOD(NULL, &_49$$23, "__construct", &_52, 33, &name, &_50$$23, &_51$$23); + zephir_check_call_status(); + zephir_array_update_zval(&indexObjects, &name, &_49$$23, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &indexes, "rewind", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("limit"), &_108$$96, PH_COPY | PH_SEPARATE); - } - if (zephir_array_isset_string(ast, SL("forUpdate"))) { - zephir_array_update_string(&sqlSelect, SL("forUpdate"), &__$true, PH_COPY | PH_SEPARATE); - } - if (merge) { - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &tempModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &tempModelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &tempSqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &tempSqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &tempSqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &tempSqlAliasesModelsInstances); + while (1) { + ZEPHIR_CALL_METHOD(&_46, &indexes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_46)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &indexes, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&index, &indexes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_53$$24); + object_init_ex(&_53$$24, phalcon_db_index_ce); + zephir_array_fetch_string(&_54$$24, &index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 374); + zephir_array_fetch_string(&_55$$24, &index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 376); + ZEPHIR_CALL_METHOD(NULL, &_53$$24, "__construct", &_52, 33, &name, &_54$$24, &_55$$24); + zephir_check_call_status(); + zephir_array_update_zval(&indexObjects, &name, &_53$$24, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &indexes, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("nestingLevel"))); - RETURN_CCTOR(&sqlSelect); + ZEPHIR_INIT_NVAR(&index); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&indexObjects); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareUpdate) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeReferences) { - zval _15$$20, _22$$21; - zend_bool notQuoting = 0; + zval _14$$3, _21$$6, _27$$9, _31$$10; + zend_string *_7, *_25; + zend_ulong _6, _24; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, ast, update, tables, values, modelsInstances, models, sqlTables, sqlAliases, sqlAliasesModelsInstances, updateTables, completeSource, sqlModels, manager, table, qualifiedName, modelName, model, source, schema, alias, sqlFields, sqlValues, updateValues, updateValue, exprColumn, sqlUpdate, where, limit, _0, *_1, _2, *_9, _10, _4$$9, _5$$10, _7$$14, _8$$15, _11$$20, _12$$20, _13$$20, _16$$20, _17$$20, _18$$20, _19$$21, _20$$21, _21$$21, _23$$21, _24$$21, _25$$21, _26$$22, _27$$22, _28$$23; - zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL, *_14 = NULL; + zephir_fcall_cache_entry *_29 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *table_param = NULL, *schema_param = NULL, references, reference, arrayReference, constraintName, referenceObjects, name, referencedSchema, referencedTable, columns, referencedColumns, number, _0, _1, _2, _3, *_4, _5, *_22, _23, _8$$5, _9$$5, _10$$5, _11$$5, _12$$3, _13$$3, _15$$8, _16$$8, _17$$8, _18$$8, _19$$6, _20$$6, _26$$9, _28$$9, _30$$10, _32$$10; + zval table, schema; zval *this_ptr = getThis(); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&update); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&sqlTables); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&updateTables); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&sqlModels); - ZVAL_UNDEF(&manager); ZVAL_UNDEF(&table); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&sqlFields); - ZVAL_UNDEF(&sqlValues); - ZVAL_UNDEF(&updateValues); - ZVAL_UNDEF(&updateValue); - ZVAL_UNDEF(&exprColumn); - ZVAL_UNDEF(&sqlUpdate); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&references); + ZVAL_UNDEF(&reference); + ZVAL_UNDEF(&arrayReference); + ZVAL_UNDEF(&constraintName); + ZVAL_UNDEF(&referenceObjects); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&referencedSchema); + ZVAL_UNDEF(&referencedTable); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&referencedColumns); + ZVAL_UNDEF(&number); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_5$$10); - ZVAL_UNDEF(&_7$$14); - ZVAL_UNDEF(&_8$$15); - ZVAL_UNDEF(&_11$$20); - ZVAL_UNDEF(&_12$$20); - ZVAL_UNDEF(&_13$$20); - ZVAL_UNDEF(&_16$$20); - ZVAL_UNDEF(&_17$$20); - ZVAL_UNDEF(&_18$$20); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$21); - ZVAL_UNDEF(&_21$$21); - ZVAL_UNDEF(&_23$$21); - ZVAL_UNDEF(&_24$$21); - ZVAL_UNDEF(&_25$$21); - ZVAL_UNDEF(&_26$$22); - ZVAL_UNDEF(&_27$$22); - ZVAL_UNDEF(&_28$$23); - ZVAL_UNDEF(&_15$$20); - ZVAL_UNDEF(&_22$$21); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_23); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_18$$8); + ZVAL_UNDEF(&_19$$6); + ZVAL_UNDEF(&_20$$6); + ZVAL_UNDEF(&_26$$9); + ZVAL_UNDEF(&_28$$9); + ZVAL_UNDEF(&_30$$10); + ZVAL_UNDEF(&_32$$10); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_21$$6); + ZVAL_UNDEF(&_27$$9); + ZVAL_UNDEF(&_31$$10); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(table) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(schema) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ast, &_0); - ZEPHIR_OBS_VAR(&update); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&update, &ast, SL("update"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4048); - return; + zephir_fetch_params(1, 1, 1, &table_param, &schema_param); + if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_OBS_VAR(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &update, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4052); - return; + if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { + zephir_get_strval(&table, table_param); + } else { + ZEPHIR_INIT_VAR(&table); } - ZEPHIR_OBS_VAR(&values); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&values, &update, SL("values"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4056); - return; + if (!schema_param) { + ZEPHIR_INIT_VAR(&schema); + } else { + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&models); - array_init(&models); - ZEPHIR_INIT_VAR(&modelsInstances); - array_init(&modelsInstances); - ZEPHIR_INIT_VAR(&sqlTables); - array_init(&sqlTables); - ZEPHIR_INIT_VAR(&sqlModels); - array_init(&sqlModels); - ZEPHIR_INIT_VAR(&sqlAliases); - array_init(&sqlAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); - array_init(&sqlAliasesModelsInstances); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&updateTables); - zephir_create_array(&updateTables, 1, 0); - zephir_array_fast_append(&updateTables, &tables); + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); } else { - ZEPHIR_CPY_WRT(&updateTables, &tables); + ZEPHIR_INIT_VAR(&schema); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_is_iterable(&updateTables, 0, "phalcon/Mvc/Model/Query.zep", 4122); - if (Z_TYPE_P(&updateTables) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&updateTables), _1) + } + + + ZEPHIR_INIT_VAR(&references); + array_init(&references); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dialect"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "describereferences", NULL, 0, &table, &schema); + zephir_check_call_status(); + ZVAL_LONG(&_3, 3); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, &_2, &_3); + zephir_check_call_status(); + zephir_is_iterable(&_0, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 419); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _6, _7, _4) { - ZEPHIR_INIT_NVAR(&table); - ZVAL_COPY(&table, _1); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4080); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4081); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_3, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&completeSource); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_4$$9); - zephir_create_array(&_4$$9, 2, 0); - zephir_array_fast_append(&_4$$9, &source); - zephir_array_fast_append(&_4$$9, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_4$$9); + ZEPHIR_INIT_NVAR(&number); + if (_7 != NULL) { + ZVAL_STR_COPY(&number, _7); } else { - ZEPHIR_INIT_NVAR(&_5$$10); - zephir_create_array(&_5$$10, 2, 0); - zephir_array_fast_append(&_5$$10, &source); - zephir_array_fast_append(&_5$$10, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_5$$10); + ZVAL_LONG(&number, _6); } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4104); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4105); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&reference); + ZVAL_COPY(&reference, _4); + ZEPHIR_INIT_NVAR(&constraintName); + ZEPHIR_CONCAT_SV(&constraintName, "foreign_key_", &number); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_INIT_NVAR(&referencedSchema); + ZVAL_NULL(&referencedSchema); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 398); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4111); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_fetch(&_8$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 402); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_8$$5, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 402); + zephir_array_fetch(&_9$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 403); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_9$$5, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 403); + zephir_array_fetch(&_10$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 404); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_10$$5, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 404); + zephir_array_fetch(&_11$$5, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 405); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_11$$5, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 405); } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4115); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_12$$3, &reference, 3, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 408); + zephir_array_append(&columns, &_12$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 408); + zephir_array_fetch_long(&_13$$3, &reference, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 409); + zephir_array_append(&referencedColumns, &_13$$3, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 409); + ZEPHIR_INIT_NVAR(&_14$$3); + zephir_create_array(&_14$$3, 4, 0); + zephir_array_update_string(&_14$$3, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$3, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_14$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &updateTables, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &updateTables, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_5, &_0, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2)) { + if (!zend_is_true(&_5)) { break; } - ZEPHIR_CALL_METHOD(&table, &updateTables, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&number, &_0, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4080); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4081); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_6, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_7$$14); - zephir_create_array(&_7$$14, 2, 0); - zephir_array_fast_append(&_7$$14, &source); - zephir_array_fast_append(&_7$$14, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_7$$14); - } else { - ZEPHIR_INIT_NVAR(&_8$$15); - zephir_create_array(&_8$$15, 2, 0); - zephir_array_fast_append(&_8$$15, &source); - zephir_array_fast_append(&_8$$15, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_8$$15); - } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4104); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4105); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&reference, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&constraintName); + ZEPHIR_CONCAT_SV(&constraintName, "foreign_key_", &number); + if (!(zephir_array_isset(&references, &constraintName))) { + ZEPHIR_INIT_NVAR(&referencedSchema); + ZVAL_NULL(&referencedSchema); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_long(&referencedTable, &reference, 2, PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 398); + ZEPHIR_INIT_NVAR(&columns); + array_init(&columns); + ZEPHIR_INIT_NVAR(&referencedColumns); + array_init(&referencedColumns); } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4111); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_fetch(&_15$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 402); + ZEPHIR_OBS_NVAR(&referencedSchema); + zephir_array_fetch_string(&referencedSchema, &_15$$8, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 402); + zephir_array_fetch(&_16$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 403); + ZEPHIR_OBS_NVAR(&referencedTable); + zephir_array_fetch_string(&referencedTable, &_16$$8, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 403); + zephir_array_fetch(&_17$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 404); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_17$$8, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 404); + zephir_array_fetch(&_18$$8, &references, &constraintName, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 405); + ZEPHIR_OBS_NVAR(&referencedColumns); + zephir_array_fetch_string(&referencedColumns, &_18$$8, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 405); } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4115); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &updateTables, "next", NULL, 0); + zephir_array_fetch_long(&_19$$6, &reference, 3, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 408); + zephir_array_append(&columns, &_19$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 408); + zephir_array_fetch_long(&_20$$6, &reference, 4, PH_NOISY | PH_READONLY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 409); + zephir_array_append(&referencedColumns, &_20$$6, PH_SEPARATE, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 409); + ZEPHIR_INIT_NVAR(&_21$$6); + zephir_create_array(&_21$$6, 4, 0); + zephir_array_update_string(&_21$$6, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$6, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$6, SL("columns"), &columns, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$6, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&references, &constraintName, &_21$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&table); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - ZEPHIR_INIT_VAR(&sqlFields); - array_init(&sqlFields); - ZEPHIR_INIT_VAR(&sqlValues); - array_init(&sqlValues); - if (!(zephir_array_isset_long(&values, 0))) { - ZEPHIR_INIT_VAR(&updateValues); - zephir_create_array(&updateValues, 1, 0); - zephir_array_fast_append(&updateValues, &values); - } else { - ZEPHIR_CPY_WRT(&updateValues, &values); - } - notQuoting = 0; - zephir_is_iterable(&updateValues, 0, "phalcon/Mvc/Model/Query.zep", 4146); - if (Z_TYPE_P(&updateValues) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&updateValues), _9) + ZEPHIR_INIT_NVAR(&reference); + ZEPHIR_INIT_NVAR(&number); + ZEPHIR_INIT_VAR(&referenceObjects); + array_init(&referenceObjects); + zephir_is_iterable(&references, 0, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 433); + if (Z_TYPE_P(&references) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&references), _24, _25, _22) { - ZEPHIR_INIT_NVAR(&updateValue); - ZVAL_COPY(&updateValue, _9); - zephir_array_fetch_string(&_12$$20, &updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 4138); - if (notQuoting) { - ZVAL_BOOL(&_13$$20, 1); - } else { - ZVAL_BOOL(&_13$$20, 0); - } - ZEPHIR_CALL_METHOD(&_11$$20, this_ptr, "getexpression", &_14, 459, &_12$$20, &_13$$20); - zephir_check_call_status(); - zephir_array_append(&sqlFields, &_11$$20, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4138); - ZEPHIR_OBS_NVAR(&exprColumn); - zephir_array_fetch_string(&exprColumn, &updateValue, SL("expr"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4139); - ZEPHIR_INIT_NVAR(&_15$$20); - zephir_create_array(&_15$$20, 2, 0); - ZEPHIR_OBS_NVAR(&_16$$20); - zephir_array_fetch_string(&_16$$20, &exprColumn, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4141); - zephir_array_update_string(&_15$$20, SL("type"), &_16$$20, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_18$$20, 1); + ZEPHIR_INIT_NVAR(&name); + if (_25 != NULL) { + ZVAL_STR_COPY(&name, _25); } else { - ZVAL_BOOL(&_18$$20, 0); + ZVAL_LONG(&name, _24); } - ZEPHIR_CALL_METHOD(&_17$$20, this_ptr, "getexpression", &_14, 459, &exprColumn, &_18$$20); + ZEPHIR_INIT_NVAR(&arrayReference); + ZVAL_COPY(&arrayReference, _22); + ZEPHIR_INIT_NVAR(&_26$$9); + object_init_ex(&_26$$9, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_27$$9); + zephir_create_array(&_27$$9, 4, 0); + ZEPHIR_OBS_NVAR(&_28$$9); + zephir_array_fetch_string(&_28$$9, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 425); + zephir_array_update_string(&_27$$9, SL("referencedSchema"), &_28$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_28$$9); + zephir_array_fetch_string(&_28$$9, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 426); + zephir_array_update_string(&_27$$9, SL("referencedTable"), &_28$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_28$$9); + zephir_array_fetch_string(&_28$$9, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 427); + zephir_array_update_string(&_27$$9, SL("columns"), &_28$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_28$$9); + zephir_array_fetch_string(&_28$$9, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 429); + zephir_array_update_string(&_27$$9, SL("referencedColumns"), &_28$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_26$$9, "__construct", &_29, 34, &name, &_27$$9); zephir_check_call_status(); - zephir_array_update_string(&_15$$20, SL("value"), &_17$$20, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlValues, &_15$$20, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4143); + zephir_array_update_zval(&referenceObjects, &name, &_26$$9, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &updateValues, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &references, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_10, &updateValues, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_23, &references, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_10)) { + if (!zend_is_true(&_23)) { break; } - ZEPHIR_CALL_METHOD(&updateValue, &updateValues, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&name, &references, "key", NULL, 0); zephir_check_call_status(); - zephir_array_fetch_string(&_20$$21, &updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 4138); - if (notQuoting) { - ZVAL_BOOL(&_21$$21, 1); - } else { - ZVAL_BOOL(&_21$$21, 0); - } - ZEPHIR_CALL_METHOD(&_19$$21, this_ptr, "getexpression", &_14, 459, &_20$$21, &_21$$21); - zephir_check_call_status(); - zephir_array_append(&sqlFields, &_19$$21, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4138); - ZEPHIR_OBS_NVAR(&exprColumn); - zephir_array_fetch_string(&exprColumn, &updateValue, SL("expr"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4139); - ZEPHIR_INIT_NVAR(&_22$$21); - zephir_create_array(&_22$$21, 2, 0); - ZEPHIR_OBS_NVAR(&_23$$21); - zephir_array_fetch_string(&_23$$21, &exprColumn, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4141); - zephir_array_update_string(&_22$$21, SL("type"), &_23$$21, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_25$$21, 1); - } else { - ZVAL_BOOL(&_25$$21, 0); - } - ZEPHIR_CALL_METHOD(&_24$$21, this_ptr, "getexpression", &_14, 459, &exprColumn, &_25$$21); + ZEPHIR_CALL_METHOD(&arrayReference, &references, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_30$$10); + object_init_ex(&_30$$10, phalcon_db_reference_ce); + ZEPHIR_INIT_NVAR(&_31$$10); + zephir_create_array(&_31$$10, 4, 0); + ZEPHIR_OBS_NVAR(&_32$$10); + zephir_array_fetch_string(&_32$$10, &arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 425); + zephir_array_update_string(&_31$$10, SL("referencedSchema"), &_32$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_32$$10); + zephir_array_fetch_string(&_32$$10, &arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 426); + zephir_array_update_string(&_31$$10, SL("referencedTable"), &_32$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_32$$10); + zephir_array_fetch_string(&_32$$10, &arrayReference, SL("columns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 427); + zephir_array_update_string(&_31$$10, SL("columns"), &_32$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_32$$10); + zephir_array_fetch_string(&_32$$10, &arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/Db/Adapter/Pdo/Sqlite.zep", 429); + zephir_array_update_string(&_31$$10, SL("referencedColumns"), &_32$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_30$$10, "__construct", &_29, 34, &name, &_31$$10); zephir_check_call_status(); - zephir_array_update_string(&_22$$21, SL("value"), &_24$$21, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlValues, &_22$$21, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4143); - ZEPHIR_CALL_METHOD(NULL, &updateValues, "next", NULL, 0); + zephir_array_update_zval(&referenceObjects, &name, &_30$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &references, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&updateValue); - ZEPHIR_INIT_VAR(&sqlUpdate); - zephir_create_array(&sqlUpdate, 4, 0); - zephir_array_update_string(&sqlUpdate, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlUpdate, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlUpdate, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlUpdate, SL("values"), &sqlValues, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_VAR(&where); - if (zephir_array_isset_string_fetch(&where, &ast, SL("where"), 0)) { - ZVAL_BOOL(&_27$$22, 1); - ZEPHIR_CALL_METHOD(&_26$$22, this_ptr, "getexpression", &_14, 459, &where, &_27$$22); - zephir_check_call_status(); - zephir_array_update_string(&sqlUpdate, SL("where"), &_26$$22, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&limit); - if (zephir_array_isset_string_fetch(&limit, &ast, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(&_28$$23, this_ptr, "getlimitclause", NULL, 473, &limit); - zephir_check_call_status(); - zephir_array_update_string(&sqlUpdate, SL("limit"), &_28$$23, PH_COPY | PH_SEPARATE); - } - RETURN_CCTOR(&sqlUpdate); + ZEPHIR_INIT_NVAR(&arrayReference); + ZEPHIR_INIT_NVAR(&name); + RETURN_CCTOR(&referenceObjects); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, getDefaultValue) { - zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_17$$11); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlModelsAliases"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlColumnAliases"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliasesModels"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliases"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelsInstances"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("models"), &_13$$9); - } - zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_14) == IS_NULL) { - ZEPHIR_INIT_VAR(&_15$$10); - array_init(&_15$$10); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_15$$10); - } - zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_16) == IS_NULL) { - ZEPHIR_INIT_VAR(&_17$$11); - array_init(&_17$$11); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_17$$11); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); -#ifdef HAVE_CONFIG_H -#endif + ZEPHIR_MM_GROW(); + object_init_ex(return_value, phalcon_db_rawvalue_ce); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "NULL"); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 35, &_0); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, useExplicitIdValue) +{ + zval *this_ptr = getThis(); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_QueryInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, QueryInterface, phalcon, mvc_model_queryinterface, phalcon_mvc_model_queryinterface_method_entry); - return SUCCESS; + RETURN_BOOL(1); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, cache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, execute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getCacheOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getSql); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getSingleResult); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getUniqueRow); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, parse); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setSharedLock); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setUniqueRow); +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, supportsDefaultValue) +{ + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif + RETURN_BOOL(0); +} +static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, getDsnDefaults) +{ + zval *this_ptr = getThis(); + array_init(return_value); + return; +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Relation) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Relation, phalcon, mvc_model_relation, phalcon_mvc_model_relation_method_entry, 0); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("fields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateFields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateModel"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateReferencedFields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("referencedFields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("referencedModel"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("type"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_relation_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Relation; - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_CASCADE"), 2); - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_RESTRICT"), 1); - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("BELONGS_TO"), 0); +#ifdef HAVE_CONFIG_H +#endif - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY"), 2); - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY_THROUGH"), 4); - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE"), 1); - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE_THROUGH"), 3); - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("NO_ACTION"), 0); +ZEPHIR_INIT_CLASS(Phalcon_Db_Profiler_Item) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Db\\Profiler, Item, phalcon, db_profiler_item, phalcon_db_profiler_item_method_entry, 0); - zend_class_implements(phalcon_mvc_model_relation_ce, 1, phalcon_mvc_model_relationinterface_ce); + zend_declare_property_null(phalcon_db_profiler_item_ce, SL("finalTime"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_profiler_item_ce, SL("initialTime"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_profiler_item_ce, SL("sqlBindTypes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_profiler_item_ce, SL("sqlStatement"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_db_profiler_item_ce, SL("sqlVariables"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, __construct) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getFinalTime) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval options; - zval referencedModel; - zval *type_param = NULL, *referencedModel_param = NULL, *fields, fields_sub, *referencedFields, referencedFields_sub, *options_param = NULL, _0; - zend_long type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&options); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_LONG(type) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(fields) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 1, &type_param, &referencedModel_param, &fields, &referencedFields, &options_param); - type = zephir_get_intval(type_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, type); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("referencedModel"), &referencedModel); - zephir_update_property_zval(this_ptr, ZEND_STRL("fields"), fields); - zephir_update_property_zval(this_ptr, ZEND_STRL("referencedFields"), referencedFields); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "finalTime"); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getFields) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getInitialTime) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "fields"); + RETURN_MEMBER(getThis(), "initialTime"); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getForeignKey) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getSqlBindTypes) { - zval options, foreignKey, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&foreignKey); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - if (zephir_array_isset_string_fetch(&foreignKey, &options, SL("foreignKey"), 1)) { - if (zephir_is_true(&foreignKey)) { - RETURN_CTOR(&foreignKey); - } - } - RETURN_MM_BOOL(0); + RETURN_MEMBER(getThis(), "sqlBindTypes"); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateFields) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getSqlStatement) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "intermediateFields"); + RETURN_MEMBER(getThis(), "sqlStatement"); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateModel) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getSqlVariables) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "intermediateModel"); + RETURN_MEMBER(getThis(), "sqlVariables"); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateReferencedFields) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getTotalElapsedNanoseconds) { + zval _0, _1; zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); - RETURN_MEMBER(getThis(), "intermediateReferencedFields"); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("finalTime"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("initialTime"), PH_NOISY_CC | PH_READONLY); + zephir_sub_function(return_value, &_0, &_1); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOption) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getTotalElapsedMilliseconds) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, option, _0; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&option); ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&option, &_0, &name, 1))) { - RETURN_MM_NULL(); - } - RETURN_CTOR(&option); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOptions) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "options"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettotalelapsednanoseconds", NULL, 0); + zephir_check_call_status(); + RETURN_MM_DOUBLE(zephir_safe_div_zval_long(&_0, 1000000)); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getParams) +static PHP_METHOD(Phalcon_Db_Profiler_Item, getTotalElapsedSeconds) { - zval options, params, _0; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(¶ms); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - ZEPHIR_OBS_VAR(¶ms); - if (zephir_array_isset_string_fetch(¶ms, &options, SL("params"), 0)) { - if (zephir_is_true(¶ms)) { - if (zephir_is_callable(¶ms)) { - ZEPHIR_CALL_USER_FUNC(return_value, ¶ms); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_CCTOR(¶ms); - } - } - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getType) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "type"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettotalelapsedmilliseconds", NULL, 0); + zephir_check_call_status(); + RETURN_MM_DOUBLE(zephir_safe_div_zval_long(&_0, 1000)); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedFields) +static PHP_METHOD(Phalcon_Db_Profiler_Item, setFinalTime) { + zval *finalTime_param = NULL, _0; + double finalTime; zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(finalTime) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "referencedFields"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedModel) -{ - zval *this_ptr = getThis(); - + zephir_fetch_params_without_memory_grow(1, 0, &finalTime_param); + finalTime = zephir_get_doubleval(finalTime_param); - RETURN_MEMBER(getThis(), "referencedModel"); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_DOUBLE(&_0, finalTime); + zephir_update_property_zval(this_ptr, ZEND_STRL("finalTime"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, isForeignKey) +static PHP_METHOD(Phalcon_Db_Profiler_Item, setInitialTime) { - zval foreignKey, _0; + zval *initialTime_param = NULL, _0; + double initialTime; zval *this_ptr = getThis(); - ZVAL_UNDEF(&foreignKey); ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(initialTime) + ZEND_PARSE_PARAMETERS_END(); +#endif + zephir_fetch_params_without_memory_grow(1, 0, &initialTime_param); + initialTime = zephir_get_doubleval(initialTime_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&foreignKey, &_0, SL("foreignKey"), 1))) { - RETURN_BOOL(0); - } - RETURN_BOOL(zephir_get_boolval(&foreignKey)); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, isThrough) -{ - zend_bool _1; - zval type, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - - - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&type, &_0); - _1 = ZEPHIR_IS_LONG(&type, 3); - if (!(_1)) { - _1 = ZEPHIR_IS_LONG(&type, 4); - } - RETURN_MM_BOOL(_1); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_DOUBLE(&_0, initialTime); + zephir_update_property_zval(this_ptr, ZEND_STRL("initialTime"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, isReusable) +static PHP_METHOD(Phalcon_Db_Profiler_Item, setSqlBindTypes) { - zval options, reusable, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *sqlBindTypes_param = NULL; + zval sqlBindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&reusable); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&sqlBindTypes); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(sqlBindTypes) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &sqlBindTypes_param); + zephir_get_arrval(&sqlBindTypes, sqlBindTypes_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - if (!(zephir_array_isset_string_fetch(&reusable, &options, SL("reusable"), 1))) { - RETURN_MM_BOOL(0); - } - RETURN_CTOR(&reusable); + + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlBindTypes"), &sqlBindTypes); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Relation, setIntermediateRelation) +static PHP_METHOD(Phalcon_Db_Profiler_Item, setSqlStatement) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval intermediateModel; - zval *intermediateFields, intermediateFields_sub, *intermediateModel_param = NULL, *intermediateReferencedFields, intermediateReferencedFields_sub; + zval *sqlStatement_param = NULL; + zval sqlStatement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&sqlStatement); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateReferencedFields) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sqlStatement) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &intermediateFields, &intermediateModel_param, &intermediateReferencedFields); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); - } else { - ZEPHIR_INIT_VAR(&intermediateModel); - } + zephir_fetch_params(1, 1, 0, &sqlStatement_param); + zephir_get_strval(&sqlStatement, sqlStatement_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateFields"), intermediateFields); - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateModel"), &intermediateModel); - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateReferencedFields"), intermediateReferencedFields); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlStatement"), &sqlStatement); + RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Relation(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Db_Profiler_Item, setSqlVariables) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_RelationInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, RelationInterface, phalcon, mvc_model_relationinterface, phalcon_mvc_model_relationinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getForeignKey); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateModel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateReferencedFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOption); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedModel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isForeignKey); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isReusable); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, setIntermediateRelation); - - + zval *sqlVariables_param = NULL; + zval sqlVariables; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&sqlVariables); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(sqlVariables) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &sqlVariables_param); + zephir_get_arrval(&sqlVariables, sqlVariables_param); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultInterface, phalcon, mvc_model_resultinterface, phalcon_mvc_model_resultinterface_method_entry); - - return SUCCESS; + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlVariables"), &sqlVariables); + RETURN_THIS(); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultInterface, setDirtyState); @@ -80721,1724 +74730,2417 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultInterface, setDirtyState); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset) +ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_AbstractDispatcher) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Resultset, phalcon, mvc_model_resultset, phalcon_mvc_model_resultset_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("activeRow"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("cache"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("count"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("errorMessages"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("hydrateMode"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_resultset_ce, SL("isFresh"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("pointer"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("row"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("rows"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("result"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_resultset_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Resultset; - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_ARRAYS"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_OBJECTS"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_RECORDS"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_FULL"), 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Dispatcher, AbstractDispatcher, phalcon, dispatcher_abstractdispatcher, phalcon_di_abstractinjectionaware_ce, phalcon_dispatcher_abstractdispatcher_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_PARTIAL"), 1); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("activeHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("activeMethodMap"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("actionName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("camelCaseMap"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultNamespace"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultHandler"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerHashes"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerSuffix"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("finished"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("forwarded"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("isControllerInitialize"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("lastHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("modelBinder"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("modelBinding"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("moduleName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("namespaceName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("params"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousActionName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousHandlerName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousNamespaceName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("returnedValue"), ZEND_ACC_PROTECTED); + phalcon_dispatcher_abstractdispatcher_ce->create_object = zephir_init_properties_Phalcon_Dispatcher_AbstractDispatcher; - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, phalcon_mvc_model_resultsetinterface_ce); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_iterator); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, spl_ce_SeekableIterator); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_countable); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_serializable); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, php_json_serializable_ce); + zend_class_implements(phalcon_dispatcher_abstractdispatcher_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); + zend_class_implements(phalcon_dispatcher_abstractdispatcher_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, __construct) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, callActionMethod) { - zend_bool _11, _4$$4; - zval _10, _7$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, prefetchRecords = 0; - zval *result, result_sub, *cache = NULL, cache_sub, __$null, rowCount, rows, _8, _0$$3, _1$$3, _2$$4, _3$$4, _5$$4, _6$$5, _9$$6, _12$$9; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval params, _0; + zval actionMethod; + zval *handler, handler_sub, *actionMethod_param = NULL, *params_param = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&result_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&rowCount); - ZVAL_UNDEF(&rows); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&actionMethod); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(result) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(handler) + Z_PARAM_STR(actionMethod) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(cache) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &result, &cache); - if (!cache) { - cache = &cache_sub; - cache = &__$null; + zephir_fetch_params(1, 2, 1, &handler, &actionMethod_param, ¶ms_param); + zephir_get_strval(&actionMethod, actionMethod_param); + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else { + ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); } - if (Z_TYPE_P(result) != IS_OBJECT) { - ZEPHIR_INIT_ZVAL_NREF(_0$$3); - ZVAL_LONG(&_0$$3, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_1$$3); - RETURN_MM_NULL(); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("result"), result); - if (Z_TYPE_P(cache) != IS_NULL) { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "Phalcon\\Cache\\CacheInterface"); - ZEPHIR_CALL_FUNCTION(&_3$$4, "is_a", NULL, 86, cache, &_2$$4); - zephir_check_call_status(); - _4$$4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_3$$4); - if (_4$$4) { - ZEPHIR_INIT_NVAR(&_2$$4); - ZVAL_STRING(&_2$$4, "Psr\\SimpleCache\\CacheInterface"); - ZEPHIR_CALL_FUNCTION(&_5$$4, "is_a", NULL, 86, cache, &_2$$4); - zephir_check_call_status(); - _4$$4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_5$$4); - } - if (UNEXPECTED(_4$$4)) { - ZEPHIR_INIT_VAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$5); - ZEPHIR_CONCAT_SS(&_7$$5, "Cache service must be an object implementing ", "Phalcon\\Cache\\CacheInterface or Psr\\SimpleCache\\CacheInterface"); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 32, &_7$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$5, "phalcon/Mvc/Model/Resultset.zep", 165); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); - } - ZVAL_LONG(&_8, 2); - ZEPHIR_CALL_METHOD(NULL, result, "setfetchmode", NULL, 0, &_8); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&rowCount, result, "numrows", NULL, 0); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, handler); + zephir_array_fast_append(&_0, &actionMethod); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, ¶ms); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &rowCount); - if (ZEPHIR_IS_LONG(&rowCount, 0)) { - ZEPHIR_INIT_VAR(&_9$$6); - array_init(&_9$$6); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_9$$6); - RETURN_MM_NULL(); - } - ZEPHIR_INIT_VAR(&_10); - ZEPHIR_INIT_NVAR(&_10); - ZVAL_STRING(&_10, "ZEPHIR_GLOBAL(orm).resultset_prefetch_records"); - prefetchRecords = zephir_get_intval_ex(&_10); - _11 = prefetchRecords > 0; - if (_11) { - _11 = ZEPHIR_LE_LONG(&rowCount, prefetchRecords); - } - if (_11) { - ZEPHIR_CALL_METHOD(&rows, result, "fetchall", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&rows) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &rows); - } else { - ZEPHIR_INIT_VAR(&_12$$9); - array_init(&_12$$9); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_12$$9); - } - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, count) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "count"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, delete) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, dispatch) { - zval _4$$6; - zend_bool result = 0, transaction = 0; + zval _44$$10; + zend_bool hasService = 0, hasEventsManager = 0, isNewHandler = 0, _5$$5, _16$$13, _21$$15, _29$$18, _34$$20, _42$$23, _52$$25, _56$$31, _62$$33, _66$$36, _72$$38, _78$$43, _83$$46, _88$$48, _105$$59, _110$$62, _115$$64, _118$$67, _123$$69, _130$$73; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *conditionCallback = NULL, conditionCallback_sub, __$null, record, connection, _0, _3$$6, _6$$3, _7$$8; + zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL, *_15 = NULL, *_20 = NULL, *_23 = NULL, *_25 = NULL, *_28 = NULL, *_30 = NULL, *_33 = NULL, *_35 = NULL, *_41 = NULL, *_43 = NULL, *_47 = NULL, *_51 = NULL, *_55 = NULL, *_58 = NULL, *_61 = NULL, *_64 = NULL, *_68 = NULL, *_71 = NULL, *_74 = NULL, *_77 = NULL, *_82 = NULL, *_87 = NULL, *_94 = NULL, *_100 = NULL, *_104 = NULL, *_109 = NULL, *_114 = NULL, *_122 = NULL, *_126 = NULL, *_129 = NULL; + zval __$true, __$false, value, handler, container, namespaceName, handlerName, actionName, eventsManager, handlerClass, status, actionMethod, modelBinder, bindCacheKey, handlerHash, e, _0, _1$$3, _2$$3, _3$$5, _4$$5, _6$$5, _7$$4, _8$$7, _9$$11, _10$$11, _13$$13, _14$$13, _17$$13, _18$$12, _19$$15, _22$$15, _24$$10, _36$$10, _37$$10, _38$$10, _102$$10, _26$$18, _27$$18, _31$$20, _32$$20, _39$$23, _40$$23, _45$$26, _46$$26, _48$$26, _49$$25, _50$$25, _53$$31, _54$$31, _57$$31, _59$$30, _60$$33, _63$$33, _65$$36, _67$$36, _69$$35, _70$$38, _73$$38, _75$$41, _76$$43, _79$$43, _80$$46, _81$$46, _84$$46, _85$$45, _86$$48, _89$$48, _90$$50, _91$$50, _92$$51, _93$$51, _95$$51, _96$$54, _97$$54, _98$$57, _99$$57, _101$$57, _103$$59, _106$$59, _107$$62, _108$$62, _111$$62, _112$$61, _113$$64, _116$$64, _117$$67, _119$$67, _120$$66, _121$$69, _124$$69, _125$$72, _127$$71, _128$$73, _131$$73, _132$$76, _133$$75, _134$$77; + zend_long ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditionCallback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&connection); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&handlerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&handlerClass); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&actionMethod); + ZVAL_UNDEF(&modelBinder); + ZVAL_UNDEF(&bindCacheKey); + ZVAL_UNDEF(&handlerHash); + ZVAL_UNDEF(&e); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_4$$6); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(conditionCallback, zend_ce_closure) - ZEND_PARSE_PARAMETERS_END(); -#endif - - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &conditionCallback); - if (!conditionCallback) { - conditionCallback = &conditionCallback_sub; - conditionCallback = &__$null; - } - - - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - result = 1; - transaction = 0; - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 91); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - if (transaction == 0) { - if (UNEXPECTED(!((zephir_method_exists_ex(&record, ZEND_STRL("getwriteconnection")) == SUCCESS)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/Mvc/Model/Resultset.zep", 239); - return; - } - ZEPHIR_CALL_METHOD(&connection, &record, "getwriteconnection", NULL, 0); - zephir_check_call_status(); - transaction = 1; - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - } - if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_3$$6); - ZEPHIR_INIT_NVAR(&_4$$6); - zephir_create_array(&_4$$6, 1, 0); - zephir_array_fast_append(&_4$$6, &record); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$6, conditionCallback, &_4$$6); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$6)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$11); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_13$$13); + ZVAL_UNDEF(&_14$$13); + ZVAL_UNDEF(&_17$$13); + ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_24$$10); + ZVAL_UNDEF(&_36$$10); + ZVAL_UNDEF(&_37$$10); + ZVAL_UNDEF(&_38$$10); + ZVAL_UNDEF(&_102$$10); + ZVAL_UNDEF(&_26$$18); + ZVAL_UNDEF(&_27$$18); + ZVAL_UNDEF(&_31$$20); + ZVAL_UNDEF(&_32$$20); + ZVAL_UNDEF(&_39$$23); + ZVAL_UNDEF(&_40$$23); + ZVAL_UNDEF(&_45$$26); + ZVAL_UNDEF(&_46$$26); + ZVAL_UNDEF(&_48$$26); + ZVAL_UNDEF(&_49$$25); + ZVAL_UNDEF(&_50$$25); + ZVAL_UNDEF(&_53$$31); + ZVAL_UNDEF(&_54$$31); + ZVAL_UNDEF(&_57$$31); + ZVAL_UNDEF(&_59$$30); + ZVAL_UNDEF(&_60$$33); + ZVAL_UNDEF(&_63$$33); + ZVAL_UNDEF(&_65$$36); + ZVAL_UNDEF(&_67$$36); + ZVAL_UNDEF(&_69$$35); + ZVAL_UNDEF(&_70$$38); + ZVAL_UNDEF(&_73$$38); + ZVAL_UNDEF(&_75$$41); + ZVAL_UNDEF(&_76$$43); + ZVAL_UNDEF(&_79$$43); + ZVAL_UNDEF(&_80$$46); + ZVAL_UNDEF(&_81$$46); + ZVAL_UNDEF(&_84$$46); + ZVAL_UNDEF(&_85$$45); + ZVAL_UNDEF(&_86$$48); + ZVAL_UNDEF(&_89$$48); + ZVAL_UNDEF(&_90$$50); + ZVAL_UNDEF(&_91$$50); + ZVAL_UNDEF(&_92$$51); + ZVAL_UNDEF(&_93$$51); + ZVAL_UNDEF(&_95$$51); + ZVAL_UNDEF(&_96$$54); + ZVAL_UNDEF(&_97$$54); + ZVAL_UNDEF(&_98$$57); + ZVAL_UNDEF(&_99$$57); + ZVAL_UNDEF(&_101$$57); + ZVAL_UNDEF(&_103$$59); + ZVAL_UNDEF(&_106$$59); + ZVAL_UNDEF(&_107$$62); + ZVAL_UNDEF(&_108$$62); + ZVAL_UNDEF(&_111$$62); + ZVAL_UNDEF(&_112$$61); + ZVAL_UNDEF(&_113$$64); + ZVAL_UNDEF(&_116$$64); + ZVAL_UNDEF(&_117$$67); + ZVAL_UNDEF(&_119$$67); + ZVAL_UNDEF(&_120$$66); + ZVAL_UNDEF(&_121$$69); + ZVAL_UNDEF(&_124$$69); + ZVAL_UNDEF(&_125$$72); + ZVAL_UNDEF(&_127$$71); + ZVAL_UNDEF(&_128$$73); + ZVAL_UNDEF(&_131$$73); + ZVAL_UNDEF(&_132$$76); + ZVAL_UNDEF(&_133$$75); + ZVAL_UNDEF(&_134$$77); + ZVAL_UNDEF(&_44$$10); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "A dependency injection container is required to access related dispatching services"); + ZVAL_LONG(&_2$$3, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$3, &_2$$3); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + hasEventsManager = Z_TYPE_P(&eventsManager) == IS_OBJECT; + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + if (hasEventsManager) { + + /* try_start_1: */ + + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "dispatch:beforeDispatchLoop"); + ZEPHIR_CALL_METHOD(&_3$$5, &eventsManager, "fire", NULL, 0, &_4$$5, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + _5$$5 = ZEPHIR_IS_FALSE_IDENTICAL(&_3$$5); + if (_5$$5) { + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _5$$5 = !ZEPHIR_IS_FALSE_IDENTICAL(&_6$$5); + } + if (_5$$5) { + RETURN_MM_BOOL(0); + } + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_7$$4); + ZVAL_OBJ(&_7$$4, EG(exception)); + Z_ADDREF_P(&_7$$4); + if (zephir_is_instance_of(&_7$$4, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_7$$4); + ZEPHIR_CALL_METHOD(&status, this_ptr, "handleexception", NULL, 0, &e); zephir_check_call_status(); + zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_8$$7)) { + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_MM_BOOL(0); + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 229); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + } + ZEPHIR_INIT_VAR(&value); + ZVAL_NULL(&value); + ZEPHIR_INIT_VAR(&handler); + ZVAL_NULL(&handler); + numberDispatches = 0; + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + while (1) { + zephir_read_property(&_0, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (!(!(zephir_is_true(&_0)))) { + break; + } + numberDispatches++; + if (UNEXPECTED(numberDispatches == 256)) { + ZEPHIR_INIT_NVAR(&_9$$11); + ZVAL_STRING(&_9$$11, "Dispatcher has detected a cyclic routing causing stability problems"); + ZVAL_LONG(&_10$$11, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", &_11, 0, &_9$$11, &_10$$11); + zephir_check_call_status(); + break; + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolveemptyproperties", &_12, 0); + zephir_check_call_status(); + if (hasEventsManager) { + + /* try_start_2: */ + + ZEPHIR_INIT_NVAR(&_14$$13); + ZVAL_STRING(&_14$$13, "dispatch:beforeDispatch"); + ZEPHIR_CALL_METHOD(&_13$$13, &eventsManager, "fire", &_15, 0, &_14$$13, this_ptr); + zephir_check_call_status_or_jump(try_end_2); + _16$$13 = ZEPHIR_IS_FALSE_IDENTICAL(&_13$$13); + if (!(_16$$13)) { + zephir_read_property(&_17$$13, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _16$$13 = ZEPHIR_IS_FALSE_IDENTICAL(&_17$$13); + } + if (_16$$13) { + continue; + } + + try_end_2: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_18$$12); + ZVAL_OBJ(&_18$$12, EG(exception)); + Z_ADDREF_P(&_18$$12); + if (zephir_is_instance_of(&_18$$12, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_18$$12); + ZEPHIR_CALL_METHOD(&_19$$15, this_ptr, "handleexception", &_20, 0, &e); + zephir_check_call_status(); + _21$$15 = ZEPHIR_IS_FALSE_IDENTICAL(&_19$$15); + if (!(_21$$15)) { + zephir_read_property(&_22$$15, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _21$$15 = ZEPHIR_IS_FALSE_IDENTICAL(&_22$$15); + } + if (_21$$15) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 269); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_23, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24$$10, &container, "has", &_25, 0, &handlerClass); + zephir_check_call_status(); + hasService = zephir_get_boolval(&_24$$10); + if (!(hasService)) { + hasService = zephir_class_exists(&handlerClass, 1); + } + if (!(hasService)) { + ZEPHIR_INIT_NVAR(&_26$$18); + ZEPHIR_CONCAT_VS(&_26$$18, &handlerClass, " handler class cannot be loaded"); + ZVAL_LONG(&_27$$18, 2); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_28, 0, &_26$$18, &_27$$18); + zephir_check_call_status(); + _29$$18 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_29$$18) { + zephir_read_property(&_27$$18, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _29$$18 = ZEPHIR_IS_FALSE_IDENTICAL(&_27$$18); + } + if (_29$$18) { continue; } + break; } - ZEPHIR_CALL_METHOD(&_6$$3, &record, "delete", NULL, 0); + ZEPHIR_CALL_METHOD(&handler, &container, "getshared", &_30, 0, &handlerClass); zephir_check_call_status(); - if (!(zephir_is_true(&_6$$3))) { - ZEPHIR_CALL_METHOD(&_7$$8, &record, "getmessages", NULL, 0); + if (UNEXPECTED(Z_TYPE_P(&handler) != IS_OBJECT)) { + ZEPHIR_INIT_NVAR(&_31$$20); + ZVAL_STRING(&_31$$20, "Invalid handler returned from the services container"); + ZVAL_LONG(&_32$$20, 3); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_33, 0, &_31$$20, &_32$$20); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_7$$8); - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); + _34$$20 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_34$$20) { + zephir_read_property(&_32$$20, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _34$$20 = ZEPHIR_IS_FALSE_IDENTICAL(&_32$$20); + } + if (_34$$20) { + continue; + } + break; + } + ZEPHIR_CALL_FUNCTION(&handlerHash, "spl_object_hash", &_35, 80, &handler); + zephir_check_call_status(); + zephir_read_property(&_36$$10, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); + isNewHandler = !((zephir_array_isset(&_36$$10, &handlerHash))); + if (isNewHandler) { + zephir_update_property_array(this_ptr, SL("handlerHashes"), &handlerHash, &__$true); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), &handler); + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&namespaceName, &_37$$10); + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlerName, &_37$$10); + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&actionName, &_37$$10); + ZEPHIR_OBS_NVAR(&_38$$10); + zephir_read_property(&_38$$10, this_ptr, ZEND_STRL("params"), PH_NOISY_CC); + if (UNEXPECTED(Z_TYPE_P(&_38$$10) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_39$$23); + ZVAL_STRING(&_39$$23, "Action parameters must be an Array"); + ZVAL_LONG(&_40$$23, 4); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_41, 0, &_39$$23, &_40$$23); zephir_check_call_status(); - result = 0; - transaction = 0; + _42$$23 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_42$$23) { + zephir_read_property(&_40$$23, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _42$$23 = ZEPHIR_IS_FALSE_IDENTICAL(&_40$$23); + } + if (_42$$23) { + continue; + } break; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + ZEPHIR_CALL_METHOD(&actionMethod, this_ptr, "getactivemethod", &_43, 0); zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_44$$10); + zephir_create_array(&_44$$10, 2, 0); + zephir_array_fast_append(&_44$$10, &handler); + zephir_array_fast_append(&_44$$10, &actionMethod); + if (UNEXPECTED(!(zephir_is_callable(&_44$$10)))) { + if (hasEventsManager) { + ZEPHIR_INIT_NVAR(&_46$$26); + ZVAL_STRING(&_46$$26, "dispatch:beforeNotFoundAction"); + ZEPHIR_CALL_METHOD(&_45$$26, &eventsManager, "fire", &_47, 0, &_46$$26, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_45$$26)) { + continue; + } + zephir_read_property(&_48$$26, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_48$$26)) { + continue; + } + } + ZEPHIR_INIT_NVAR(&_49$$25); + ZEPHIR_CONCAT_SVSVS(&_49$$25, "Action '", &actionName, "' was not found on handler '", &handlerName, "'"); + ZVAL_LONG(&_50$$25, 5); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_51, 0, &_49$$25, &_50$$25); + zephir_check_call_status(); + _52$$25 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_52$$25) { + zephir_read_property(&_50$$25, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _52$$25 = ZEPHIR_IS_FALSE_IDENTICAL(&_50$$25); + } + if (_52$$25) { + continue; + } + break; + } + if (hasEventsManager) { + + /* try_start_3: */ + + ZEPHIR_INIT_NVAR(&_54$$31); + ZVAL_STRING(&_54$$31, "dispatch:beforeExecuteRoute"); + ZEPHIR_CALL_METHOD(&_53$$31, &eventsManager, "fire", &_55, 0, &_54$$31, this_ptr); + zephir_check_call_status_or_jump(try_end_3); + _56$$31 = ZEPHIR_IS_FALSE_IDENTICAL(&_53$$31); + if (!(_56$$31)) { + zephir_read_property(&_57$$31, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _56$$31 = ZEPHIR_IS_FALSE_IDENTICAL(&_57$$31); + } + if (_56$$31) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_58, 0, &handlerClass); + zephir_check_call_status_or_jump(try_end_3); + continue; + } + + try_end_3: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_59$$30); + ZVAL_OBJ(&_59$$30, EG(exception)); + Z_ADDREF_P(&_59$$30); + if (zephir_is_instance_of(&_59$$30, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_59$$30); + ZEPHIR_CALL_METHOD(&_60$$33, this_ptr, "handleexception", &_61, 0, &e); + zephir_check_call_status(); + _62$$33 = ZEPHIR_IS_FALSE_IDENTICAL(&_60$$33); + if (!(_62$$33)) { + zephir_read_property(&_63$$33, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _62$$33 = ZEPHIR_IS_FALSE_IDENTICAL(&_63$$33); + } + if (_62$$33) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_64, 0, &handlerClass); + zephir_check_call_status(); + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 408); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if ((zephir_method_exists_ex(&handler, ZEND_STRL("beforeexecuteroute")) == SUCCESS)) { + + /* try_start_4: */ + + ZEPHIR_CALL_METHOD(&_65$$36, &handler, "beforeexecuteroute", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_4); + _66$$36 = ZEPHIR_IS_FALSE_IDENTICAL(&_65$$36); + if (!(_66$$36)) { + zephir_read_property(&_67$$36, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _66$$36 = ZEPHIR_IS_FALSE_IDENTICAL(&_67$$36); + } + if (_66$$36) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_68, 0, &handlerClass); + zephir_check_call_status_or_jump(try_end_4); + continue; + } + + try_end_4: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_69$$35); + ZVAL_OBJ(&_69$$35, EG(exception)); + Z_ADDREF_P(&_69$$35); + if (zephir_is_instance_of(&_69$$35, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_69$$35); + ZEPHIR_CALL_METHOD(&_70$$38, this_ptr, "handleexception", &_71, 0, &e); + zephir_check_call_status(); + _72$$38 = ZEPHIR_IS_FALSE_IDENTICAL(&_70$$38); + if (!(_72$$38)) { + zephir_read_property(&_73$$38, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _72$$38 = ZEPHIR_IS_FALSE_IDENTICAL(&_73$$38); + } + if (_72$$38) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_74, 0, &handlerClass); + zephir_check_call_status(); + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 427); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if (isNewHandler) { + if ((zephir_method_exists_ex(&handler, ZEND_STRL("initialize")) == SUCCESS)) { + + /* try_start_5: */ + + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); + } + ZEPHIR_CALL_METHOD(NULL, &handler, "initialize", NULL, 0); + zephir_check_call_status_or_jump(try_end_5); + + try_end_5: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_75$$41); + ZVAL_OBJ(&_75$$41, EG(exception)); + Z_ADDREF_P(&_75$$41); + if (zephir_is_instance_of(&_75$$41, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_75$$41); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); + } + ZEPHIR_CALL_METHOD(&_76$$43, this_ptr, "handleexception", &_77, 0, &e); + zephir_check_call_status(); + _78$$43 = ZEPHIR_IS_FALSE_IDENTICAL(&_76$$43); + if (!(_78$$43)) { + zephir_read_property(&_79$$43, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _78$$43 = ZEPHIR_IS_FALSE_IDENTICAL(&_79$$43); + } + if (_78$$43) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 469); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); + } + if (zephir_is_true(&eventsManager)) { + + /* try_start_6: */ + + ZEPHIR_INIT_NVAR(&_81$$46); + ZVAL_STRING(&_81$$46, "dispatch:afterInitialize"); + ZEPHIR_CALL_METHOD(&_80$$46, &eventsManager, "fire", &_82, 0, &_81$$46, this_ptr); + zephir_check_call_status_or_jump(try_end_6); + _83$$46 = ZEPHIR_IS_FALSE_IDENTICAL(&_80$$46); + if (!(_83$$46)) { + zephir_read_property(&_84$$46, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _83$$46 = ZEPHIR_IS_FALSE_IDENTICAL(&_84$$46); + } + if (_83$$46) { + continue; + } + + try_end_6: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_85$$45); + ZVAL_OBJ(&_85$$45, EG(exception)); + Z_ADDREF_P(&_85$$45); + if (zephir_is_instance_of(&_85$$45, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_85$$45); + ZEPHIR_CALL_METHOD(&_86$$48, this_ptr, "handleexception", &_87, 0, &e); + zephir_check_call_status(); + _88$$48 = ZEPHIR_IS_FALSE_IDENTICAL(&_86$$48); + if (!(_88$$48)) { + zephir_read_property(&_89$$48, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _88$$48 = ZEPHIR_IS_FALSE_IDENTICAL(&_89$$48); + } + if (_88$$48) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 488); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + } + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("modelBinding"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_37$$10)) { + zephir_read_property(&_90$$50, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&modelBinder, &_90$$50); + ZEPHIR_INIT_NVAR(&bindCacheKey); + ZEPHIR_CONCAT_SVSV(&bindCacheKey, "_PHMB_", &handlerClass, "_", &actionMethod); + zephir_read_property(&_90$$50, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_91$$50, &modelBinder, "bindtohandler", NULL, 0, &handler, &_90$$50, &bindCacheKey, &actionMethod); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_91$$50); + } + if (hasEventsManager) { + ZEPHIR_INIT_NVAR(&_93$$51); + ZVAL_STRING(&_93$$51, "dispatch:afterBinding"); + ZEPHIR_CALL_METHOD(&_92$$51, &eventsManager, "fire", &_94, 0, &_93$$51, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_92$$51)) { + continue; + } + zephir_read_property(&_95$$51, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_95$$51)) { + continue; + } + } + if ((zephir_method_exists_ex(&handler, ZEND_STRL("afterbinding")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&_96$$54, &handler, "afterbinding", NULL, 0, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_96$$54)) { + continue; + } + zephir_read_property(&_97$$54, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_97$$54)) { + continue; + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("lastHandler"), &handler); + + /* try_start_7: */ + + zephir_read_property(&_99$$57, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_98$$57, this_ptr, "callactionmethod", &_100, 0, &handler, &actionMethod, &_99$$57); + zephir_check_call_status_or_jump(try_end_7); + zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), &_98$$57); + zephir_read_property(&_101$$57, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_101$$57)) { + continue; + } + + try_end_7: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_102$$10); + ZVAL_OBJ(&_102$$10, EG(exception)); + Z_ADDREF_P(&_102$$10); + if (zephir_is_instance_of(&_102$$10, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_102$$10); + ZEPHIR_CALL_METHOD(&_103$$59, this_ptr, "handleexception", &_104, 0, &e); + zephir_check_call_status(); + _105$$59 = ZEPHIR_IS_FALSE_IDENTICAL(&_103$$59); + if (!(_105$$59)) { + zephir_read_property(&_106$$59, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _105$$59 = ZEPHIR_IS_FALSE_IDENTICAL(&_106$$59); + } + if (_105$$59) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 560); + ZEPHIR_MM_RESTORE(); + return; + } + } + if (hasEventsManager) { + + /* try_start_8: */ + + ZEPHIR_INIT_NVAR(&_108$$62); + ZVAL_STRING(&_108$$62, "dispatch:afterExecuteRoute"); + ZEPHIR_CALL_METHOD(&_107$$62, &eventsManager, "fire", &_109, 0, &_108$$62, this_ptr, &value); + zephir_check_call_status_or_jump(try_end_8); + _110$$62 = ZEPHIR_IS_FALSE_IDENTICAL(&_107$$62); + if (!(_110$$62)) { + zephir_read_property(&_111$$62, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _110$$62 = ZEPHIR_IS_FALSE_IDENTICAL(&_111$$62); + } + if (_110$$62) { + continue; + } + + try_end_8: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_112$$61); + ZVAL_OBJ(&_112$$61, EG(exception)); + Z_ADDREF_P(&_112$$61); + if (zephir_is_instance_of(&_112$$61, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_112$$61); + ZEPHIR_CALL_METHOD(&_113$$64, this_ptr, "handleexception", &_114, 0, &e); + zephir_check_call_status(); + _115$$64 = ZEPHIR_IS_FALSE_IDENTICAL(&_113$$64); + if (!(_115$$64)) { + zephir_read_property(&_116$$64, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _115$$64 = ZEPHIR_IS_FALSE_IDENTICAL(&_116$$64); + } + if (_115$$64) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 576); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if ((zephir_method_exists_ex(&handler, ZEND_STRL("afterexecuteroute")) == SUCCESS)) { + + /* try_start_9: */ + + ZEPHIR_CALL_METHOD(&_117$$67, &handler, "afterexecuteroute", NULL, 0, this_ptr, &value); + zephir_check_call_status_or_jump(try_end_9); + _118$$67 = ZEPHIR_IS_FALSE_IDENTICAL(&_117$$67); + if (!(_118$$67)) { + zephir_read_property(&_119$$67, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _118$$67 = ZEPHIR_IS_FALSE_IDENTICAL(&_119$$67); + } + if (_118$$67) { + continue; + } + + try_end_9: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_120$$66); + ZVAL_OBJ(&_120$$66, EG(exception)); + Z_ADDREF_P(&_120$$66); + if (zephir_is_instance_of(&_120$$66, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_120$$66); + ZEPHIR_CALL_METHOD(&_121$$69, this_ptr, "handleexception", &_122, 0, &e); + zephir_check_call_status(); + _123$$69 = ZEPHIR_IS_FALSE_IDENTICAL(&_121$$69); + if (!(_123$$69)) { + zephir_read_property(&_124$$69, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _123$$69 = ZEPHIR_IS_FALSE_IDENTICAL(&_124$$69); + } + if (_123$$69) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 593); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if (hasEventsManager) { + + /* try_start_10: */ + + ZEPHIR_INIT_NVAR(&_125$$72); + ZVAL_STRING(&_125$$72, "dispatch:afterDispatch"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_126, 0, &_125$$72, this_ptr, &value); + zephir_check_call_status_or_jump(try_end_10); + + try_end_10: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_127$$71); + ZVAL_OBJ(&_127$$71, EG(exception)); + Z_ADDREF_P(&_127$$71); + if (zephir_is_instance_of(&_127$$71, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_127$$71); + ZEPHIR_CALL_METHOD(&_128$$73, this_ptr, "handleexception", &_129, 0, &e); + zephir_check_call_status(); + _130$$73 = ZEPHIR_IS_FALSE_IDENTICAL(&_128$$73); + if (!(_130$$73)) { + zephir_read_property(&_131$$73, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _130$$73 = ZEPHIR_IS_FALSE_IDENTICAL(&_131$$73); + } + if (_130$$73) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 610); + ZEPHIR_MM_RESTORE(); + return; + } + } + } } - if (transaction == 1) { - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); + if (hasEventsManager) { + + /* try_start_11: */ + + ZEPHIR_INIT_VAR(&_132$$76); + ZVAL_STRING(&_132$$76, "dispatch:afterDispatchLoop"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_132$$76, this_ptr); + zephir_check_call_status_or_jump(try_end_11); + + try_end_11: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_133$$75); + ZVAL_OBJ(&_133$$75, EG(exception)); + Z_ADDREF_P(&_133$$75); + if (zephir_is_instance_of(&_133$$75, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_133$$75); + ZEPHIR_CALL_METHOD(&_134$$77, this_ptr, "handleexception", NULL, 0, &e); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_134$$77)) { + RETURN_MM_BOOL(0); + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 627); + ZEPHIR_MM_RESTORE(); + return; + } + } } - RETURN_MM_BOOL(result); + RETURN_CCTOR(&handler); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, filter) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, forward) { - zend_bool _4$$3; - zval records, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filter, filter_sub, record, processedRecord, _0; + zval *forward_param = NULL, __$true, __$false, namespaceName, controllerName, params, actionName, taskName, _0, _1, _2, _3; + zval forward; zval *this_ptr = getThis(); - ZVAL_UNDEF(&filter_sub); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&processedRecord); + ZVAL_UNDEF(&forward); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&taskName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(filter) + Z_PARAM_ARRAY(forward) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &filter); + zephir_fetch_params(1, 1, 0, &forward_param); + zephir_get_arrval(&forward, forward_param); - ZEPHIR_INIT_VAR(&records); - array_init(&records); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 91); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3$$3); - zephir_create_array(&_3$$3, 1, 0); - zephir_array_fast_append(&_3$$3, &record); - ZEPHIR_INIT_NVAR(&processedRecord); - ZEPHIR_CALL_USER_FUNC_ARRAY(&processedRecord, filter, &_3$$3); - zephir_check_call_status(); - _4$$3 = Z_TYPE_P(&processedRecord) != IS_OBJECT; - if (_4$$3) { - _4$$3 = Z_TYPE_P(&processedRecord) != IS_ARRAY; - } - if (_4$$3) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - continue; - } - zephir_array_append(&records, &processedRecord, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 333); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("isControllerInitialize"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_dispatcher_exception_ce, "Forwarding inside a controller's initialize() method is forbidden", "phalcon/Dispatcher/AbstractDispatcher.zep", 661); + return; } - RETURN_CTOR(&records); + zephir_read_property(&_1, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("previousNamespaceName"), &_1); + zephir_read_property(&_2, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("previousHandlerName"), &_2); + zephir_read_property(&_3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("previousActionName"), &_3); + if (zephir_array_isset_string_fetch(&namespaceName, &forward, SL("namespace"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &namespaceName); + } + ZEPHIR_OBS_VAR(&taskName); + if (zephir_array_isset_string_fetch(&controllerName, &forward, SL("controller"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &controllerName); + } else if (zephir_array_isset_string_fetch(&taskName, &forward, SL("task"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &taskName); + } + if (zephir_array_isset_string_fetch(&actionName, &forward, SL("action"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); + } + if (zephir_array_isset_string_fetch(¶ms, &forward, SL("params"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); + } + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("forwarded"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("forwarded"), &__$false); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getCache) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActionName) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "cache"); + RETURN_MEMBER(getThis(), "actionName"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getFirst) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActionSuffix) { - zval _0, _1; + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "actionSuffix"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActiveMethod) +{ + zval activeMethodName, _0, _1, _5, _2$$3, _3$$3, _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + ZVAL_UNDEF(&activeMethodName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_LONG(&_0, 0)) { - RETURN_MM_NULL(); + ZEPHIR_OBS_VAR(&activeMethodName); + zephir_read_property(&_0, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&activeMethodName, &_0, &_1, 0))) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "tocamelcase", NULL, 0, &_3$$3); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&activeMethodName, "lcfirst", NULL, 76, &_2$$3); + zephir_check_call_status(); + ZEPHIR_OBS_VAR(&_4$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC); + zephir_update_property_array(this_ptr, SL("activeMethodMap"), &_4$$3, &activeMethodName); } - ZVAL_LONG(&_1, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 92, &_1); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); - zephir_check_call_status(); + zephir_read_property(&_5, this_ptr, ZEND_STRL("actionSuffix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CONCAT_VV(return_value, &activeMethodName, &_5); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getHydrateMode) -{ - zval *this_ptr = getThis(); - - - - RETURN_MEMBER(getThis(), "hydrateMode"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getBoundModels) { - zval count, _0; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&count); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&count, &_0); - if (ZEPHIR_IS_LONG(&count, 0)) { - RETURN_MM_NULL(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + array_init(return_value); + RETURN_MM(); } - ZVAL_LONG(&_0, (zephir_get_numberval(&count) - 1)); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 92, &_0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_1, "getboundmodels", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getMessages) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getDefaultNamespace) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "errorMessages"); + RETURN_MEMBER(getThis(), "defaultNamespace"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getType) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getEventsManager) { - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_OBS_VAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZVAL_LONG(&_0, 0); - } else { - ZVAL_LONG(&_0, 1); - } - RETURN_CCTOR(&_0); + RETURN_MEMBER(getThis(), "eventsManager"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, isFresh) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getHandlerSuffix) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "isFresh"); + RETURN_MEMBER(getThis(), "handlerSuffix"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, jsonSerialize) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getModelBinder) { - zend_bool _3$$3; - zval records; - zval current, _0, _4$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(¤t); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&records); - ZEPHIR_MM_GROW(); - - ZEPHIR_INIT_VAR(&records); - array_init(&records); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 91); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(¤t, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - _3$$3 = Z_TYPE_P(¤t) == IS_OBJECT; - if (_3$$3) { - _3$$3 = (zephir_method_exists_ex(¤t, ZEND_STRL("jsonserialize")) == SUCCESS); - } - if (_3$$3) { - ZEPHIR_CALL_METHOD(&_4$$4, ¤t, "jsonserialize", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&records, &_4$$4, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 458); - } else { - zephir_array_append(&records, ¤t, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 460); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - } - RETURN_CTOR(&records); + RETURN_MEMBER(getThis(), "modelBinder"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, key) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getModuleName) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - RETURN_MM_NULL(); - } - RETURN_MM_MEMBER(getThis(), "pointer"); + RETURN_MEMBER(getThis(), "moduleName"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, next) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getNamespaceName) { - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, (zephir_get_numberval(&_0) + 1)); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 92, &_1); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "namespaceName"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParam) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval index_sub, _0; - zval *index; + zval *param, param_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(param) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &index); - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(ZEPHIR_GE(index, &_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor", "phalcon/Mvc/Model/Resultset.zep", 498); - return; + zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); + if (!filters) { + filters = &filters_sub; + filters = &__$null; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 92, index); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameter", NULL, 0, param, filters, defaultValue); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetExists) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParameter) { - zval *index, index_sub, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *param, param_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null, params, filter, paramValue, _0, _3, _4, _5, _1$$5, _2$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(¶mValue); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(param) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &index); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); + if (!filters) { + filters = &filters_sub; + filters = &__$null; + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(ZEPHIR_LT(index, &_0)); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(¶ms, &_0); + ZEPHIR_OBS_VAR(¶mValue); + if (!(zephir_array_isset_fetch(¶mValue, ¶ms, param, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + if (Z_TYPE_P(filters) == IS_NULL) { + RETURN_CCTOR(¶mValue); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$5); + ZVAL_STRING(&_1$$5, "A dependency injection container is required to access the 'filter' service"); + ZVAL_LONG(&_2$$5, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$5, &_2$$5); + zephir_check_call_status(); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "filter"); + ZEPHIR_CALL_METHOD(&_4, &_3, "getshared", NULL, 0, &_5); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filter, &_4); + ZEPHIR_RETURN_CALL_METHOD(&filter, "sanitize", NULL, 0, ¶mValue, filters); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetSet) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParams) { - zval *index, index_sub, *value, value_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&value_sub); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameters", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParameters) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "params"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, hasParam) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *param, param_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¶m_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(index) - Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(param) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(2, 0, &index, &value); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ¶m); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/Mvc/Model/Resultset.zep", 525); - return; + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasparameter", NULL, 0, param); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetUnset) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, hasParameter) { - zval *offset, offset_sub; + zval *param, param_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) + Z_PARAM_ZVAL(param) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &offset); + zephir_fetch_params_without_memory_grow(1, 0, ¶m); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/Mvc/Model/Resultset.zep", 533); - return; + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, param)); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, rewind) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, isFinished) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 92, &_0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "finished"); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, seek) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setActionName) { - zend_bool _1, _6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_13 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *position, position_sub, __$null, result, row, _0, _2, _3$$3, _5$$3, _7$$3, _9$$3, _11$$3, _4$$4, _8$$6, _10$$7, _12$$8; + zval *actionName_param = NULL; + zval actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&position_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&actionName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(position) + Z_PARAM_STR(actionName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &position); + zephir_fetch_params(1, 1, 0, &actionName_param); + zephir_get_strval(&actionName, actionName_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - _1 = !ZEPHIR_IS_EQUAL(&_0, position); - if (!(_1)) { - zephir_read_property(&_2, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - _1 = Z_TYPE_P(&_2) == IS_NULL; - } - if (_1) { - ZEPHIR_OBS_VAR(&_3$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); - if (Z_TYPE_P(&_3$$3) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&row); - zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&row, &_4$$4, position, 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &row); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$null); - RETURN_MM_NULL(); - } - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("result"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&result, &_5$$3); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - _6$$3 = Z_TYPE_P(&_5$$3) == IS_NULL; - if (_6$$3) { - zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - _6$$3 = ZEPHIR_IS_LONG_IDENTICAL(&_7$$3, 0); - } - if (_6$$3) { - ZEPHIR_CALL_METHOD(&_8$$6, &result, "fetch", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_8$$6); - } - zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_GT(&_9$$3, position)) { - ZEPHIR_CALL_METHOD(NULL, &result, "dataseek", NULL, 0, position); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10$$7, &result, "fetch", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_10$$7); - zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); - } - while (1) { - zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_LT(&_11$$3, position))) { - break; - } - ZEPHIR_CALL_METHOD(&_12$$8, &result, "fetch", &_13, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_12$$8); - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("pointer"))); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$null); - } + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setHydrateMode) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setDefaultAction) { - zval *hydrateMode_param = NULL, _0; - zend_long hydrateMode; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *actionName_param = NULL; + zval actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&actionName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(hydrateMode) + Z_PARAM_STR(actionName) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &hydrateMode_param); - hydrateMode = zephir_get_intval(hydrateMode_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &actionName_param); + zephir_get_strval(&actionName, actionName_param); - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, hydrateMode); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_0); - RETURN_THISW(); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setIsFresh) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setDefaultNamespace) { - zval *isFresh_param = NULL, __$true, __$false; - zend_bool isFresh; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *defaultNamespace_param = NULL; + zval defaultNamespace; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&defaultNamespace); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(isFresh) + Z_PARAM_STR(defaultNamespace) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &isFresh_param); - isFresh = zephir_get_boolval(isFresh_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &defaultNamespace_param); + zephir_get_strval(&defaultNamespace, defaultNamespace_param); - if (isFresh) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isFresh"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isFresh"), &__$false); - } - RETURN_THISW(); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &defaultNamespace); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, update) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getHandlerClass) { - zval _4$$6; - zend_bool transaction = 0; + zval handlerSuffix, handlerName, namespaceName, camelizedClass, handlerClass, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data, data_sub, *conditionCallback = NULL, conditionCallback_sub, __$null, record, connection, _0, _3$$6, _6$$3, _7$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&conditionCallback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&handlerSuffix); + ZVAL_UNDEF(&handlerName); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&camelizedClass); + ZVAL_UNDEF(&handlerClass); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_4$$6); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(data) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(conditionCallback, zend_ce_closure) - ZEND_PARSE_PARAMETERS_END(); -#endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &data, &conditionCallback); - if (!conditionCallback) { - conditionCallback = &conditionCallback_sub; - conditionCallback = &__$null; - } - - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - transaction = 0; - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 91); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolveemptyproperties", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - if (transaction == 0) { - if (UNEXPECTED(!((zephir_method_exists_ex(&record, ZEND_STRL("getwriteconnection")) == SUCCESS)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/Mvc/Model/Resultset.zep", 650); - return; - } - ZEPHIR_CALL_METHOD(&connection, &record, "getwriteconnection", NULL, 0); - zephir_check_call_status(); - transaction = 1; - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - } - if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_3$$6); - ZEPHIR_INIT_NVAR(&_4$$6); - zephir_create_array(&_4$$6, 1, 0); - zephir_array_fast_append(&_4$$6, &record); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$6, conditionCallback, &_4$$6); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$6)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - continue; - } - } - ZEPHIR_CALL_METHOD(NULL, &record, "assign", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$3, &record, "save", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_6$$3))) { - ZEPHIR_CALL_METHOD(&_7$$8, &record, "getmessages", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_7$$8); - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - transaction = 0; - break; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("handlerSuffix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlerSuffix, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlerName, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&namespaceName, &_0); + if (!(zephir_memnstr_str(&handlerName, SL("\\"), "phalcon/Dispatcher/AbstractDispatcher.zep", 938))) { + ZEPHIR_CALL_METHOD(&camelizedClass, this_ptr, "tocamelcase", NULL, 0, &handlerName); zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&camelizedClass, &handlerName); } - if (transaction == 1) { - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&handlerClass); + if (zephir_is_true(&namespaceName)) { + if (!(zephir_end_with_str(&namespaceName, SL("\\")))) { + zephir_concat_self_str(&namespaceName, SL("\\")); + } + ZEPHIR_CONCAT_VVV(&handlerClass, &namespaceName, &camelizedClass, &handlerSuffix); + } else { + ZEPHIR_CONCAT_VV(&handlerClass, &camelizedClass, &handlerSuffix); } - RETURN_MM_BOOL(transaction); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, valid) -{ - zval _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - - - zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(ZEPHIR_LT(&_0, &_1)); + RETURN_CCTOR(&handlerClass); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Resultset(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParam) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errorMessages"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *param, param_sub, *value, value_sub; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&value_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(param) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, ¶m, &value); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultsetInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultsetInterface, phalcon, mvc_model_resultsetinterface, phalcon_mvc_model_resultsetinterface_method_entry); - - return SUCCESS; + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setparameter", NULL, 0, param, value); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, filter); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getCache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getFirst); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getHydrateMode); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getLast); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, isFresh); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setHydrateMode); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setIsFresh); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, toArray); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, update); - - +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParameter) +{ + zval *param, param_sub, *value, value_sub; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&value_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(param) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); #endif + zephir_fetch_params_without_memory_grow(2, 0, ¶m, &value); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Row) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Row, phalcon, mvc_model_row, zend_standard_class_def, phalcon_mvc_model_row_method_entry, 0); - - zend_class_implements(phalcon_mvc_model_row_ce, 1, phalcon_mvc_entityinterface_ce); - zend_class_implements(phalcon_mvc_model_row_ce, 1, phalcon_mvc_model_resultinterface_ce); - zend_class_implements(phalcon_mvc_model_row_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_mvc_model_row_ce, 1, php_json_serializable_ce); - return SUCCESS; + zephir_update_property_array(this_ptr, SL("params"), param, value); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, jsonSerialize) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParams) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *params_param = NULL; + zval params; zval *this_ptr = getThis(); + ZVAL_UNDEF(¶ms); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(params) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ¶ms_param); + zephir_get_arrval(¶ms, params_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setparameters", NULL, 0, ¶ms); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetGet) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParameters) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval index_sub, _0, _1; - zval *index; + zval *params_param = NULL; + zval params; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(¶ms); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &index); + zephir_fetch_params(1, 1, 0, ¶ms_param); + zephir_get_arrval(¶ms, params_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "offsetexists", NULL, 0, index); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the row", "phalcon/Mvc/Model/Row.zep", 42); - return; - } - ZEPHIR_OBS_VAR(&_1); - zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); - RETURN_CCTOR(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetExists) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setReturnedValue) { - zval index_sub; - zval *index; + zval *value, value_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&value_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &index); + zephir_fetch_params_without_memory_grow(1, 0, &value); - RETURN_BOOL(zephir_isset_property_zval(this_ptr, index)); + zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), value); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetSet) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setActionSuffix) { - zval index_sub, value_sub; - zval *index, *value; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *actionSuffix_param = NULL; + zval actionSuffix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&actionSuffix); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(index) - Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(actionSuffix) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(2, 0, &index, &value); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &actionSuffix_param); + zephir_get_strval(&actionSuffix, actionSuffix_param); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/Mvc/Model/Row.zep", 66); - return; + zephir_update_property_zval(this_ptr, ZEND_STRL("actionSuffix"), &actionSuffix); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetUnset) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setEventsManager) { - zval offset_sub; - zval *offset; + zval *eventsManager, eventsManager_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&eventsManager_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &offset); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/Mvc/Model/Row.zep", 76); - return; + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, readAttribute) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setHandlerSuffix) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, value; - zval attribute; + zval *handlerSuffix_param = NULL; + zval handlerSuffix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&handlerSuffix); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(attribute) + Z_PARAM_STR(handlerSuffix) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &attribute_param); - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - } + zephir_fetch_params(1, 1, 0, &handlerSuffix_param); + zephir_get_strval(&handlerSuffix, handlerSuffix_param); - ZEPHIR_OBS_VAR(&value); - if (!(zephir_fetch_property_zval(&value, this_ptr, &attribute, PH_SILENT_CC))) { - RETURN_MM_NULL(); - } - RETURN_CTOR(&value); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &handlerSuffix); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, setDirtyState) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setModelBinder) { - zval *dirtyState_param = NULL; - zend_long dirtyState; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelBinder, modelBinder_sub, *cache = NULL, cache_sub, __$true, __$false, __$null, container, _0$$3, _1$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&modelBinder_sub); + ZVAL_UNDEF(&cache_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(dirtyState) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(modelBinder, phalcon_mvc_model_binderinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(cache) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &dirtyState_param); - dirtyState = zephir_get_intval(dirtyState_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &modelBinder, &cache); + if (!cache) { + cache = &cache_sub; + ZEPHIR_CPY_WRT(cache, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(cache); + } - RETURN_BOOL(0); + if (Z_TYPE_P(cache) == IS_STRING) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0$$3); + ZEPHIR_CALL_METHOD(&_1$$3, &container, "get", NULL, 0, cache); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(cache, &_1$$3); + } + if (Z_TYPE_P(cache) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, modelBinder, "setcache", NULL, 0, cache); + zephir_check_call_status(); + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinding"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinding"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinder"), modelBinder); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, toArray) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setModuleName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *moduleName_param = NULL; + zval moduleName; zval *this_ptr = getThis(); + ZVAL_UNDEF(&moduleName); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(moduleName) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &moduleName_param); + if (!moduleName_param) { + ZEPHIR_INIT_VAR(&moduleName); + } else { + zephir_get_strval(&moduleName, moduleName_param); + } - ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 428, this_ptr); - zephir_check_call_status(); - RETURN_MM(); + + zephir_update_property_zval(this_ptr, ZEND_STRL("moduleName"), &moduleName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Row, writeAttribute) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setNamespaceName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub; - zval attribute; + zval *namespaceName_param = NULL; + zval namespaceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&namespaceName); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(attribute) - Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(namespaceName) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - } + zephir_fetch_params(1, 1, 0, &namespaceName_param); + zephir_get_strval(&namespaceName, namespaceName_param); - zephir_update_property_zval_zval(this_ptr, &attribute, value); + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &namespaceName); ZEPHIR_MM_RESTORE(); } +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getReturnedValue) +{ + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "returnedValue"); +} +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, wasForwarded) +{ + zval *this_ptr = getThis(); + RETURN_MEMBER(getThis(), "forwarded"); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, resolveEmptyProperties) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Transaction, phalcon, mvc_model_transaction, phalcon_mvc_model_transaction_method_entry, 0); + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zval *this_ptr = getThis(); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("activeTransaction"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("connection"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("isNewTransaction"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("manager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("rollbackRecord"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("rollbackOnAbort"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("rollbackThrowException"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_model_transaction_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Transaction; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); - zend_class_implements(phalcon_mvc_model_transaction_ce, 1, phalcon_mvc_model_transactioninterface_ce); - return SUCCESS; + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &_1$$3); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_2))) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("defaultHandler"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &_3$$4); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_4))) { + zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &_5$$5); + } } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, __construct) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, toCamelCase) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval service; - zend_bool autoBegin; - zval *container, container_sub, *autoBegin_param = NULL, *service_param = NULL, connection, _0; + zval *input_param = NULL, camelCaseInput, _0, _1$$3, _2$$3, _3$$3; + zval input; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&camelCaseInput); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(autoBegin) - Z_PARAM_STR(service) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &container, &autoBegin_param, &service_param); - if (!autoBegin_param) { - autoBegin = 0; - } else { - autoBegin = zephir_get_boolval(autoBegin_param); - } - if (!service_param) { - ZEPHIR_INIT_VAR(&service); - ZVAL_STRING(&service, "db"); - } else { - zephir_get_strval(&service, service_param); - } + zephir_fetch_params(1, 1, 0, &input_param); + zephir_get_strval(&input, input_param); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_0); - ZEPHIR_CALL_METHOD(&connection, container, "get", NULL, 0, &service); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("connection"), &connection); - if (autoBegin) { - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); + ZEPHIR_OBS_VAR(&camelCaseInput); + zephir_read_property(&_0, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&camelCaseInput, &_0, &input, 0))) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "/[_-]+/"); + ZEPHIR_CALL_FUNCTION(&_2$$3, "preg_split", NULL, 70, &_1$$3, &input); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1$$3); + ZVAL_STRING(&_1$$3, "ucfirst"); + ZEPHIR_CALL_FUNCTION(&_3$$3, "array_map", NULL, 69, &_1$$3, &_2$$3); zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&camelCaseInput); + zephir_fast_join_str(&camelCaseInput, SL(""), &_3$$3); + zephir_update_property_array(this_ptr, SL("camelCaseMap"), &input, &camelCaseInput); } - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&camelCaseInput); } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, begin) +zend_object *zephir_init_properties_Phalcon_Dispatcher_AbstractDispatcher(zend_class_entry *class_type) { - zval _0; + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + - ZVAL_UNDEF(&_0); + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlerHashes"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("camelCaseMap"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("activeMethodMap"), &_7$$6); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "begin", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, commit) -{ - zval manager, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&_0); - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - if (Z_TYPE_P(&manager) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &manager, "notifycommit", NULL, 0, this_ptr); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "commit", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getConnection) +ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_DispatcherInterface) { - zval _0, _1$$3, _2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Dispatcher, DispatcherInterface, phalcon, dispatcher_dispatcherinterface, phalcon_dispatcher_dispatcherinterface_method_entry); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); + return SUCCESS; +} +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, dispatch); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, forward); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getActionName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getActionSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getHandlerSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParam); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParameter); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParams); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParameters); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getReturnedValue); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, hasParam); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, isFinished); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setActionName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setActionSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setDefaultAction); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setDefaultNamespace); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setHandlerSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setModuleName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setNamespaceName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParam); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParams); - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("rollbackOnAbort"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_FUNCTION(&_1$$3, "connection_aborted", NULL, 482); - zephir_check_call_status(); - if (zephir_is_true(&_1$$3)) { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "The request was aborted"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0, &_2$$4); - zephir_check_call_status(); - } - } - RETURN_MM_MEMBER(getThis(), "connection"); -} -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getMessages) -{ - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "messages"); -} -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isManaged) + +ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_Exception) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Dispatcher, Exception, phalcon, dispatcher_exception, zend_ce_exception, NULL, 0); - ZVAL_UNDEF(&_0); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_ACTION_NOT_FOUND"), 5); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_CYCLIC_ROUTING"), 1); - ZEPHIR_MM_GROW(); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_HANDLER_NOT_FOUND"), 2); - ZEPHIR_OBS_VAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC); - RETURN_MM_BOOL(Z_TYPE_P(&_0) == IS_OBJECT); -} + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_INVALID_HANDLER"), 3); -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isValid) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_INVALID_PARAMS"), 4); - ZVAL_UNDEF(&_0); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_NO_DI"), 0); + return SUCCESS; +} - ZEPHIR_MM_GROW(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "isundertransaction", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, rollback) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *rollbackMessage_param = NULL, *rollbackRecord = NULL, rollbackRecord_sub, __$null, manager, connection, _0, _1, _2$$4, _3$$7, _4$$7; - zval rollbackMessage; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&rollbackMessage); - ZVAL_UNDEF(&rollbackRecord_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(rollbackMessage) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(rollbackRecord, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_AbstractLogger) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, AbstractLogger, phalcon, logger_abstractlogger, phalcon_logger_abstractlogger_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("adapters"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("excluded"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_logger_abstractlogger_ce, SL("logLevel"), 8, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_abstractlogger_ce, SL("name"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("timezone"), ZEND_ACC_PROTECTED); + phalcon_logger_abstractlogger_ce->create_object = zephir_init_properties_Phalcon_Logger_AbstractLogger; + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("ALERT"), 2); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("CRITICAL"), 1); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("CUSTOM"), 8); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("DEBUG"), 7); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("EMERGENCY"), 0); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("ERROR"), 3); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("INFO"), 6); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("NOTICE"), 5); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("WARNING"), 4); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_AbstractLogger, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval adapters; + zval *name_param = NULL, *adapters_param = NULL, *timezone = NULL, timezone_sub, __$null, defaultTimezone; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&timezone_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&defaultTimezone); + ZVAL_UNDEF(&adapters); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(adapters) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone, php_date_get_timezone_ce()) + ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, &rollbackMessage_param, &rollbackRecord); - if (!rollbackMessage_param) { - ZEPHIR_INIT_VAR(&rollbackMessage); + zephir_fetch_params(1, 1, 2, &name_param, &adapters_param, &timezone); + zephir_get_strval(&name, name_param); + if (!adapters_param) { + ZEPHIR_INIT_VAR(&adapters); + array_init(&adapters); } else { - zephir_get_strval(&rollbackMessage, rollbackMessage_param); + zephir_get_arrval(&adapters, adapters_param); } - if (!rollbackRecord) { - rollbackRecord = &rollbackRecord_sub; - rollbackRecord = &__$null; + if (!timezone) { + timezone = &timezone_sub; + ZEPHIR_CPY_WRT(timezone, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(timezone); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - if (Z_TYPE_P(&manager) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &manager, "notifyrollback", NULL, 0, this_ptr); + if (Z_TYPE_P(timezone) == IS_NULL) { + ZEPHIR_CALL_FUNCTION(&defaultTimezone, "date_default_timezone_get", NULL, 96); zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&connection, &_0); - ZEPHIR_CALL_METHOD(&_1, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(zephir_is_true(&_1))) { - if (!(!(ZEPHIR_IS_EMPTY(&rollbackMessage)))) { - ZEPHIR_INIT_NVAR(&rollbackMessage); - ZVAL_STRING(&rollbackMessage, "Transaction aborted"); - } - if (Z_TYPE_P(rollbackRecord) == IS_OBJECT) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackRecord"), rollbackRecord); - } - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("rollbackThrowException"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_2$$4)) { - ZEPHIR_INIT_VAR(&_3$$7); - object_init_ex(&_3$$7, phalcon_mvc_model_transaction_failed_ce); - zephir_read_property(&_4$$7, this_ptr, ZEND_STRL("rollbackRecord"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 483, &rollbackMessage, &_4$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model/Transaction.zep", 215); - ZEPHIR_MM_RESTORE(); - return; + if (UNEXPECTED(1 == ZEPHIR_IS_EMPTY(&defaultTimezone))) { + ZEPHIR_INIT_NVAR(&defaultTimezone); + ZVAL_STRING(&defaultTimezone, "UTC"); } + ZEPHIR_INIT_NVAR(timezone); + object_init_ex(timezone, php_date_get_timezone_ce()); + ZEPHIR_CALL_METHOD(NULL, timezone, "__construct", NULL, 0, &defaultTimezone); + zephir_check_call_status(); } - RETURN_MM_BOOL(1); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("timezone"), timezone); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setadapters", NULL, 0, &adapters); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setIsNewTransaction) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, addAdapter) { - zval *isNew_param = NULL, __$true, __$false; - zend_bool isNew; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, *adapter, adapter_sub; + zval name; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&adapter_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(isNew) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_OBJECT_OF_CLASS(adapter, phalcon_logger_adapter_adapterinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &isNew_param); - isNew = zephir_get_boolval(isNew_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &adapter); + zephir_get_strval(&name, name_param); - if (isNew) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isNewTransaction"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isNewTransaction"), &__$false); - } + zephir_update_property_array(this_ptr, SL("adapters"), &name, adapter); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackOnAbort) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, excludeAdapters) { - zval *rollbackOnAbort_param = NULL, __$true, __$false; - zend_bool rollbackOnAbort; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *adapters_param = NULL, __$true, adapter, registered, *_0, _1; + zval adapters; zval *this_ptr = getThis(); + ZVAL_UNDEF(&adapters); ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&adapter); + ZVAL_UNDEF(®istered); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(rollbackOnAbort) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(adapters) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &rollbackOnAbort_param); - rollbackOnAbort = zephir_get_boolval(rollbackOnAbort_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &adapters_param); + if (!adapters_param) { + ZEPHIR_INIT_VAR(&adapters); + array_init(&adapters); + } else { + zephir_get_arrval(&adapters, adapters_param); + } - if (rollbackOnAbort) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackOnAbort"), &__$true); + zephir_read_property(®istered, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&adapters, 0, "phalcon/Logger/AbstractLogger.zep", 153); + if (Z_TYPE_P(&adapters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&adapters), _0) + { + ZEPHIR_INIT_NVAR(&adapter); + ZVAL_COPY(&adapter, _0); + if (1 == zephir_array_isset(®istered, &adapter)) { + zephir_update_property_array(this_ptr, SL("excluded"), &adapter, &__$true); + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackOnAbort"), &__$false); + ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &adapters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&adapter, &adapters, "current", NULL, 0); + zephir_check_call_status(); + if (1 == zephir_array_isset(®istered, &adapter)) { + zephir_update_property_array(this_ptr, SL("excluded"), &adapter, &__$true); + } + ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&adapter); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackedRecord) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getAdapter) { - zval *record, record_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _0, _1, _2; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &record); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackRecord"), record); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &name)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter does not exist for this logger", "phalcon/Logger/AbstractLogger.zep", 169); + return; + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2, &_1, &name, PH_NOISY | PH_READONLY, "phalcon/Logger/AbstractLogger.zep", 172); + RETURN_CTOR(&_2); } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setTransactionManager) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getAdapters) { - zval *manager, manager_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&manager_sub); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_transaction_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif - zephir_fetch_params_without_memory_grow(1, 0, &manager); + RETURN_MEMBER(getThis(), "adapters"); +} + +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLogLevel) +{ + zval *this_ptr = getThis(); - zephir_update_property_zval(this_ptr, ZEND_STRL("manager"), manager); + + RETURN_MEMBER(getThis(), "logLevel"); } -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, throwRollbackException) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getName) { - zval *status_param = NULL, __$true, __$false; - zend_bool status; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + + + RETURN_MEMBER(getThis(), "name"); +} + +static PHP_METHOD(Phalcon_Logger_AbstractLogger, removeAdapter) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _0, _1; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(status) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &status_param); - status = zephir_get_boolval(status_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); - if (status) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackThrowException"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackThrowException"), &__$false); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &name)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter does not exist for this logger", "phalcon/Logger/AbstractLogger.zep", 214); + return; } - RETURN_THISW(); + zephir_unset_property_array(this_ptr, ZEND_STRL("adapters"), &name); + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_1, &name, PH_SEPARATE); + RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Transaction(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, setAdapters) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - + zval *adapters_param = NULL; + zval adapters; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&adapters); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(adapters) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &adapters_param); + zephir_get_arrval(&adapters, adapters_param); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_TransactionInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, TransactionInterface, phalcon, mvc_model_transactioninterface, phalcon_mvc_model_transactioninterface_method_entry); - - return SUCCESS; + zephir_update_property_zval(this_ptr, ZEND_STRL("adapters"), &adapters); + RETURN_THIS(); } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, begin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, commit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isManaged); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isValid); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, rollback); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setIsNewTransaction); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackOnAbort); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackedRecord); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setTransactionManager); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, throwRollbackException); - - +static PHP_METHOD(Phalcon_Logger_AbstractLogger, setLogLevel) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *level_param = NULL, levels, _0; + zend_long level, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&levels); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(level) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &level_param); + level = zephir_get_intval(level_param); - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ValidationFailed) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, ValidationFailed, phalcon, mvc_model_validationfailed, phalcon_mvc_model_exception_ce, phalcon_mvc_model_validationfailed_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("model"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_validationfailed_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed; - - return SUCCESS; + ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + if (1 == zephir_array_isset_long(&levels, level)) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, level); + } else { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 8); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, __construct) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, addMessage) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval validationMessages; - zval *model, model_sub, *validationMessages_param = NULL, messageStr, message; + zval context; + zval message; + zval *level_param = NULL, *message_param = NULL, *context_param = NULL, adapter, collection, item, levelName, levels, method, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, *_7$$3, _8$$3, _9$$5, _10$$7; + zend_long level, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&messageStr); + ZVAL_UNDEF(&adapter); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&levelName); + ZVAL_UNDEF(&levels); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$7); ZVAL_UNDEF(&message); - ZVAL_UNDEF(&validationMessages); + ZVAL_UNDEF(&context); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(validationMessages) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_LONG(level) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &validationMessages_param); - ZEPHIR_OBS_COPY_OR_DUP(&validationMessages, validationMessages_param); + zephir_fetch_params(1, 2, 1, &level_param, &message_param, &context_param); + level = zephir_get_intval(level_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } - if (zephir_fast_count_int(&validationMessages) > 0) { - ZEPHIR_OBS_VAR(&message); - zephir_array_fetch_long(&message, &validationMessages, 0, PH_NOISY, "phalcon/Mvc/Model/ValidationFailed.zep", 48); - ZEPHIR_CALL_METHOD(&messageStr, &message, "getmessage", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("logLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GE_LONG(&_0, level)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (zephir_fast_count_int(&_1$$3) == 0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "No adapters specified", "phalcon/Logger/AbstractLogger.zep", 273); + return; + } + ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&messageStr); - ZVAL_STRING(&messageStr, "Validation failed"); + if (1 == zephir_array_isset_long(&levels, level)) { + ZEPHIR_OBS_VAR(&levelName); + zephir_array_fetch_long(&levelName, &levels, level, PH_NOISY, "phalcon/Logger/AbstractLogger.zep", 277); + } else { + ZEPHIR_OBS_NVAR(&levelName); + zephir_array_fetch_long(&levelName, &levels, 8, PH_NOISY, "phalcon/Logger/AbstractLogger.zep", 277); + } + ZEPHIR_INIT_VAR(&item); + object_init_ex(&item, phalcon_logger_item_ce); + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, php_date_get_immutable_ce()); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("timezone"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "now"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &_4$$3, &_3$$3); + zephir_check_call_status(); + ZVAL_LONG(&_5$$3, level); + ZEPHIR_CALL_METHOD(NULL, &item, "__construct", NULL, 97, &message, &levelName, &_5$$3, &_2$$3, &context); + zephir_check_call_status(); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("excluded"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&collection, "array_diff_key", NULL, 98, &_5$$3, &_6$$3); + zephir_check_call_status(); + zephir_is_iterable(&collection, 0, "phalcon/Logger/AbstractLogger.zep", 303); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _7$$3) + { + ZEPHIR_INIT_NVAR(&adapter); + ZVAL_COPY(&adapter, _7$$3); + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "process"); + ZEPHIR_CALL_METHOD(&_9$$5, &adapter, "intransaction", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_9$$5)) { + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "add"); + } + ZEPHIR_CALL_METHOD_ZVAL(NULL, &adapter, &method, NULL, 0, &item); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8$$3, &collection, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&adapter, &collection, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "process"); + ZEPHIR_CALL_METHOD(&_10$$7, &adapter, "intransaction", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_10$$7)) { + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "add"); + } + ZEPHIR_CALL_METHOD_ZVAL(NULL, &adapter, &method, NULL, 0, &item); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&adapter); + ZEPHIR_INIT_NVAR(&_4$$3); + array_init(&_4$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("excluded"), &_4$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &validationMessages); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_validationfailed_ce, getThis(), "__construct", NULL, 0, &messageStr); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getMessages) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLevelNumber) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *level, level_sub, levelName, levels, _0$$3, _1$$4; zval *this_ptr = getThis(); + ZVAL_UNDEF(&level_sub); + ZVAL_UNDEF(&levelName); + ZVAL_UNDEF(&levels); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(level) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &level); - RETURN_MEMBER(getThis(), "messages"); + if (Z_TYPE_P(level) == IS_STRING) { + ZEPHIR_INIT_VAR(&levelName); + zephir_fast_strtoupper(&levelName, level); + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getlevels", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&levels, "array_flip", NULL, 99, &_0$$3); + zephir_check_call_status(); + if (zephir_array_isset(&levels, &levelName)) { + zephir_array_fetch(&_1$$4, &levels, &levelName, PH_NOISY | PH_READONLY, "phalcon/Logger/AbstractLogger.zep", 328); + RETURN_CTOR(&_1$$4); + } + } else if (1 == zephir_is_numeric(level)) { + ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); + zephir_check_call_status(); + if (zephir_array_isset(&levels, level)) { + RETURN_MM_LONG(zephir_get_intval(level)); + } + } + RETURN_MM_LONG(8); } -static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getModel) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLevels) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "model"); + zephir_create_array(return_value, 9, 0); + add_index_stringl(return_value, 2, SL("ALERT")); + add_index_stringl(return_value, 1, SL("CRITICAL")); + add_index_stringl(return_value, 7, SL("DEBUG")); + add_index_stringl(return_value, 0, SL("EMERGENCY")); + add_index_stringl(return_value, 3, SL("ERROR")); + add_index_stringl(return_value, 6, SL("INFO")); + add_index_stringl(return_value, 5, SL("NOTICE")); + add_index_stringl(return_value, 4, SL("WARNING")); + add_index_stringl(return_value, 8, SL("CUSTOM")); + return; } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Logger_AbstractLogger(zend_class_entry *class_type) { - zval _0, _1$$3; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); ZEPHIR_MM_GROW(); @@ -82446,11 +77148,17 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed(zend_clas { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("excluded"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("excluded"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("adapters"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -82467,303 +77175,165 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed(zend_clas -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_SoftDelete) +ZEPHIR_INIT_CLASS(Phalcon_Logger_AdapterFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, SoftDelete, phalcon, mvc_model_behavior_softdelete, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_softdelete_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, AdapterFactory, phalcon, logger_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_logger_adapterfactory_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior_SoftDelete, notify) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, __construct) { - zend_bool _9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *model, model_sub, options, value, field, updateModel, message, modelsManager, metaData, _0, _1, _2, _8, _3$$7, *_4$$7, _5$$7, _10$$10, _11$$10; - zval type; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&updateModel); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&modelsManager); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&services); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &type_param, &model); - if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { - zephir_get_strval(&type, type_param); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); } else { - ZEPHIR_INIT_VAR(&type); + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); } - if (!ZEPHIR_IS_STRING_IDENTICAL(&type, "beforeDelete")) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&value); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &options, SL("value"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'value' is required", "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 42); - return; - } - ZEPHIR_OBS_VAR(&field); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 49); - return; - } - ZVAL_BOOL(&_0, 1); - ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, &field); - zephir_check_call_status(); - if (ZEPHIR_IS_IDENTICAL(&_1, &value)) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&modelsManager, model, "getmodelsmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&updateModel); - if (zephir_clone(&updateModel, model) == FAILURE) { - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &updateModel, "writeattribute", NULL, 0, &field, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &updateModel, "save", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_2))) { - ZEPHIR_CALL_METHOD(&_3$$7, &updateModel, "getmessages", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_3$$7, 0, "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 84); - if (Z_TYPE_P(&_3$$7) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3$$7), _4$$7) - { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _4$$7); - ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_6, 0, &message); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$7, &_3$$7, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&message, &_3$$7, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&message); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8, &modelsManager, "iskeepingsnapshots", NULL, 0, model); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); zephir_check_call_status(); - _9 = zephir_is_true(&_8); - if (_9) { - _9 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; - } - if (_9) { - ZEPHIR_CALL_METHOD(&metaData, model, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10$$10, &updateModel, "getsnapshotdata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "setsnapshotdata", NULL, 0, &_10$$10); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_11$$10, &updateModel, "getoldsnapshotdata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "setoldsnapshotdata", NULL, 0, &_11$$10); - zephir_check_call_status(); - } ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_Timestampable) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, Timestampable, phalcon, mvc_model_behavior_timestampable, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_timestampable_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, notify) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, newInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *model, model_sub, options, timestamp, singleField, field, _0, *_1$$6, _2$$6; - zval type; + zval options, _0; + zval *name_param = NULL, *fileName_param = NULL, *options_param = NULL, definition; + zval name, fileName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&fileName); + ZVAL_UNDEF(&definition); ZVAL_UNDEF(&options); - ZVAL_UNDEF(×tamp); - ZVAL_UNDEF(&singleField); - ZVAL_UNDEF(&field); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(name) + Z_PARAM_STR(fileName) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &type_param, &model); - if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + zephir_fetch_params(1, 2, 1, &name_param, &fileName_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { - zephir_get_strval(&type, type_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&type); - } - - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "musttakeaction", NULL, 0, &type); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0, &type); - zephir_check_call_status(); - if (Z_TYPE_P(&options) != IS_ARRAY) { + if (UNEXPECTED(Z_TYPE_P(fileName_param) != IS_STRING && Z_TYPE_P(fileName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fileName' must be of the type string")); RETURN_MM_NULL(); } - ZEPHIR_OBS_VAR(&field); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/Mvc/Model/Behavior/Timestampable.zep", 50); - return; + if (EXPECTED(Z_TYPE_P(fileName_param) == IS_STRING)) { + zephir_get_strval(&fileName, fileName_param); + } else { + ZEPHIR_INIT_VAR(&fileName); } - ZEPHIR_CALL_METHOD(×tamp, this_ptr, "gettimestamp", NULL, 436, &options); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&field) == IS_ARRAY)) { - zephir_is_iterable(&field, 0, "phalcon/Mvc/Model/Behavior/Timestampable.zep", 63); - if (Z_TYPE_P(&field) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _1$$6) - { - ZEPHIR_INIT_NVAR(&singleField); - ZVAL_COPY(&singleField, _1$$6); - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_3, 0, &singleField, ×tamp); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$6, &field, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, &singleField, ×tamp); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&singleField); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, ×tamp); - zephir_check_call_status(); + zephir_get_arrval(&options, options_param); } - ZEPHIR_MM_RESTORE(); + + + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, &fileName); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, getTimestamp) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, getExceptionClass) { - zend_bool _0$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *options_param = NULL, format, generator; - zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&format); - ZVAL_UNDEF(&generator); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); + + + RETURN_STRING("Phalcon\\Logger\\Exception"); +} + +static PHP_METHOD(Phalcon_Logger_AdapterFactory, getServices) +{ + zval *this_ptr = getThis(); + + + + zephir_create_array(return_value, 3, 0); + add_assoc_stringl_ex(return_value, SL("noop"), SL("Phalcon\\Logger\\Adapter\\Noop")); + add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Logger\\Adapter\\Stream")); + add_assoc_stringl_ex(return_value, SL("syslog"), SL("Phalcon\\Logger\\Adapter\\Syslog")); + return; +} + + + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &options_param); - zephir_get_arrval(&options, options_param); - ZEPHIR_OBS_VAR(&format); - if (zephir_array_isset_string_fetch(&format, &options, SL("format"), 0)) { - ZEPHIR_RETURN_CALL_FUNCTION("date", NULL, 437, &format); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_OBS_VAR(&generator); - if (zephir_array_isset_string_fetch(&generator, &options, SL("generator"), 0)) { - _0$$4 = Z_TYPE_P(&generator) == IS_OBJECT; - if (_0$$4) { - _0$$4 = zephir_is_instance_of(&generator, SL("Closure")); - } - if (_0$$4) { - ZEPHIR_CALL_USER_FUNC(return_value, &generator); - zephir_check_call_status(); - RETURN_MM(); - } - } - zephir_time(return_value); - RETURN_MM(); + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Enum) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Enum, phalcon, logger_enum, NULL, 0); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("ALERT"), 2); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("CRITICAL"), 1); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("CUSTOM"), 8); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("DEBUG"), 7); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("EMERGENCY"), 0); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("ERROR"), 3); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("INFO"), 6); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("NOTICE"), 5); + + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("WARNING"), 4); + + return SUCCESS; } @@ -82776,1390 +77346,807 @@ static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, getTimestamp) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Complex) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Complex, phalcon, mvc_model_resultset_complex, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_complex_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Exception, phalcon, logger_exception, zend_ce_exception, NULL, 0); - zend_declare_property_null(phalcon_mvc_model_resultset_complex_ce, SL("columnTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_resultset_complex_ce, SL("disableHydration"), 0, ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_model_resultset_complex_ce, 1, phalcon_mvc_model_resultsetinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __construct) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Item) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Item, phalcon, logger_item, phalcon_logger_item_method_entry, 0); + + zend_declare_property_null(phalcon_logger_item_ce, SL("context"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("dateTime"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("message"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("level"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("levelName"), ZEND_ACC_PROTECTED); + phalcon_logger_item_ce->create_object = zephir_init_properties_Phalcon_Logger_Item; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Item, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *columnTypes, columnTypes_sub, *result = NULL, result_sub, *cache = NULL, cache_sub, __$null; + zval context; + zend_long level; + zval *message_param = NULL, *levelName_param = NULL, *level_param = NULL, *dateTime, dateTime_sub, *context_param = NULL, _0; + zval message, levelName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columnTypes_sub); - ZVAL_UNDEF(&result_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&levelName); + ZVAL_UNDEF(&dateTime_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(columnTypes) + ZEND_PARSE_PARAMETERS_START(4, 5) + Z_PARAM_STR(message) + Z_PARAM_STR(levelName) + Z_PARAM_LONG(level) + Z_PARAM_OBJECT_OF_CLASS(dateTime, php_date_get_immutable_ce()) Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(result, phalcon_db_resultinterface_ce) - Z_PARAM_ZVAL_OR_NULL(cache) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &columnTypes, &result, &cache); - if (!result) { - result = &result_sub; - result = &__$null; - } - if (!cache) { - cache = &cache_sub; - cache = &__$null; + zephir_fetch_params(1, 4, 1, &message_param, &levelName_param, &level_param, &dateTime, &context_param); + zephir_get_strval(&message, message_param); + zephir_get_strval(&levelName, levelName_param); + level = zephir_get_intval(level_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), columnTypes); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_complex_ce, getThis(), "__construct", &_0, 0, result, cache); - zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); + zephir_update_property_zval(this_ptr, ZEND_STRL("levelName"), &levelName); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, level); + zephir_update_property_zval(this_ptr, ZEND_STRL("level"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateTime"), dateTime); + zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &context); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, current) +static PHP_METHOD(Phalcon_Logger_Item, getContext) { - zend_class_entry *_14$$16, *_29$$36; - zend_string *_5; - zend_ulong _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_15 = NULL, *_18 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, dirtyState = 0; - zval __$true, __$false, row, hydrateMode, eager, alias, activeRow, type, column, columnValue, value, attribute, source, attributes, columnMap, rowModel, keepSnapshots, sqlAlias, modelName, _0, _1, *_2, _3, *_6$$11, _7$$11, _8$$12, _9$$13, _10$$16, _12$$16, _13$$16, _11$$17, _16$$19, _17$$19, _19$$25, _20$$25, *_21$$31, _22$$31, _23$$32, _24$$33, _25$$36, _27$$36, _28$$36, _26$$37, _30$$39, _31$$39, _32$$45, _33$$45; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&hydrateMode); - ZVAL_UNDEF(&eager); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&activeRow); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&columnValue); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&rowModel); - ZVAL_UNDEF(&keepSnapshots); - ZVAL_UNDEF(&sqlAlias); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_8$$12); - ZVAL_UNDEF(&_9$$13); - ZVAL_UNDEF(&_10$$16); - ZVAL_UNDEF(&_12$$16); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_11$$17); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_17$$19); - ZVAL_UNDEF(&_19$$25); - ZVAL_UNDEF(&_20$$25); - ZVAL_UNDEF(&_22$$31); - ZVAL_UNDEF(&_23$$32); - ZVAL_UNDEF(&_24$$33); - ZVAL_UNDEF(&_25$$36); - ZVAL_UNDEF(&_27$$36); - ZVAL_UNDEF(&_28$$36); - ZVAL_UNDEF(&_26$$37); - ZVAL_UNDEF(&_30$$39); - ZVAL_UNDEF(&_31$$39); - ZVAL_UNDEF(&_32$$45); - ZVAL_UNDEF(&_33$$45); - ZEPHIR_MM_GROW(); + RETURN_MEMBER(getThis(), "context"); +} - zephir_read_property(&_0, this_ptr, ZEND_STRL("activeRow"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&activeRow, &_0); - if (Z_TYPE_P(&activeRow) != IS_NULL) { - RETURN_CCTOR(&activeRow); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&row, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("disableHydration"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &row); - RETURN_CCTOR(&row); - } - if (Z_TYPE_P(&row) != IS_ARRAY) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$false); - } - RETURN_MM_BOOL(0); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hydrateMode, &_1); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - ZEPHIR_INIT_NVAR(&activeRow); - object_init_ex(&activeRow, phalcon_mvc_model_row_ce); - if (zephir_has_constructor(&activeRow)) { - ZEPHIR_CALL_METHOD(NULL, &activeRow, "__construct", NULL, 0); - zephir_check_call_status(); - } +static PHP_METHOD(Phalcon_Logger_Item, getDateTime) +{ + zval *this_ptr = getThis(); - break; - } - if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { - ZEPHIR_INIT_NVAR(&activeRow); - array_init(&activeRow); - break; - } - ZEPHIR_INIT_NVAR(&activeRow); - object_init(&activeRow); - break; - } while(0); - dirtyState = 0; - zephir_read_property(&_1, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_1, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 259); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&alias); - if (_5 != NULL) { - ZVAL_STR_COPY(&alias, _5); - } else { - ZVAL_LONG(&alias, _4); - } - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _2); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/Mvc/Model/Resultset/Complex.zep", 138); - return; - } - ZEPHIR_OBS_NVAR(&type); - zephir_array_fetch_string(&type, &column, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 141); - if (ZEPHIR_IS_STRING(&type, "object")) { - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 147); - ZEPHIR_OBS_NVAR(&attributes); - zephir_array_fetch_string(&attributes, &column, SL("attributes"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 148); - ZEPHIR_OBS_NVAR(&columnMap); - zephir_array_fetch_string(&columnMap, &column, SL("columnMap"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 149); - ZEPHIR_INIT_NVAR(&rowModel); - array_init(&rowModel); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 167); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _6$$11) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _6$$11); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_8$$12); - ZEPHIR_CONCAT_SVSV(&_8$$12, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_8$$12, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 160); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$11, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$11)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_9$$13); - ZEPHIR_CONCAT_SVSV(&_9$$13, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_9$$13, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 160); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - ZEPHIR_OBS_NVAR(&keepSnapshots); - if (!(zephir_array_isset_string_fetch(&keepSnapshots, &column, SL("keepSnapshots"), 0))) { - ZEPHIR_INIT_NVAR(&keepSnapshots); - ZVAL_BOOL(&keepSnapshots, 0); - } - if (ZEPHIR_GLOBAL(orm).late_state_binding) { - ZEPHIR_OBS_NVAR(&_10$$16); - zephir_array_fetch_string(&_10$$16, &column, SL("instance"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 175); - if (zephir_instance_of_ev(&_10$$16, phalcon_mvc_model_ce)) { - zephir_array_fetch_string(&_11$$17, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 176); - ZEPHIR_INIT_NVAR(&modelName); - zephir_get_class(&modelName, &_11$$17, 0); - } else { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); - } - zephir_array_fetch_string(&_12$$16, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 182); - ZVAL_LONG(&_13$$16, dirtyState); - _14$$16 = zephir_fetch_class(&modelName); - ZEPHIR_CALL_CE_STATIC(&value, _14$$16, "cloneresultmap", NULL, 0, &_12$$16, &rowModel, &columnMap, &_13$$16, &keepSnapshots); - zephir_check_call_status(); - } else { - zephir_array_fetch_string(&_16$$19, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 194); - ZVAL_LONG(&_17$$19, dirtyState); - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_15, 0, &_16$$19, &rowModel, &columnMap, &_17$$19, &keepSnapshots); - zephir_check_call_status(); - } - break; - } - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_18, 0, &rowModel, &columnMap, &hydrateMode); - zephir_check_call_status(); - break; - } while(0); - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch_string(&attribute, &column, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 218); - } else { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &row, &sqlAlias, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 224); - } else { - ZEPHIR_OBS_NVAR(&value); - zephir_array_isset_fetch(&value, &row, &alias, 0); - } - if (zephir_array_isset_string(&column, SL("balias"))) { - ZEPHIR_CPY_WRT(&attribute, &alias); - } else { - ZEPHIR_INIT_NVAR(&_19$$25); - ZVAL_STRING(&_19$$25, "_"); - ZEPHIR_INIT_NVAR(&_20$$25); - ZVAL_STRING(&_20$$25, ""); - ZEPHIR_INIT_NVAR(&attribute); - zephir_fast_str_replace(&attribute, &_19$$25, &_20$$25, &alias); - } - } - if (!(zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 1))) { - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { - zephir_array_update_zval(&activeRow, &attribute, &value, PH_COPY | PH_SEPARATE); - break; - } - zephir_update_property_zval_zval(&activeRow, &attribute, &value); - break; - } while(0); + RETURN_MEMBER(getThis(), "dateTime"); +} - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&alias, &_1, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&column, &_1, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/Mvc/Model/Resultset/Complex.zep", 138); - return; - } - ZEPHIR_OBS_NVAR(&type); - zephir_array_fetch_string(&type, &column, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 141); - if (ZEPHIR_IS_STRING(&type, "object")) { - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 147); - ZEPHIR_OBS_NVAR(&attributes); - zephir_array_fetch_string(&attributes, &column, SL("attributes"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 148); - ZEPHIR_OBS_NVAR(&columnMap); - zephir_array_fetch_string(&columnMap, &column, SL("columnMap"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 149); - ZEPHIR_INIT_NVAR(&rowModel); - array_init(&rowModel); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 167); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _21$$31) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _21$$31); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_23$$32); - ZEPHIR_CONCAT_SVSV(&_23$$32, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_23$$32, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 160); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_22$$31, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_22$$31)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_24$$33); - ZEPHIR_CONCAT_SVSV(&_24$$33, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_24$$33, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 160); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - ZEPHIR_OBS_NVAR(&keepSnapshots); - if (!(zephir_array_isset_string_fetch(&keepSnapshots, &column, SL("keepSnapshots"), 0))) { - ZEPHIR_INIT_NVAR(&keepSnapshots); - ZVAL_BOOL(&keepSnapshots, 0); - } - if (ZEPHIR_GLOBAL(orm).late_state_binding) { - ZEPHIR_OBS_NVAR(&_25$$36); - zephir_array_fetch_string(&_25$$36, &column, SL("instance"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 175); - if (zephir_instance_of_ev(&_25$$36, phalcon_mvc_model_ce)) { - zephir_array_fetch_string(&_26$$37, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 176); - ZEPHIR_INIT_NVAR(&modelName); - zephir_get_class(&modelName, &_26$$37, 0); - } else { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); - } - zephir_array_fetch_string(&_27$$36, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 182); - ZVAL_LONG(&_28$$36, dirtyState); - _29$$36 = zephir_fetch_class(&modelName); - ZEPHIR_CALL_CE_STATIC(&value, _29$$36, "cloneresultmap", NULL, 0, &_27$$36, &rowModel, &columnMap, &_28$$36, &keepSnapshots); - zephir_check_call_status(); - } else { - zephir_array_fetch_string(&_30$$39, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 194); - ZVAL_LONG(&_31$$39, dirtyState); - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_15, 0, &_30$$39, &rowModel, &columnMap, &_31$$39, &keepSnapshots); - zephir_check_call_status(); - } - break; - } - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_18, 0, &rowModel, &columnMap, &hydrateMode); - zephir_check_call_status(); - break; - } while(0); +static PHP_METHOD(Phalcon_Logger_Item, getMessage) +{ + zval *this_ptr = getThis(); - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch_string(&attribute, &column, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 218); - } else { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &row, &sqlAlias, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 224); - } else { - ZEPHIR_OBS_NVAR(&value); - zephir_array_isset_fetch(&value, &row, &alias, 0); - } - if (zephir_array_isset_string(&column, SL("balias"))) { - ZEPHIR_CPY_WRT(&attribute, &alias); - } else { - ZEPHIR_INIT_NVAR(&_32$$45); - ZVAL_STRING(&_32$$45, "_"); - ZEPHIR_INIT_NVAR(&_33$$45); - ZVAL_STRING(&_33$$45, ""); - ZEPHIR_INIT_NVAR(&attribute); - zephir_fast_str_replace(&attribute, &_32$$45, &_33$$45, &alias); - } - } - ZEPHIR_OBS_NVAR(&eager); - if (!(zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 0))) { - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { - zephir_array_update_zval(&activeRow, &attribute, &value, PH_COPY | PH_SEPARATE); - break; - } - zephir_update_property_zval_zval(&activeRow, &attribute, &value); - break; - } while(0); - } - ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); - zephir_check_call_status(); + + RETURN_MEMBER(getThis(), "message"); +} + +static PHP_METHOD(Phalcon_Logger_Item, getLevel) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "level"); +} + +static PHP_METHOD(Phalcon_Logger_Item, getLevelName) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "levelName"); +} + +zend_object *zephir_init_properties_Phalcon_Logger_Item(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("context"), &_1$$3); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_NVAR(&alias); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &activeRow); - RETURN_CCTOR(&activeRow); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, toArray) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Logger) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Logger, phalcon, logger_logger, phalcon_logger_abstractlogger_ce, phalcon_logger_logger_method_entry, 0); + + zend_class_implements(phalcon_logger_logger_ce, 1, phalcon_logger_loggerinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Logger, alert) { - zval records; - zval current, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(¤t); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&records); + ZVAL_UNDEF(&context); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } - ZEPHIR_INIT_VAR(&records); - array_init(&records); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 91); + + ZVAL_LONG(&_0, 2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(¤t, this_ptr, "current", &_2, 481); - zephir_check_call_status(); - zephir_array_append(&records, ¤t, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Complex.zep", 279); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_3, 0); - zephir_check_call_status(); - } - RETURN_CTOR(&records); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize) +static PHP_METHOD(Phalcon_Logger_Logger, critical) { - zval data; - zval container, serializer, _1, _2, _3, _4$$4, _5$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Complex.zep", 299); - return; - } - ZEPHIR_INIT_VAR(&data); - zephir_create_array(&data, 4, 0); - ZEPHIR_OBS_VAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("cache"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - zephir_array_update_string(&data, SL("rows"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("columnTypes"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("hydrateMode"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "serializer"); - ZEPHIR_CALL_METHOD(&_2, &container, "has", NULL, 0, &_3); - zephir_check_call_status(); - if (zephir_is_true(&_2)) { - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_4$$4, &container, "getshared", NULL, 0, &_5$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_4$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); } - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &data); + + + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, unserialize) +static PHP_METHOD(Phalcon_Logger_Logger, debug) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *data, data_sub, __$true, __$false, resultset, container, serializer, _1, _2, _5, _6, _7, _8, _9, _10, _3$$4, _4$$4; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&resultset); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &data); - - - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$true); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$false); - } - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Complex.zep", 335); - return; + zephir_get_arrval(&context, context_param); } - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "serializer"); - ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_2); + + + ZVAL_LONG(&_0, 7); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - if (zephir_is_true(&_1)) { - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_3$$4, &container, "getshared", NULL, 0, &_4$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_3$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "unserialize", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&resultset, &serializer, "getdata", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 16, data); - zephir_check_call_status(); - } - if (UNEXPECTED(Z_TYPE_P(&resultset) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/Mvc/Model/Resultset/Complex.zep", 348); - return; - } - zephir_array_fetch_string(&_5, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 351); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_5); - zephir_array_fetch_string(&_6, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 352); - ZEPHIR_INIT_ZVAL_NREF(_7); - ZVAL_LONG(&_7, zephir_fast_count_int(&_6)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_7); - zephir_array_fetch_string(&_8, &resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 353); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_8); - zephir_array_fetch_string(&_9, &resultset, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 354); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), &_9); - zephir_array_fetch_string(&_10, &resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 355); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_10); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __serialize) +static PHP_METHOD(Phalcon_Logger_Logger, emergency) { - zval records, cache, columnTypes, hydrateMode, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&columnTypes); - ZVAL_UNDEF(&hydrateMode); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } - ZEPHIR_CALL_METHOD(&records, this_ptr, "toarray", NULL, 0); + + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columnTypes, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hydrateMode, &_0); - zephir_create_array(return_value, 4, 0); - zephir_array_update_string(return_value, SL("cache"), &cache, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("rows"), &records, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("columnTypes"), &columnTypes, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("hydrateMode"), &hydrateMode, PH_COPY | PH_SEPARATE); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __unserialize) +static PHP_METHOD(Phalcon_Logger_Logger, error) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL, __$true, __$false, _0, _1, _2, _3, _4, _5; - zval data; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&context); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - - - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$true); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$false); + zephir_get_arrval(&context, context_param); } - zephir_array_fetch_string(&_0, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 386); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_0); - zephir_array_fetch_string(&_1, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 387); - ZEPHIR_INIT_ZVAL_NREF(_2); - ZVAL_LONG(&_2, zephir_fast_count_int(&_1)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_2); - zephir_array_fetch_string(&_3, &data, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 388); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_3); - zephir_array_fetch_string(&_4, &data, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 389); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), &_4); - zephir_array_fetch_string(&_5, &data, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 390); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_5); - ZEPHIR_MM_RESTORE(); -} + ZVAL_LONG(&_0, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Logger_Logger, info) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); #endif + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Simple) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Simple, phalcon, mvc_model_resultset_simple, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_simple_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("columnMap"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("model"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_resultset_simple_ce, SL("keepSnapshots"), 0, ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_LONG(&_0, 6); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __construct) +static PHP_METHOD(Phalcon_Logger_Logger, log) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zend_bool keepSnapshots; - zval *columnMap, columnMap_sub, *model, model_sub, *result, result_sub, *cache = NULL, cache_sub, *keepSnapshots_param = NULL, __$true, __$false, __$null; + zval context; + zval message, _0; + zval *level, level_sub, *message_param = NULL, *context_param = NULL, intLevel; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columnMap_sub); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&result_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&level_sub); + ZVAL_UNDEF(&intLevel); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_ZVAL(columnMap) - Z_PARAM_ZVAL(model) - Z_PARAM_ZVAL(result) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(level) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(cache) - Z_PARAM_BOOL(keepSnapshots) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 2, &columnMap, &model, &result, &cache, &keepSnapshots_param); - if (!cache) { - cache = &cache_sub; - cache = &__$null; - } - if (!keepSnapshots_param) { - keepSnapshots = 0; + zephir_fetch_params(1, 2, 1, &level, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - keepSnapshots = zephir_get_boolval(keepSnapshots_param); + zephir_get_arrval(&context, context_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), columnMap); - if (keepSnapshots) { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &__$false); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_simple_ce, getThis(), "__construct", &_0, 0, result, cache); + ZEPHIR_CALL_METHOD(&intLevel, this_ptr, "getlevelnumber", NULL, 0, level); + zephir_check_call_status(); + zephir_cast_to_string(&_0, &message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &intLevel, &_0, &context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) +static PHP_METHOD(Phalcon_Logger_Logger, notice) { - zend_class_entry *_6$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval __$true, __$false, row, hydrateMode, columnMap, activeRow, modelName, _0, _1$$6, _3$$6, _4$$6, _5$$6, _2$$7, _8$$9, _9$$9, _10$$9; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&hydrateMode); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&activeRow); - ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&context); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("activeRow"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&activeRow, &_0); - if (Z_TYPE_P(&activeRow) != IS_NULL) { - RETURN_CCTOR(&activeRow); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&row, &_0); - if (Z_TYPE_P(&row) != IS_ARRAY) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$false); - } - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hydrateMode, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columnMap, &_0); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - if (ZEPHIR_GLOBAL(orm).late_state_binding) { - ZEPHIR_OBS_VAR(&_1$$6); - zephir_read_property(&_1$$6, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - if (zephir_instance_of_ev(&_1$$6, phalcon_mvc_model_ce)) { - zephir_read_property(&_2$$7, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&modelName); - zephir_get_class(&modelName, &_2$$7, 0); - } else { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); - } - zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4$$6, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_5$$6, 0); - _6$$6 = zephir_fetch_class(&modelName); - ZEPHIR_CALL_CE_STATIC(&activeRow, _6$$6, "cloneresultmap", NULL, 0, &_3$$6, &row, &columnMap, &_5$$6, &_4$$6); - zephir_check_call_status(); - } else { - zephir_read_property(&_8$$9, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_9$$9, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_10$$9, 0); - ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", &_7, 0, &_8$$9, &row, &columnMap, &_10$$9, &_9$$9); - zephir_check_call_status(); - } - break; - } - ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_11, 0, &row, &columnMap, &hydrateMode); - zephir_check_call_status(); - break; - } while(0); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &activeRow); - RETURN_CCTOR(&activeRow); + + ZVAL_LONG(&_0, 5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray) +static PHP_METHOD(Phalcon_Logger_Logger, warning) { - zend_string *_9$$8, *_22$$17; - zend_ulong _8$$8, _21$$17; - zval renamedRecords, renamed; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_12 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *renameColumns_param = NULL, __$null, result, records, record, renamedKey, key, value, columnMap, _2, _0$$3, _3$$5, *_4$$7, _5$$7, *_6$$8, _7$$8, _10$$10, _11$$10, _13$$12, _14$$12, _15$$14, _16$$14, _17$$16, _18$$16, *_19$$17, _20$$17, _23$$19, _24$$19, _25$$21, _26$$21, _27$$23, _28$$23, _29$$25, _30$$25; - zend_bool renameColumns, _1; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&renamedKey); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_13$$12); - ZVAL_UNDEF(&_14$$12); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_16$$14); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$16); - ZVAL_UNDEF(&_20$$17); - ZVAL_UNDEF(&_23$$19); - ZVAL_UNDEF(&_24$$19); - ZVAL_UNDEF(&_25$$21); - ZVAL_UNDEF(&_26$$21); - ZVAL_UNDEF(&_27$$23); - ZVAL_UNDEF(&_28$$23); - ZVAL_UNDEF(&_29$$25); - ZVAL_UNDEF(&_30$$25); - ZVAL_UNDEF(&renamedRecords); - ZVAL_UNDEF(&renamed); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(renameColumns) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &renameColumns_param); - if (!renameColumns_param) { - renameColumns = 1; + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - renameColumns = zephir_get_boolval(renameColumns_param); + zephir_get_arrval(&context, context_param); } - ZEPHIR_OBS_VAR(&records); - zephir_read_property(&records, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); - if (Z_TYPE_P(&records) != IS_ARRAY) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("result"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&result, &_0$$3); - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0$$3) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &result, "execute", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&records, &result, "fetchall", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &__$null); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &records); - } - _1 = renameColumns; - if (_1) { - ZEPHIR_OBS_VAR(&_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - _1 = !(zephir_instance_of_ev(&_2, phalcon_mvc_model_row_ce)); - } - if (_1) { - zephir_read_property(&_3$$5, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columnMap, &_3$$5); - if (Z_TYPE_P(&columnMap) != IS_ARRAY) { - RETURN_CCTOR(&records); - } - ZEPHIR_INIT_VAR(&renamedRecords); - array_init(&renamedRecords); - if (Z_TYPE_P(&records) == IS_ARRAY) { - zephir_is_iterable(&records, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 240); - if (Z_TYPE_P(&records) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&records), _4$$7) - { - ZEPHIR_INIT_NVAR(&record); - ZVAL_COPY(&record, _4$$7); - ZEPHIR_INIT_NVAR(&renamed); - array_init(&renamed); - zephir_is_iterable(&record, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 238); - if (Z_TYPE_P(&record) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&record), _8$$8, _9$$8, _6$$8) - { - ZEPHIR_INIT_NVAR(&key); - if (_9$$8 != NULL) { - ZVAL_STR_COPY(&key, _9$$8); - } else { - ZVAL_LONG(&key, _8$$8); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _6$$8); - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_10$$10); - object_init_ex(&_10$$10, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$10); - ZEPHIR_CONCAT_SVS(&_11$$10, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_10$$10, "__construct", &_12, 32, &_11$$10); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$10, "phalcon/Mvc/Model/Resultset/Simple.zep", 221); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_13$$12); - object_init_ex(&_13$$12, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_14$$12); - ZEPHIR_CONCAT_SVS(&_14$$12, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_13$$12, "__construct", &_12, 32, &_14$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$12, "phalcon/Mvc/Model/Resultset/Simple.zep", 228); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &record, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$8, &record, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$8)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &record, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &record, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_15$$14); - object_init_ex(&_15$$14, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_16$$14); - ZEPHIR_CONCAT_SVS(&_16$$14, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_15$$14, "__construct", &_12, 32, &_16$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_15$$14, "phalcon/Mvc/Model/Resultset/Simple.zep", 221); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_17$$16); - object_init_ex(&_17$$16, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_18$$16); - ZEPHIR_CONCAT_SVS(&_18$$16, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_17$$16, "__construct", &_12, 32, &_18$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$16, "phalcon/Mvc/Model/Resultset/Simple.zep", 228); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &record, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_array_append(&renamedRecords, &renamed, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Simple.zep", 238); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$7, &records, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&record, &records, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&renamed); - array_init(&renamed); - zephir_is_iterable(&record, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 238); - if (Z_TYPE_P(&record) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&record), _21$$17, _22$$17, _19$$17) - { - ZEPHIR_INIT_NVAR(&key); - if (_22$$17 != NULL) { - ZVAL_STR_COPY(&key, _22$$17); - } else { - ZVAL_LONG(&key, _21$$17); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _19$$17); - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_23$$19); - object_init_ex(&_23$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_24$$19); - ZEPHIR_CONCAT_SVS(&_24$$19, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_23$$19, "__construct", &_12, 32, &_24$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$19, "phalcon/Mvc/Model/Resultset/Simple.zep", 221); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_25$$21); - object_init_ex(&_25$$21, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_26$$21); - ZEPHIR_CONCAT_SVS(&_26$$21, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_25$$21, "__construct", &_12, 32, &_26$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_25$$21, "phalcon/Mvc/Model/Resultset/Simple.zep", 228); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &record, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20$$17, &record, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20$$17)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &record, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &record, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_27$$23); - object_init_ex(&_27$$23, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_28$$23); - ZEPHIR_CONCAT_SVS(&_28$$23, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_27$$23, "__construct", &_12, 32, &_28$$23); - zephir_check_call_status(); - zephir_throw_exception_debug(&_27$$23, "phalcon/Mvc/Model/Resultset/Simple.zep", 221); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_29$$25); - object_init_ex(&_29$$25, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_30$$25); - ZEPHIR_CONCAT_SVS(&_30$$25, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_29$$25, "__construct", &_12, 32, &_30$$25); - zephir_check_call_status(); - zephir_throw_exception_debug(&_29$$25, "phalcon/Mvc/Model/Resultset/Simple.zep", 228); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &record, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_array_append(&renamedRecords, &renamed, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Simple.zep", 238); - ZEPHIR_CALL_METHOD(NULL, &records, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&record); - } - RETURN_CTOR(&renamedRecords); - } - RETURN_CCTOR(&records); + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, serialize) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_LoggerFactory) { - zval data; - zval container, serializer, _1, _2, _3, _4, _5$$4, _6$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, LoggerFactory, phalcon, logger_loggerfactory, phalcon_factory_abstractconfigfactory_ce, phalcon_logger_loggerfactory_method_entry, 0); + + zend_declare_property_null(phalcon_logger_loggerfactory_ce, SL("adapterFactory"), ZEND_ACC_PRIVATE); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_LoggerFactory, __construct) +{ + zval *factory, factory_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&factory_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_logger_adapterfactory_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif - ZEPHIR_MM_GROW(); + zephir_fetch_params_without_memory_grow(1, 0, &factory); - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Simple.zep", 260); - return; - } - ZEPHIR_INIT_VAR(&data); - zephir_create_array(&data, 6, 0); - ZEPHIR_OBS_VAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("model"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("cache"), &_1, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_3, 0); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "toarray", NULL, 0, &_3); - zephir_check_call_status(); - zephir_array_update_string(&data, SL("rows"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("columnMap"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("hydrateMode"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("keepSnapshots"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "serializer"); - ZEPHIR_CALL_METHOD(&_2, &container, "has", NULL, 0, &_4); - zephir_check_call_status(); - if (zephir_is_true(&_2)) { - ZEPHIR_INIT_VAR(&_6$$4); - ZVAL_STRING(&_6$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_5$$4, &container, "getshared", NULL, 0, &_6$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_5$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &data); - zephir_check_call_status(); - RETURN_MM(); + + zephir_update_property_zval(this_ptr, ZEND_STRL("adapterFactory"), factory); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, unserialize) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, load) { + zend_string *_7; + zend_ulong _6; + zval data; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *data, data_sub, resultset, keepSnapshots, container, serializer, _1, _2, _5, _6, _7, _8, _9, _10, _11, _3$$4, _4$$4; + zval *config = NULL, config_sub, adapter, adapterClass, adapterFileName, adapterName, adapterOptions, adapters, name, timezone, options, _0, _1, _2, _3, *_4, _5, _8$$3, _9$$3, _10$$3, _11$$3, _12$$4, _13$$4, _14$$4, _15$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&resultset); - ZVAL_UNDEF(&keepSnapshots); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&adapter); + ZVAL_UNDEF(&adapterClass); + ZVAL_UNDEF(&adapterFileName); + ZVAL_UNDEF(&adapterName); + ZVAL_UNDEF(&adapterOptions); + ZVAL_UNDEF(&adapters); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&timezone); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$4); + ZVAL_UNDEF(&_13$$4); + ZVAL_UNDEF(&_14$$4); + ZVAL_UNDEF(&_15$$4); + ZVAL_UNDEF(&data); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &data); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", &_0, 0); + ZEPHIR_INIT_VAR(&data); + array_init(&data); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Simple.zep", 297); - return; - } + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "name"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_OBS_VAR(&name); + zephir_array_fetch_string(&name, config, SL("name"), PH_NOISY, "phalcon/Logger/LoggerFactory.zep", 62); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "timezone"); + ZEPHIR_CALL_METHOD(&timezone, this_ptr, "getarrval", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + array_init(&_1); ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "serializer"); - ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_2); + ZVAL_STRING(&_2, "options"); + ZEPHIR_CALL_METHOD(&options, this_ptr, "getarrval", NULL, 0, config, &_2, &_1); zephir_check_call_status(); - if (zephir_is_true(&_1)) { - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_3$$4, &container, "getshared", NULL, 0, &_4$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_3$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "unserialize", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&resultset, &serializer, "getdata", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "adapters"); + ZEPHIR_CALL_METHOD(&adapters, this_ptr, "getarrval", NULL, 0, &options, &_3, &_2); + zephir_check_call_status(); + zephir_is_iterable(&adapters, 0, "phalcon/Logger/LoggerFactory.zep", 81); + if (Z_TYPE_P(&adapters) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&adapters), _6, _7, _4) + { + ZEPHIR_INIT_NVAR(&adapterName); + if (_7 != NULL) { + ZVAL_STR_COPY(&adapterName, _7); + } else { + ZVAL_LONG(&adapterName, _6); + } + ZEPHIR_INIT_NVAR(&adapter); + ZVAL_COPY(&adapter, _4); + ZEPHIR_INIT_NVAR(&_8$$3); + ZVAL_STRING(&_8$$3, "adapter"); + ZEPHIR_CALL_METHOD(&adapterClass, this_ptr, "getarrval", NULL, 0, &adapter, &_8$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$3); + ZVAL_STRING(&_8$$3, "name"); + ZEPHIR_CALL_METHOD(&adapterFileName, this_ptr, "getarrval", NULL, 0, &adapter, &_8$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$3); + array_init(&_8$$3); + ZEPHIR_INIT_NVAR(&_9$$3); + ZVAL_STRING(&_9$$3, "options"); + ZEPHIR_CALL_METHOD(&adapterOptions, this_ptr, "getarrval", NULL, 0, &adapter, &_9$$3, &_8$$3); + zephir_check_call_status(); + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_11$$3, &_10$$3, "newinstance", NULL, 0, &adapterClass, &adapterFileName, &adapterOptions); + zephir_check_call_status(); + zephir_array_update_zval(&data, &adapterName, &_11$$3, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 16, data); + ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &adapters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&adapterName, &adapters, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&adapter, &adapters, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$4); + ZVAL_STRING(&_12$$4, "adapter"); + ZEPHIR_CALL_METHOD(&adapterClass, this_ptr, "getarrval", NULL, 0, &adapter, &_12$$4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$4); + ZVAL_STRING(&_12$$4, "name"); + ZEPHIR_CALL_METHOD(&adapterFileName, this_ptr, "getarrval", NULL, 0, &adapter, &_12$$4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$4); + array_init(&_12$$4); + ZEPHIR_INIT_NVAR(&_13$$4); + ZVAL_STRING(&_13$$4, "options"); + ZEPHIR_CALL_METHOD(&adapterOptions, this_ptr, "getarrval", NULL, 0, &adapter, &_13$$4, &_12$$4); + zephir_check_call_status(); + zephir_read_property(&_14$$4, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_15$$4, &_14$$4, "newinstance", NULL, 0, &adapterClass, &adapterFileName, &adapterOptions); + zephir_check_call_status(); + zephir_array_update_zval(&data, &adapterName, &_15$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); + zephir_check_call_status(); + } } - if (UNEXPECTED(Z_TYPE_P(&resultset) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/Mvc/Model/Resultset/Simple.zep", 310); - return; - } - zephir_array_fetch_string(&_5, &resultset, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 313); - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &_5); - zephir_array_fetch_string(&_6, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 314); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_6); - zephir_array_fetch_string(&_7, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 315); - ZEPHIR_INIT_ZVAL_NREF(_8); - ZVAL_LONG(&_8, zephir_fast_count_int(&_7)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_8); - zephir_array_fetch_string(&_9, &resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 316); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_9); - zephir_array_fetch_string(&_10, &resultset, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 317); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_10); - zephir_array_fetch_string(&_11, &resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 318); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_11); - if (zephir_array_isset_string_fetch(&keepSnapshots, &resultset, SL("keepSnapshots"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &keepSnapshots); - } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&adapter); + ZEPHIR_INIT_NVAR(&adapterName); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &data, &timezone); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __serialize) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, newInstance) { - zval _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval adapters; + zval *name_param = NULL, *adapters_param = NULL, *timezone = NULL, timezone_sub, __$null; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&timezone_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&adapters); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(adapters) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone, php_date_get_timezone_ce()) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, &name_param, &adapters_param, &timezone); + zephir_get_strval(&name, name_param); + if (!adapters_param) { + ZEPHIR_INIT_VAR(&adapters); + array_init(&adapters); + } else { + zephir_get_arrval(&adapters, adapters_param); + } + if (!timezone) { + timezone = &timezone_sub; + timezone = &__$null; + } - zephir_create_array(return_value, 6, 0); - ZEPHIR_OBS_VAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("model"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("cache"), &_0, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_2, 0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0, &_2); + + object_init_ex(return_value, phalcon_logger_logger_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 413, &name, &adapters, timezone); zephir_check_call_status(); - zephir_array_update_string(return_value, SL("rows"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("columnMap"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("keepSnapshots"), &_0, PH_COPY | PH_SEPARATE); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __unserialize) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, getArrVal) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL, keepSnapshots, _0, _1, _2, _3, _4, _5, _6; - zval data; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&keepSnapshots); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } - zephir_array_fetch_string(&_0, &data, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 341); - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &_0); - zephir_array_fetch_string(&_1, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 342); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_1); - zephir_array_fetch_string(&_2, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 343); - ZEPHIR_INIT_ZVAL_NREF(_3); - ZVAL_LONG(&_3, zephir_fast_count_int(&_2)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_3); - zephir_array_fetch_string(&_4, &data, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 344); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_4); - zephir_array_fetch_string(&_5, &data, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 345); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_5); - zephir_array_fetch_string(&_6, &data, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 346); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_6); - if (zephir_array_isset_string_fetch(&keepSnapshots, &data, SL("keepSnapshots"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &keepSnapshots); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 1)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); } - ZEPHIR_MM_RESTORE(); + RETURN_CTOR(&value); +} + +static PHP_METHOD(Phalcon_Logger_LoggerFactory, getExceptionClass) +{ + zval *this_ptr = getThis(); + + + + RETURN_STRING("Phalcon\\Logger\\Exception"); } @@ -84172,3312 +78159,2951 @@ static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __unserialize) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Builder) +ZEPHIR_INIT_CLASS(Phalcon_Logger_LoggerInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Builder, phalcon, mvc_model_query_builder, phalcon_mvc_model_query_builder_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger, LoggerInterface, phalcon, logger_loggerinterface, phalcon_logger_loggerinterface_method_entry); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("bindParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("columns"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("conditions"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("distinct"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_builder_ce, SL("forUpdate"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("group"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("having"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_query_builder_ce, SL("hiddenParamNumber"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("joins"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("limit"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("models"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_query_builder_ce, SL("offset"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("order"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_builder_ce, SL("sharedLock"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_model_query_builder_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Query_Builder; + return SUCCESS; +} - zend_class_implements(phalcon_mvc_model_query_builder_ce, 1, phalcon_mvc_model_query_builderinterface_ce); - zend_class_implements(phalcon_mvc_model_query_builder_ce, 1, phalcon_di_injectionawareinterface_ce); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, alert); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, critical); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, debug); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, emergency); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, error); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getAdapter); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getAdapters); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getLogLevel); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, info); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, log); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, notice); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, warning); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_AbstractAdapter) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger\\Adapter, AbstractAdapter, phalcon, logger_adapter_abstractadapter, phalcon_logger_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_string(phalcon_logger_adapter_abstractadapter_ce, SL("defaultFormatter"), "Phalcon\\Logger\\Formatter\\Line", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_abstractadapter_ce, SL("formatter"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_logger_adapter_abstractadapter_ce, SL("inTransaction"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_abstractadapter_ce, SL("queue"), ZEND_ACC_PROTECTED); + phalcon_logger_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Logger_Adapter_AbstractAdapter; + + zend_class_implements(phalcon_logger_adapter_abstractadapter_ce, 1, phalcon_logger_adapter_adapterinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __destruct) { - zend_bool _7$$38; - zval mergedConditions, mergedParams, mergedTypes; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params = NULL, params_sub, *container = NULL, container_sub, __$null, conditions, columns, groupClause, havingClause, limitClause, forUpdate, sharedLock, orderClause, offsetClause, joinsClause, singleConditionArray, limit, offset, fromClause, singleCondition, singleParams, singleTypes, distinct, bind, bindTypes, *_0$$7, _1$$7, _6$$7, _2$$11, _3$$12, _4$$16, _5$$17; zval *this_ptr = getThis(); - ZVAL_UNDEF(¶ms_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&groupClause); - ZVAL_UNDEF(&havingClause); - ZVAL_UNDEF(&limitClause); - ZVAL_UNDEF(&forUpdate); - ZVAL_UNDEF(&sharedLock); - ZVAL_UNDEF(&orderClause); - ZVAL_UNDEF(&offsetClause); - ZVAL_UNDEF(&joinsClause); - ZVAL_UNDEF(&singleConditionArray); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&fromClause); - ZVAL_UNDEF(&singleCondition); - ZVAL_UNDEF(&singleParams); - ZVAL_UNDEF(&singleTypes); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&bind); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&_1$$7); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_2$$11); - ZVAL_UNDEF(&_3$$12); - ZVAL_UNDEF(&_4$$16); - ZVAL_UNDEF(&_5$$17); - ZVAL_UNDEF(&mergedConditions); - ZVAL_UNDEF(&mergedParams); - ZVAL_UNDEF(&mergedTypes); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, ¶ms, &container); - if (!params) { - params = ¶ms_sub; - params = &__$null; - } - if (!container) { - container = &container_sub; - container = &__$null; - } - - if (Z_TYPE_P(params) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&conditions); - if (zephir_array_isset_long_fetch(&conditions, params, 0, 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); - } else { - ZEPHIR_OBS_NVAR(&conditions); - if (zephir_array_isset_string_fetch(&conditions, params, SL("conditions"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); - } - } - if (Z_TYPE_P(&conditions) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&mergedConditions); - array_init(&mergedConditions); - ZEPHIR_INIT_VAR(&mergedParams); - array_init(&mergedParams); - ZEPHIR_INIT_VAR(&mergedTypes); - array_init(&mergedTypes); - zephir_is_iterable(&conditions, 0, "phalcon/Mvc/Model/Query/Builder.zep", 189); - if (Z_TYPE_P(&conditions) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&conditions), _0$$7) - { - ZEPHIR_INIT_NVAR(&singleConditionArray); - ZVAL_COPY(&singleConditionArray, _0$$7); - if (Z_TYPE_P(&singleConditionArray) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&singleCondition); - zephir_array_isset_long_fetch(&singleCondition, &singleConditionArray, 0, 0); - ZEPHIR_OBS_NVAR(&singleParams); - zephir_array_isset_long_fetch(&singleParams, &singleConditionArray, 1, 0); - ZEPHIR_OBS_NVAR(&singleTypes); - zephir_array_isset_long_fetch(&singleTypes, &singleConditionArray, 2, 0); - if (Z_TYPE_P(&singleCondition) == IS_STRING) { - zephir_array_append(&mergedConditions, &singleCondition, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 176); - } - if (Z_TYPE_P(&singleParams) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_2$$11); - zephir_add_function(&_2$$11, &mergedParams, &singleParams); - ZEPHIR_CPY_WRT(&mergedParams, &_2$$11); - } - if (Z_TYPE_P(&singleTypes) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_3$$12); - zephir_add_function(&_3$$12, &mergedTypes, &singleTypes); - ZEPHIR_CPY_WRT(&mergedTypes, &_3$$12); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &conditions, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$7, &conditions, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&singleConditionArray, &conditions, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&singleConditionArray) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&singleCondition); - zephir_array_isset_long_fetch(&singleCondition, &singleConditionArray, 0, 0); - ZEPHIR_OBS_NVAR(&singleParams); - zephir_array_isset_long_fetch(&singleParams, &singleConditionArray, 1, 0); - ZEPHIR_OBS_NVAR(&singleTypes); - zephir_array_isset_long_fetch(&singleTypes, &singleConditionArray, 2, 0); - if (Z_TYPE_P(&singleCondition) == IS_STRING) { - zephir_array_append(&mergedConditions, &singleCondition, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 176); - } - if (Z_TYPE_P(&singleParams) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_4$$16); - zephir_add_function(&_4$$16, &mergedParams, &singleParams); - ZEPHIR_CPY_WRT(&mergedParams, &_4$$16); - } - if (Z_TYPE_P(&singleTypes) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_5$$17); - zephir_add_function(&_5$$17, &mergedTypes, &singleTypes); - ZEPHIR_CPY_WRT(&mergedTypes, &_5$$17); - } - } - ZEPHIR_CALL_METHOD(NULL, &conditions, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&singleConditionArray); - ZEPHIR_INIT_VAR(&_6$$7); - zephir_fast_join_str(&_6$$7, SL(" AND "), &mergedConditions); - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &_6$$7); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &mergedParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &mergedTypes); - } - ZEPHIR_OBS_VAR(&bind); - if (zephir_array_isset_string_fetch(&bind, params, SL("bind"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bind); - } - ZEPHIR_OBS_VAR(&bindTypes); - if (zephir_array_isset_string_fetch(&bindTypes, params, SL("bindTypes"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - ZEPHIR_OBS_VAR(&distinct); - if (zephir_array_isset_string_fetch(&distinct, params, SL("distinct"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("distinct"), &distinct); - } - ZEPHIR_OBS_VAR(&fromClause); - if (zephir_array_isset_string_fetch(&fromClause, params, SL("models"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &fromClause); - } - ZEPHIR_OBS_VAR(&columns); - if (zephir_array_isset_string_fetch(&columns, params, SL("columns"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); - } - ZEPHIR_OBS_VAR(&joinsClause); - if (zephir_array_isset_string_fetch(&joinsClause, params, SL("joins"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("joins"), &joinsClause); - } - ZEPHIR_OBS_VAR(&groupClause); - if (zephir_array_isset_string_fetch(&groupClause, params, SL("group"), 0)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "groupby", NULL, 0, &groupClause); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&havingClause); - if (zephir_array_isset_string_fetch(&havingClause, params, SL("having"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("having"), &havingClause); - } - ZEPHIR_OBS_VAR(&orderClause); - if (zephir_array_isset_string_fetch(&orderClause, params, SL("order"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("order"), &orderClause); - } - ZEPHIR_OBS_VAR(&limitClause); - if (zephir_array_isset_string_fetch(&limitClause, params, SL("limit"), 0)) { - if (Z_TYPE_P(&limitClause) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&limit); - if (zephir_array_isset_long_fetch(&limit, &limitClause, 0, 0)) { - if (Z_TYPE_P(&limit) == IS_LONG) { - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limit); - } - ZEPHIR_OBS_VAR(&offset); - if (zephir_array_isset_long_fetch(&offset, &limitClause, 1, 0)) { - if (Z_TYPE_P(&offset) == IS_LONG) { - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &offset); - } - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limitClause); - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limitClause); - } - } - if (zephir_array_isset_string_fetch(&offsetClause, params, SL("offset"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &offsetClause); - } - if (zephir_array_isset_string_fetch(&forUpdate, params, SL("for_update"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &forUpdate); - } - if (zephir_array_isset_string_fetch(&sharedLock, params, SL("shared_lock"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &sharedLock); - } - } else { - _7$$38 = Z_TYPE_P(params) == IS_STRING; - if (_7$$38) { - _7$$38 = !ZEPHIR_IS_STRING_IDENTICAL(params, ""); - } - if (_7$$38) { - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), params); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("inTransaction"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "There is an active transaction", "phalcon/Logger/Adapter/AbstractAdapter.zep", 64); + return; } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "close", NULL, 0); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, addFrom) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __serialize) +{ + zval *this_ptr = getThis(); + + + + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_logger_exception_ce, "This object cannot be serialized", "phalcon/Logger/Adapter/AbstractAdapter.zep", 75); + return; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __unserialize) { - zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *alias_param = NULL, models, currentModel, _0, _1$$4; - zval model, alias; + zval *data_param = NULL; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(¤tModel); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&data); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(alias) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &model_param, &alias_param); - zephir_get_strval(&model, model_param); - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_arrval(&data, data_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - if (Z_TYPE_P(&models) != IS_ARRAY) { - if (Z_TYPE_P(&models) != IS_NULL) { - ZEPHIR_CPY_WRT(¤tModel, &models); - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, ¤tModel); - ZEPHIR_CPY_WRT(&models, &_1$$4); - } else { - ZEPHIR_INIT_NVAR(&models); - array_init(&models); - } - } - _2 = 1 == 1; - if (_2) { - _2 = !ZEPHIR_IS_NULL(&alias); - } - if (_2) { - zephir_array_update_zval(&models, &alias, &model, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&models, &model, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 344); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - RETURN_THIS(); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "This object cannot be unserialized", "phalcon/Logger/Adapter/AbstractAdapter.zep", 83); + return; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andHaving) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, add) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; + zval *item, item_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&item_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } + zephir_fetch_params_without_memory_grow(1, 0, &item); - ZEPHIR_OBS_VAR(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("having"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "having", NULL, 0, &conditions, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_array_append(this_ptr, SL("queue"), item); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andWhere) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, begin) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; + zval __$true, __$false; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); + + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$true); } else { - zephir_get_arrval(&bindParams, bindParams_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$false); } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, commit) +{ + zval item, queue, _0, *_1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&queue); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checktransaction", NULL, 67); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("queue"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&queue, &_0); + zephir_is_iterable(&queue, 0, "phalcon/Logger/Adapter/AbstractAdapter.zep", 132); + if (Z_TYPE_P(&queue) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queue), _1) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "process", &_3, 0, &item); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_arrval(&bindTypes, bindTypes_param); + ZEPHIR_CALL_METHOD(NULL, &queue, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &queue, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&item, &queue, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "process", &_3, 0, &item); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &queue, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&item); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resettransaction", NULL, 68); + zephir_check_call_status(); + RETURN_THIS(); +} +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, getFormatter) +{ + zval _0, _1$$3, _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZEPHIR_OBS_VAR(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("formatter"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("defaultFormatter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&_1$$3, &_2$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("formatter"), &_1$$3); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, &bindParams, &bindTypes); + RETURN_MM_MEMBER(getThis(), "formatter"); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, inTransaction) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "inTransaction"); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, process) +{ +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, rollback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checktransaction", NULL, 67); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resettransaction", NULL, 68); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, autoescape) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, setFormatter) +{ + zval *formatter, formatter_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&formatter_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(formatter, phalcon_logger_formatter_formatterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &formatter); + + + zephir_update_property_zval(this_ptr, ZEND_STRL("formatter"), formatter); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, getFormattedItem) { - zend_bool _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *identifier_param = NULL; - zval identifier; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, formatter; zval *this_ptr = getThis(); - ZVAL_UNDEF(&identifier); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&formatter); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(identifier) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &identifier_param); - zephir_get_strval(&identifier, identifier_param); + zephir_fetch_params(1, 1, 0, &item); - _0 = zephir_memnstr_str(&identifier, SL("["), "phalcon/Mvc/Model/Query/Builder.zep", 418); - if (!(_0)) { - _0 = zephir_memnstr_str(&identifier, SL("."), "phalcon/Mvc/Model/Query/Builder.zep", 418); + ZEPHIR_CALL_METHOD(&formatter, this_ptr, "getformatter", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&formatter, "format", NULL, 0, item); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, checkTransaction) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("inTransaction"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_logger_exception_ce, "There is no active transaction", "phalcon/Logger/Adapter/AbstractAdapter.zep", 213); + return; } - _1 = _0; - if (!(_1)) { - _1 = zephir_is_numeric(&identifier); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, resetTransaction) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, __$false, _0; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("queue"), &_0); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$false); } - if (_1) { - RETURN_CTOR(&identifier); + ZEPHIR_MM_RESTORE(); +} + +zend_object *zephir_init_properties_Phalcon_Logger_Adapter_AbstractAdapter(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("queue"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("queue"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_CONCAT_SVS(return_value, "[", &identifier, "]"); - RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenHaving) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_AdapterInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger\\Adapter, AdapterInterface, phalcon, logger_adapter_adapterinterface, phalcon_logger_adapter_adapterinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, add); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, begin); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, close); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, commit); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, getFormatter); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, inTransaction); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, process); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, rollback); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, setFormatter); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Noop) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Noop, phalcon, logger_adapter_noop, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_noop_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Noop, close) +{ + zval *this_ptr = getThis(); + + + + RETURN_BOOL(1); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Noop, process) +{ + zval *item, item_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&item_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &item); + + +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Stream) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Stream, phalcon, logger_adapter_stream, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_stream_method_entry, 0); + + zend_declare_property_string(phalcon_logger_adapter_stream_ce, SL("mode"), "ab", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("options"), ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; + zval options; + zval *name_param = NULL, *options_param = NULL, mode, _0, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&mode); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + zephir_get_strval(&name, name_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_arrval(&options, options_param); } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); + + + if (1 == zephir_array_isset_string(&options, SL("mode"))) { + ZEPHIR_OBS_VAR(&mode); + zephir_array_fetch_string(&mode, &options, SL("mode"), PH_NOISY, "phalcon/Logger/Adapter/Stream.zep", 74); } else { - ZEPHIR_INIT_VAR(&operator); + ZEPHIR_INIT_NVAR(&mode); + ZVAL_STRING(&mode, "ab"); } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "r"); + ZEPHIR_CALL_FUNCTION(&_1, "mb_strpos", NULL, 85, &mode, &_0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter cannot be opened in read mode", "phalcon/Logger/Adapter/Stream.zep", 76); + return; } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("mode"), &mode); + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, close) +{ + zval *this_ptr = getThis(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); - zephir_check_call_status(); - RETURN_MM(); + + + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenWhere) +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, getName) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "name"); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, process) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; + zval *item, item_sub, handler, message, _0, _1, _6, _7, _8, _2$$3, _3$$3, _4$$3, _5$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } + zephir_fetch_params(1, 1, 0, &item); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("mode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&handler, this_ptr, "phpfopen", NULL, 0, &_0, &_1); zephir_check_call_status(); - RETURN_MM(); + if (!(Z_TYPE_P(&handler) == IS_RESOURCE)) { + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, spl_ce_LogicException); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("mode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5$$3); + ZEPHIR_CONCAT_SVSVS(&_5$$3, "The file '", &_3$$3, "' cannot be opened with mode '", &_4$$3, "'"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 408, &_5$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$3, "phalcon/Logger/Adapter/Stream.zep", 119); + ZEPHIR_MM_RESTORE(); + return; + } + ZVAL_LONG(&_6, 2); + ZEPHIR_CALL_FUNCTION(NULL, "flock", NULL, 131, &handler, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getformatteditem", NULL, 0, item); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_8); + ZEPHIR_GET_CONSTANT(&_8, "PHP_EOL"); + ZEPHIR_INIT_VAR(&message); + ZEPHIR_CONCAT_VV(&message, &_7, &_8); + zephir_fwrite(NULL, &handler, &message); + zephir_fclose(&handler); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, columns) +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, phpFopen) { - zval *columns, columns_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *filename_param = NULL, *mode_param = NULL; + zval filename, mode; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns_sub); + ZVAL_UNDEF(&filename); + ZVAL_UNDEF(&mode); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(columns) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(filename) + Z_PARAM_STR(mode) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &columns); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &filename_param, &mode_param); + zephir_get_strval(&filename, filename_param); + zephir_get_strval(&mode, mode_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), columns); - RETURN_THISW(); + ZEPHIR_RETURN_CALL_FUNCTION("fopen", NULL, 139, &filename, &mode); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, distinct) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Syslog) { - zval *distinct, distinct_sub; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Syslog, phalcon, logger_adapter_syslog, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_syslog_method_entry, 0); + + zend_declare_property_long(phalcon_logger_adapter_syslog_ce, SL("facility"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_adapter_syslog_ce, SL("name"), "", ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_logger_adapter_syslog_ce, SL("opened"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_logger_adapter_syslog_ce, SL("option"), 0, ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval options; + zval *name_param = NULL, *options_param = NULL, facility, option; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&distinct_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&facility); + ZVAL_UNDEF(&option); + ZVAL_UNDEF(&options); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(distinct) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &distinct); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } - zephir_update_property_zval(this_ptr, ZEND_STRL("distinct"), distinct); - RETURN_THISW(); + ZEPHIR_OBS_VAR(&facility); + if (!(zephir_array_isset_string_fetch(&facility, &options, SL("facility"), 0))) { + ZEPHIR_INIT_NVAR(&facility); + ZVAL_LONG(&facility, 8); + } + ZEPHIR_OBS_VAR(&option); + if (!(zephir_array_isset_string_fetch(&option, &options, SL("option"), 0))) { + ZEPHIR_INIT_NVAR(&option); + ZVAL_LONG(&option, 4); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("option"), &option); + zephir_update_property_zval(this_ptr, ZEND_STRL("facility"), &facility); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, forUpdate) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, close) { - zval *forUpdate_param = NULL, __$true, __$false; - zend_bool forUpdate; + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("opened"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + RETURN_MM_BOOL(1); + } + ZEPHIR_RETURN_CALL_FUNCTION("closelog", NULL, 409); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, process) +{ + zval _6$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, __$true, __$false, level, message, result, _0, _1, _2, _9, _3$$3, _4$$3, _5$$3, _7$$3, _8$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&item_sub); ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&level); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_6$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(forUpdate) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &forUpdate_param); - forUpdate = zephir_get_boolval(forUpdate_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &item); - if (forUpdate) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); + ZEPHIR_CALL_METHOD(&message, this_ptr, "getformatteditem", NULL, 0, item); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("option"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("facility"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, this_ptr, "openlog", NULL, 0, &_0, &_1, &_2); + zephir_check_call_status(); + if (!zephir_is_true(&result)) { + ZEPHIR_INIT_VAR(&_3$$3); + object_init_ex(&_3$$3, spl_ce_LogicException); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_OBS_VAR(&_5$$3); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("facility"), PH_NOISY_CC); + zephir_cast_to_string(&_6$$3, &_5$$3); + ZEPHIR_INIT_VAR(&_7$$3); + ZVAL_STRING(&_7$$3, "Cannot open syslog for name [%s] and facility [%s]"); + ZEPHIR_CALL_FUNCTION(&_8$$3, "sprintf", NULL, 116, &_7$$3, &_4$$3, &_6$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 408, &_8$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$3, "phalcon/Logger/Adapter/Syslog.zep", 106); + ZEPHIR_MM_RESTORE(); + return; + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("opened"), &__$true); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); + zephir_update_property_zval(this_ptr, ZEND_STRL("opened"), &__$false); } - RETURN_THISW(); + ZEPHIR_CALL_METHOD(&_9, item, "getlevel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&level, this_ptr, "logleveltosyslog", NULL, 410, &_9); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "syslog", NULL, 411, &level, &message); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, from) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, openlog) { - zval *models, models_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long option, facility, ZEPHIR_LAST_CALL_STATUS; + zval *ident_param = NULL, *option_param = NULL, *facility_param = NULL, _0, _1; + zval ident; zval *this_ptr = getThis(); - ZVAL_UNDEF(&models_sub); + ZVAL_UNDEF(&ident); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(models) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(ident) + Z_PARAM_LONG(option) + Z_PARAM_LONG(facility) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &models); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &ident_param, &option_param, &facility_param); + zephir_get_strval(&ident, ident_param); + option = zephir_get_intval(option_param); + facility = zephir_get_intval(facility_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), models); - RETURN_THISW(); + ZVAL_LONG(&_0, option); + ZVAL_LONG(&_1, facility); + ZEPHIR_RETURN_CALL_FUNCTION("openlog", NULL, 412, &ident, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getBindParams) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, logLevelToSyslog) { + zval levels; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *level_param = NULL, result; + zend_long level; zval *this_ptr = getThis(); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&levels); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(level) + ZEND_PARSE_PARAMETERS_END(); +#endif - RETURN_MEMBER(getThis(), "bindParams"); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &level_param); + level = zephir_get_intval(level_param); + + + ZEPHIR_INIT_VAR(&levels); + zephir_create_array(&levels, 9, 0); + add_index_long(&levels, 2, 1); + add_index_long(&levels, 1, 2); + add_index_long(&levels, 8, 3); + add_index_long(&levels, 7, 7); + add_index_long(&levels, 0, 0); + add_index_long(&levels, 3, 3); + add_index_long(&levels, 6, 6); + add_index_long(&levels, 5, 5); + add_index_long(&levels, 4, 4); + ZEPHIR_OBS_VAR(&result); + if (!(zephir_array_isset_long_fetch(&result, &levels, level, 0))) { + ZEPHIR_INIT_NVAR(&result); + ZVAL_LONG(&result, 3); + } + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getBindTypes) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "bindTypes"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getColumns) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "columns"); + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_AbstractFormatter) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, AbstractFormatter, phalcon, logger_formatter_abstractformatter, phalcon_support_helper_str_abstractstr_ce, phalcon_logger_formatter_abstractformatter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("dateFormat"), "c", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("interpolatorLeft"), "%", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("interpolatorRight"), "%", ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_logger_formatter_abstractformatter_ce, 1, phalcon_logger_formatter_formatterinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDI) +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getDateFormat) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "container"); + RETURN_MEMBER(getThis(), "dateFormat"); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDistinct) +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, setDateFormat) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *format_param = NULL; + zval format; zval *this_ptr = getThis(); + ZVAL_UNDEF(&format); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(format) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &format_param); + zephir_get_strval(&format, format_param); - RETURN_MEMBER(getThis(), "distinct"); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &format); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getFrom) +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getFormattedDate) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, _0, _1; zval *this_ptr = getThis(); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &item); - RETURN_MEMBER(getThis(), "models"); + + ZEPHIR_CALL_METHOD(&_0, item, "getdatetime", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dateFormat"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "format", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getGroupBy) +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getInterpolatedMessage) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval message; + zval *item, item_sub, *message_param = NULL, _0, _1, _2; zval *this_ptr = getThis(); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&message); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &item, &message_param); + zephir_get_strval(&message, message_param); - RETURN_MEMBER(getThis(), "group"); + + ZEPHIR_CALL_METHOD(&_0, item, "getcontext", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tointerpolate", NULL, 0, &message, &_0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getHaving) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "having"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getJoins) + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_FormatterInterface) { - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger\\Formatter, FormatterInterface, phalcon, logger_formatter_formatterinterface, phalcon_logger_formatter_formatterinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Logger_Formatter_FormatterInterface, format); - RETURN_MEMBER(getThis(), "joins"); +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Json) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Json, phalcon, logger_formatter_json, phalcon_logger_formatter_abstractformatter_ce, phalcon_logger_formatter_json_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getLimit) +static PHP_METHOD(Phalcon_Logger_Formatter_Json, __construct) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *dateFormat_param = NULL, *interpolatorLeft_param = NULL, *interpolatorRight_param = NULL; + zval dateFormat, interpolatorLeft, interpolatorRight; zval *this_ptr = getThis(); + ZVAL_UNDEF(&dateFormat); + ZVAL_UNDEF(&interpolatorLeft); + ZVAL_UNDEF(&interpolatorRight); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_STR(dateFormat) + Z_PARAM_STR(interpolatorLeft) + Z_PARAM_STR(interpolatorRight) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 3, &dateFormat_param, &interpolatorLeft_param, &interpolatorRight_param); + if (!dateFormat_param) { + ZEPHIR_INIT_VAR(&dateFormat); + ZVAL_STRING(&dateFormat, "c"); + } else { + zephir_get_strval(&dateFormat, dateFormat_param); + } + if (!interpolatorLeft_param) { + ZEPHIR_INIT_VAR(&interpolatorLeft); + ZVAL_STRING(&interpolatorLeft, "%"); + } else { + zephir_get_strval(&interpolatorLeft, interpolatorLeft_param); + } + if (!interpolatorRight_param) { + ZEPHIR_INIT_VAR(&interpolatorRight); + ZVAL_STRING(&interpolatorRight, "%"); + } else { + zephir_get_strval(&interpolatorRight, interpolatorRight_param); + } - RETURN_MEMBER(getThis(), "limit"); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &dateFormat); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorLeft"), &interpolatorLeft); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorRight"), &interpolatorRight); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getModels) +static PHP_METHOD(Phalcon_Logger_Formatter_Json, format) { - zend_bool _1; - zval models, _0; + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, message, options, _0, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&models); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&options); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &item); - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - _1 = Z_TYPE_P(&models) == IS_ARRAY; - if (_1) { - _1 = zephir_fast_count_int(&models) == 1; - } - if (_1) { - ZEPHIR_MAKE_REF(&models); - ZEPHIR_RETURN_CALL_FUNCTION("reset", NULL, 478, &models); - ZEPHIR_UNREF(&models); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_CCTOR(&models); + + ZEPHIR_CALL_METHOD(&_0, item, "getmessage", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&message, this_ptr, "getinterpolatedmessage", NULL, 0, item, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&options); + ZVAL_LONG(&options, (((((1 + 4) + 2) + 8) + 64) + 4194304)); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 3, 0); + ZEPHIR_CALL_METHOD(&_2, item, "getlevelname", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&_1, SL("level"), &_2, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getformatteddate", NULL, 0, item); + zephir_check_call_status(); + zephir_array_update_string(&_1, SL("timestamp"), &_2, PH_COPY | PH_SEPARATE); + zephir_json_encode(return_value, &_1, zephir_get_intval(&options) ); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOffset) -{ - zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "offset"); +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Line) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Line, phalcon, logger_formatter_line, phalcon_logger_formatter_abstractformatter_ce, phalcon_logger_formatter_line_method_entry, 0); + + zend_declare_property_null(phalcon_logger_formatter_line_ce, SL("format"), ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOrderBy) +static PHP_METHOD(Phalcon_Logger_Formatter_Line, __construct) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *format_param = NULL, *dateFormat_param = NULL, *interpolatorLeft_param = NULL, *interpolatorRight_param = NULL; + zval format, dateFormat, interpolatorLeft, interpolatorRight; zval *this_ptr = getThis(); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&dateFormat); + ZVAL_UNDEF(&interpolatorLeft); + ZVAL_UNDEF(&interpolatorRight); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 4) + Z_PARAM_OPTIONAL + Z_PARAM_STR(format) + Z_PARAM_STR(dateFormat) + Z_PARAM_STR(interpolatorLeft) + Z_PARAM_STR(interpolatorRight) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 4, &format_param, &dateFormat_param, &interpolatorLeft_param, &interpolatorRight_param); + if (!format_param) { + ZEPHIR_INIT_VAR(&format); + ZVAL_STRING(&format, "[%date%][%level%] %message%"); + } else { + zephir_get_strval(&format, format_param); + } + if (!dateFormat_param) { + ZEPHIR_INIT_VAR(&dateFormat); + ZVAL_STRING(&dateFormat, "c"); + } else { + zephir_get_strval(&dateFormat, dateFormat_param); + } + if (!interpolatorLeft_param) { + ZEPHIR_INIT_VAR(&interpolatorLeft); + ZVAL_STRING(&interpolatorLeft, "%"); + } else { + zephir_get_strval(&interpolatorLeft, interpolatorLeft_param); + } + if (!interpolatorRight_param) { + ZEPHIR_INIT_VAR(&interpolatorRight); + ZVAL_STRING(&interpolatorRight, "%"); + } else { + zephir_get_strval(&interpolatorRight, interpolatorRight_param); + } - RETURN_MEMBER(getThis(), "order"); + zephir_update_property_zval(this_ptr, ZEND_STRL("format"), &format); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &dateFormat); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorLeft"), &interpolatorLeft); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorRight"), &interpolatorRight); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getPhql) +static PHP_METHOD(Phalcon_Logger_Formatter_Line, format) { - zend_string *_13$$26, *_22$$35, *_33$$43; - zend_ulong _12$$26, _21$$35, _32$$43; - zval _3$$8; - zend_bool noPrimary = 0, _87$$86; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, container, models, conditions, model, metaData, modelInstance, primaryKeys, firstPrimaryKey, columnMap, modelAlias, attributeField, phql, column, columns, selectedColumns, selectedColumn, selectedModel, selectedModels, columnAlias, modelColumnAlias, joins, join, joinModel, joinConditions, joinAlias, joinType, group, groupItems, groupItem, having, order, orderItems, orderItem, limit, number, offset, forUpdate, distinct, _0, _2$$8, _4$$17, _5$$17, _6$$19, _7$$13, _8$$13, _9$$13, *_10$$26, _11$$26, _18$$26, _14$$29, _15$$29, _16$$32, _17$$32, *_19$$35, _20$$35, _27$$35, _23$$37, _24$$38, _25$$40, _26$$41, _28$$42, _29$$42, *_30$$43, _31$$43, _38$$43, _39$$43, _34$$45, _35$$45, _36$$48, _37$$48, _40$$50, _41$$50, *_42$$51, _43$$51, _44$$53, _45$$53, _46$$54, _47$$54, _48$$55, _49$$55, _50$$56, _51$$58, _52$$58, _53$$59, _54$$59, _55$$60, _56$$60, _57$$61, _58$$63, *_59$$64, _60$$64, _63$$64, _64$$64, _61$$65, _62$$66, _65$$68, *_66$$70, _67$$70, _78$$70, _79$$70, itemExplode$$73, _68$$73, _69$$73, _70$$73, _71$$73, _72$$71, itemExplode$$76, _73$$76, _74$$76, _75$$76, _76$$76, _77$$74, _80$$77, _81$$83, _82$$86, _83$$86, _84$$86, _85$$86, _86$$86, _88$$87, _89$$87, _90$$87, _91$$87, _92$$87; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_1 = NULL; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&modelInstance); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&firstPrimaryKey); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&selectedColumns); - ZVAL_UNDEF(&selectedColumn); - ZVAL_UNDEF(&selectedModel); - ZVAL_UNDEF(&selectedModels); - ZVAL_UNDEF(&columnAlias); - ZVAL_UNDEF(&modelColumnAlias); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&joinModel); - ZVAL_UNDEF(&joinConditions); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&groupItems); - ZVAL_UNDEF(&groupItem); - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&order); - ZVAL_UNDEF(&orderItems); - ZVAL_UNDEF(&orderItem); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&forUpdate); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$8); - ZVAL_UNDEF(&_4$$17); - ZVAL_UNDEF(&_5$$17); - ZVAL_UNDEF(&_6$$19); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$13); - ZVAL_UNDEF(&_9$$13); - ZVAL_UNDEF(&_11$$26); - ZVAL_UNDEF(&_18$$26); - ZVAL_UNDEF(&_14$$29); - ZVAL_UNDEF(&_15$$29); - ZVAL_UNDEF(&_16$$32); - ZVAL_UNDEF(&_17$$32); - ZVAL_UNDEF(&_20$$35); - ZVAL_UNDEF(&_27$$35); - ZVAL_UNDEF(&_23$$37); - ZVAL_UNDEF(&_24$$38); - ZVAL_UNDEF(&_25$$40); - ZVAL_UNDEF(&_26$$41); - ZVAL_UNDEF(&_28$$42); - ZVAL_UNDEF(&_29$$42); - ZVAL_UNDEF(&_31$$43); - ZVAL_UNDEF(&_38$$43); - ZVAL_UNDEF(&_39$$43); - ZVAL_UNDEF(&_34$$45); - ZVAL_UNDEF(&_35$$45); - ZVAL_UNDEF(&_36$$48); - ZVAL_UNDEF(&_37$$48); - ZVAL_UNDEF(&_40$$50); - ZVAL_UNDEF(&_41$$50); - ZVAL_UNDEF(&_43$$51); - ZVAL_UNDEF(&_44$$53); - ZVAL_UNDEF(&_45$$53); - ZVAL_UNDEF(&_46$$54); - ZVAL_UNDEF(&_47$$54); - ZVAL_UNDEF(&_48$$55); - ZVAL_UNDEF(&_49$$55); - ZVAL_UNDEF(&_50$$56); - ZVAL_UNDEF(&_51$$58); - ZVAL_UNDEF(&_52$$58); - ZVAL_UNDEF(&_53$$59); - ZVAL_UNDEF(&_54$$59); - ZVAL_UNDEF(&_55$$60); - ZVAL_UNDEF(&_56$$60); - ZVAL_UNDEF(&_57$$61); - ZVAL_UNDEF(&_58$$63); - ZVAL_UNDEF(&_60$$64); - ZVAL_UNDEF(&_63$$64); - ZVAL_UNDEF(&_64$$64); - ZVAL_UNDEF(&_61$$65); - ZVAL_UNDEF(&_62$$66); - ZVAL_UNDEF(&_65$$68); - ZVAL_UNDEF(&_67$$70); - ZVAL_UNDEF(&_78$$70); - ZVAL_UNDEF(&_79$$70); - ZVAL_UNDEF(&itemExplode$$73); - ZVAL_UNDEF(&_68$$73); - ZVAL_UNDEF(&_69$$73); - ZVAL_UNDEF(&_70$$73); - ZVAL_UNDEF(&_71$$73); - ZVAL_UNDEF(&_72$$71); - ZVAL_UNDEF(&itemExplode$$76); - ZVAL_UNDEF(&_73$$76); - ZVAL_UNDEF(&_74$$76); - ZVAL_UNDEF(&_75$$76); - ZVAL_UNDEF(&_76$$76); - ZVAL_UNDEF(&_77$$74); - ZVAL_UNDEF(&_80$$77); - ZVAL_UNDEF(&_81$$83); - ZVAL_UNDEF(&_82$$86); - ZVAL_UNDEF(&_83$$86); - ZVAL_UNDEF(&_84$$86); - ZVAL_UNDEF(&_85$$86); - ZVAL_UNDEF(&_86$$86); - ZVAL_UNDEF(&_88$$87); - ZVAL_UNDEF(&_89$$87); - ZVAL_UNDEF(&_90$$87); - ZVAL_UNDEF(&_91$$87); - ZVAL_UNDEF(&_92$$87); - ZVAL_UNDEF(&_3$$8); - - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) != IS_OBJECT) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", &_1, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - if (Z_TYPE_P(&models) == IS_ARRAY) { - if (UNEXPECTED(!(zephir_fast_count_int(&models)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/Mvc/Model/Query/Builder.zep", 679); - return; - } - } else { - if (UNEXPECTED(!zephir_is_true(&models))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/Mvc/Model/Query/Builder.zep", 685); - return; - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&conditions, &_0); - if (zephir_is_numeric(&conditions)) { - if (Z_TYPE_P(&models) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&models) > 1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot build the query. Invalid condition", "phalcon/Mvc/Model/Query/Builder.zep", 700); - return; - } - ZEPHIR_OBS_VAR(&model); - zephir_array_fetch_long(&model, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 703); - } else { - ZEPHIR_CPY_WRT(&model, &models); - } - ZEPHIR_INIT_VAR(&_2$$8); - ZVAL_STRING(&_2$$8, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&metaData, &container, "getshared", NULL, 0, &_2$$8); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3$$8); - zephir_create_array(&_3$$8, 2, 0); - zephir_array_fast_append(&_3$$8, &__$null); - zephir_array_fast_append(&_3$$8, &container); - ZEPHIR_INIT_VAR(&modelInstance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&modelInstance, &model, &_3$$8); - zephir_check_call_status(); - noPrimary = 1; - ZEPHIR_CALL_METHOD(&primaryKeys, &metaData, "getprimarykeyattributes", NULL, 0, &modelInstance); - zephir_check_call_status(); - if (zephir_fast_count_int(&primaryKeys)) { - ZEPHIR_OBS_VAR(&firstPrimaryKey); - if (zephir_array_isset_long_fetch(&firstPrimaryKey, &primaryKeys, 0, 0)) { - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &modelInstance); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &firstPrimaryKey, 0)))) { - ZEPHIR_INIT_VAR(&_4$$17); - object_init_ex(&_4$$17, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_5$$17); - ZEPHIR_CONCAT_SVS(&_5$$17, "Column '", &firstPrimaryKey, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_4$$17, "__construct", NULL, 32, &_5$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$17, "phalcon/Mvc/Model/Query/Builder.zep", 739); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &firstPrimaryKey); - } - if (Z_TYPE_P(&conditions) == IS_STRING) { - ZEPHIR_INIT_VAR(&_6$$19); - ZEPHIR_CONCAT_SVS(&_6$$19, "'", &conditions, "'"); - ZEPHIR_CPY_WRT(&conditions, &_6$$19); - } - ZEPHIR_CALL_METHOD(&_7$$13, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8$$13, this_ptr, "autoescape", NULL, 479, &attributeField); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_9$$13); - ZEPHIR_CONCAT_VSVSV(&_9$$13, &_7$$13, ".", &_8$$13, " = ", &conditions); - ZEPHIR_CPY_WRT(&conditions, &_9$$13); - noPrimary = 0; - } - } - if (UNEXPECTED(noPrimary)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Source related to this model does not have a primary key defined", "phalcon/Mvc/Model/Query/Builder.zep", 766); - return; - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("distinct"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&distinct, &_0); - if (((Z_TYPE_P(&distinct) == IS_TRUE || Z_TYPE_P(&distinct) == IS_FALSE) == 1)) { - ZEPHIR_INIT_VAR(&phql); - if (zephir_is_true(&distinct)) { - ZVAL_STRING(&phql, "SELECT DISTINCT "); - } else { - ZVAL_STRING(&phql, "SELECT ALL "); - } - } else { - ZEPHIR_INIT_NVAR(&phql); - ZVAL_STRING(&phql, "SELECT "); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("columns"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columns, &_0); - if (Z_TYPE_P(&columns) != IS_NULL) { - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&selectedColumns); - array_init(&selectedColumns); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query/Builder.zep", 799); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _12$$26, _13$$26, _10$$26) - { - ZEPHIR_INIT_NVAR(&columnAlias); - if (_13$$26 != NULL) { - ZVAL_STR_COPY(&columnAlias, _13$$26); - } else { - ZVAL_LONG(&columnAlias, _12$$26); - } - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _10$$26); - if (Z_TYPE_P(&columnAlias) == IS_LONG) { - zephir_array_append(&selectedColumns, &column, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 793); - } else { - ZEPHIR_CALL_METHOD(&_14$$29, this_ptr, "autoescape", NULL, 479, &columnAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_15$$29); - ZEPHIR_CONCAT_VSV(&_15$$29, &column, " AS ", &_14$$29); - zephir_array_append(&selectedColumns, &_15$$29, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 795); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11$$26, &columns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11$$26)) { - break; - } - ZEPHIR_CALL_METHOD(&columnAlias, &columns, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnAlias) == IS_LONG) { - zephir_array_append(&selectedColumns, &column, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 793); - } else { - ZEPHIR_CALL_METHOD(&_16$$32, this_ptr, "autoescape", NULL, 479, &columnAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_17$$32); - ZEPHIR_CONCAT_VSV(&_17$$32, &column, " AS ", &_16$$32); - zephir_array_append(&selectedColumns, &_17$$32, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 795); - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_NVAR(&columnAlias); - ZEPHIR_INIT_VAR(&_18$$26); - zephir_fast_join_str(&_18$$26, SL(", "), &selectedColumns); - zephir_concat_self(&phql, &_18$$26); - } else { - zephir_concat_self(&phql, &columns); - } - } else { - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&selectedColumns); - array_init(&selectedColumns); - zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query/Builder.zep", 820); - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&models), _21$$35, _22$$35, _19$$35) - { - ZEPHIR_INIT_NVAR(&modelColumnAlias); - if (_22$$35 != NULL) { - ZVAL_STR_COPY(&modelColumnAlias, _22$$35); - } else { - ZVAL_LONG(&modelColumnAlias, _21$$35); - } - ZEPHIR_INIT_NVAR(&model); - ZVAL_COPY(&model, _19$$35); - ZEPHIR_INIT_NVAR(&selectedColumn); - if (Z_TYPE_P(&modelColumnAlias) == IS_LONG) { - ZEPHIR_CALL_METHOD(&_23$$37, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_23$$37, ".*"); - } else { - ZEPHIR_CALL_METHOD(&_24$$38, this_ptr, "autoescape", NULL, 479, &modelColumnAlias); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_24$$38, ".*"); - } - zephir_array_append(&selectedColumns, &selectedColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 817); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20$$35, &models, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20$$35)) { - break; - } - ZEPHIR_CALL_METHOD(&modelColumnAlias, &models, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&model, &models, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&selectedColumn); - if (Z_TYPE_P(&modelColumnAlias) == IS_LONG) { - ZEPHIR_CALL_METHOD(&_25$$40, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_25$$40, ".*"); - } else { - ZEPHIR_CALL_METHOD(&_26$$41, this_ptr, "autoescape", NULL, 479, &modelColumnAlias); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_26$$41, ".*"); - } - zephir_array_append(&selectedColumns, &selectedColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 817); - ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&model); - ZEPHIR_INIT_NVAR(&modelColumnAlias); - ZEPHIR_INIT_VAR(&_27$$35); - zephir_fast_join_str(&_27$$35, SL(", "), &selectedColumns); - zephir_concat_self(&phql, &_27$$35); - } else { - ZEPHIR_CALL_METHOD(&_28$$42, this_ptr, "autoescape", NULL, 479, &models); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_29$$42); - ZEPHIR_CONCAT_VS(&_29$$42, &_28$$42, ".*"); - zephir_concat_self(&phql, &_29$$42); - } - } - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&selectedModels); - array_init(&selectedModels); - zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query/Builder.zep", 842); - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&models), _32$$43, _33$$43, _30$$43) - { - ZEPHIR_INIT_NVAR(&modelAlias); - if (_33$$43 != NULL) { - ZVAL_STR_COPY(&modelAlias, _33$$43); - } else { - ZVAL_LONG(&modelAlias, _32$$43); - } - ZEPHIR_INIT_NVAR(&model); - ZVAL_COPY(&model, _30$$43); - if (Z_TYPE_P(&modelAlias) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_34$$45, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_35$$45, this_ptr, "autoescape", NULL, 479, &modelAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&selectedModel); - ZEPHIR_CONCAT_VSV(&selectedModel, &_34$$45, " AS ", &_35$$45); - } else { - ZEPHIR_CALL_METHOD(&selectedModel, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - } - zephir_array_append(&selectedModels, &selectedModel, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 839); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_31$$43, &models, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_31$$43)) { - break; - } - ZEPHIR_CALL_METHOD(&modelAlias, &models, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&model, &models, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&modelAlias) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_36$$48, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_37$$48, this_ptr, "autoescape", NULL, 479, &modelAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&selectedModel); - ZEPHIR_CONCAT_VSV(&selectedModel, &_36$$48, " AS ", &_37$$48); - } else { - ZEPHIR_CALL_METHOD(&selectedModel, this_ptr, "autoescape", NULL, 479, &model); - zephir_check_call_status(); - } - zephir_array_append(&selectedModels, &selectedModel, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 839); - ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&model); - ZEPHIR_INIT_NVAR(&modelAlias); - ZEPHIR_INIT_VAR(&_38$$43); - zephir_fast_join_str(&_38$$43, SL(", "), &selectedModels); - ZEPHIR_INIT_VAR(&_39$$43); - ZEPHIR_CONCAT_SV(&_39$$43, " FROM ", &_38$$43); - zephir_concat_self(&phql, &_39$$43); - } else { - ZEPHIR_CALL_METHOD(&_40$$50, this_ptr, "autoescape", NULL, 479, &models); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_41$$50); - ZEPHIR_CONCAT_SV(&_41$$50, " FROM ", &_40$$50); - zephir_concat_self(&phql, &_41$$50); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("joins"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&joins, &_0); - if (Z_TYPE_P(&joins) == IS_ARRAY) { - zephir_is_iterable(&joins, 0, "phalcon/Mvc/Model/Query/Builder.zep", 897); - if (Z_TYPE_P(&joins) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joins), _42$$51) - { - ZEPHIR_INIT_NVAR(&join); - ZVAL_COPY(&join, _42$$51); - ZEPHIR_OBS_NVAR(&joinModel); - zephir_array_fetch_long(&joinModel, &join, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 857); - ZEPHIR_OBS_NVAR(&joinConditions); - zephir_array_fetch_long(&joinConditions, &join, 1, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 862); - ZEPHIR_OBS_NVAR(&joinAlias); - zephir_array_fetch_long(&joinAlias, &join, 2, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 867); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch_long(&joinType, &join, 3, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 872); - if (zephir_is_true(&joinType)) { - ZEPHIR_CALL_METHOD(&_44$$53, this_ptr, "autoescape", NULL, 479, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_45$$53); - ZEPHIR_CONCAT_SVSV(&_45$$53, " ", &joinType, " JOIN ", &_44$$53); - zephir_concat_self(&phql, &_45$$53); - } else { - ZEPHIR_CALL_METHOD(&_46$$54, this_ptr, "autoescape", NULL, 479, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_47$$54); - ZEPHIR_CONCAT_SV(&_47$$54, " JOIN ", &_46$$54); - zephir_concat_self(&phql, &_47$$54); - } - if (zephir_is_true(&joinAlias)) { - ZEPHIR_CALL_METHOD(&_48$$55, this_ptr, "autoescape", NULL, 479, &joinAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_49$$55); - ZEPHIR_CONCAT_SV(&_49$$55, " AS ", &_48$$55); - zephir_concat_self(&phql, &_49$$55); - } - if (zephir_is_true(&joinConditions)) { - ZEPHIR_INIT_NVAR(&_50$$56); - ZEPHIR_CONCAT_SV(&_50$$56, " ON ", &joinConditions); - zephir_concat_self(&phql, &_50$$56); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joins, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_43$$51, &joins, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_43$$51)) { - break; - } - ZEPHIR_CALL_METHOD(&join, &joins, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinModel); - zephir_array_fetch_long(&joinModel, &join, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 857); - ZEPHIR_OBS_NVAR(&joinConditions); - zephir_array_fetch_long(&joinConditions, &join, 1, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 862); - ZEPHIR_OBS_NVAR(&joinAlias); - zephir_array_fetch_long(&joinAlias, &join, 2, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 867); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch_long(&joinType, &join, 3, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 872); - if (zephir_is_true(&joinType)) { - ZEPHIR_CALL_METHOD(&_51$$58, this_ptr, "autoescape", NULL, 479, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_52$$58); - ZEPHIR_CONCAT_SVSV(&_52$$58, " ", &joinType, " JOIN ", &_51$$58); - zephir_concat_self(&phql, &_52$$58); - } else { - ZEPHIR_CALL_METHOD(&_53$$59, this_ptr, "autoescape", NULL, 479, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_54$$59); - ZEPHIR_CONCAT_SV(&_54$$59, " JOIN ", &_53$$59); - zephir_concat_self(&phql, &_54$$59); - } - if (zephir_is_true(&joinAlias)) { - ZEPHIR_CALL_METHOD(&_55$$60, this_ptr, "autoescape", NULL, 479, &joinAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_56$$60); - ZEPHIR_CONCAT_SV(&_56$$60, " AS ", &_55$$60); - zephir_concat_self(&phql, &_56$$60); - } - if (zephir_is_true(&joinConditions)) { - ZEPHIR_INIT_NVAR(&_57$$61); - ZEPHIR_CONCAT_SV(&_57$$61, " ON ", &joinConditions); - zephir_concat_self(&phql, &_57$$61); - } - ZEPHIR_CALL_METHOD(NULL, &joins, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&join); - } - if (Z_TYPE_P(&conditions) == IS_STRING) { - if (!(ZEPHIR_IS_EMPTY(&conditions))) { - ZEPHIR_INIT_VAR(&_58$$63); - ZEPHIR_CONCAT_SV(&_58$$63, " WHERE ", &conditions); - zephir_concat_self(&phql, &_58$$63); - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("group"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&group, &_0); - if (!(ZEPHIR_IS_EMPTY(&group))) { - ZEPHIR_INIT_VAR(&groupItems); - array_init(&groupItems); - zephir_is_iterable(&group, 0, "phalcon/Mvc/Model/Query/Builder.zep", 917); - if (Z_TYPE_P(&group) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&group), _59$$64) - { - ZEPHIR_INIT_NVAR(&groupItem); - ZVAL_COPY(&groupItem, _59$$64); - ZEPHIR_CALL_METHOD(&_61$$65, this_ptr, "autoescape", NULL, 479, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupItems, &_61$$65, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 914); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &group, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_60$$64, &group, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_60$$64)) { - break; - } - ZEPHIR_CALL_METHOD(&groupItem, &group, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_62$$66, this_ptr, "autoescape", NULL, 479, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupItems, &_62$$66, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 914); - ZEPHIR_CALL_METHOD(NULL, &group, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&groupItem); - ZEPHIR_INIT_VAR(&_63$$64); - zephir_fast_join_str(&_63$$64, SL(", "), &groupItems); - ZEPHIR_INIT_VAR(&_64$$64); - ZEPHIR_CONCAT_SV(&_64$$64, " GROUP BY ", &_63$$64); - zephir_concat_self(&phql, &_64$$64); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("having"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&having, &_0); - if (Z_TYPE_P(&having) != IS_NULL) { - if (!(ZEPHIR_IS_EMPTY(&having))) { - ZEPHIR_INIT_VAR(&_65$$68); - ZEPHIR_CONCAT_SV(&_65$$68, " HAVING ", &having); - zephir_concat_self(&phql, &_65$$68); - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("order"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&order, &_0); - if (Z_TYPE_P(&order) != IS_NULL) { - if (Z_TYPE_P(&order) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&orderItems); - array_init(&orderItems); - zephir_is_iterable(&order, 0, "phalcon/Mvc/Model/Query/Builder.zep", 961); - if (Z_TYPE_P(&order) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&order), _66$$70) - { - ZEPHIR_INIT_NVAR(&orderItem); - ZVAL_COPY(&orderItem, _66$$70); - if (Z_TYPE_P(&orderItem) == IS_LONG) { - zephir_array_append(&orderItems, &orderItem, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 944); - continue; - } - if (zephir_memnstr_str(&orderItem, SL(" "), "phalcon/Mvc/Model/Query/Builder.zep", 949) != 0) { - ZEPHIR_INIT_NVAR(&itemExplode$$73); - zephir_fast_explode_str(&itemExplode$$73, SL(" "), &orderItem, LONG_MAX); - zephir_array_fetch_long(&_69$$73, &itemExplode$$73, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 953); - ZEPHIR_CALL_METHOD(&_68$$73, this_ptr, "autoescape", NULL, 479, &_69$$73); - zephir_check_call_status(); - zephir_array_fetch_long(&_70$$73, &itemExplode$$73, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 953); - ZEPHIR_INIT_NVAR(&_71$$73); - ZEPHIR_CONCAT_VSV(&_71$$73, &_68$$73, " ", &_70$$73); - zephir_array_append(&orderItems, &_71$$73, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 953); - continue; - } - ZEPHIR_CALL_METHOD(&_72$$71, this_ptr, "autoescape", NULL, 479, &orderItem); - zephir_check_call_status(); - zephir_array_append(&orderItems, &_72$$71, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 958); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &order, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_67$$70, &order, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_67$$70)) { - break; - } - ZEPHIR_CALL_METHOD(&orderItem, &order, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&orderItem) == IS_LONG) { - zephir_array_append(&orderItems, &orderItem, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 944); - continue; - } - if (zephir_memnstr_str(&orderItem, SL(" "), "phalcon/Mvc/Model/Query/Builder.zep", 949) != 0) { - ZEPHIR_INIT_NVAR(&itemExplode$$76); - zephir_fast_explode_str(&itemExplode$$76, SL(" "), &orderItem, LONG_MAX); - zephir_array_fetch_long(&_74$$76, &itemExplode$$76, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 953); - ZEPHIR_CALL_METHOD(&_73$$76, this_ptr, "autoescape", NULL, 479, &_74$$76); - zephir_check_call_status(); - zephir_array_fetch_long(&_75$$76, &itemExplode$$76, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 953); - ZEPHIR_INIT_NVAR(&_76$$76); - ZEPHIR_CONCAT_VSV(&_76$$76, &_73$$76, " ", &_75$$76); - zephir_array_append(&orderItems, &_76$$76, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 953); - continue; - } - ZEPHIR_CALL_METHOD(&_77$$74, this_ptr, "autoescape", NULL, 479, &orderItem); - zephir_check_call_status(); - zephir_array_append(&orderItems, &_77$$74, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 958); - ZEPHIR_CALL_METHOD(NULL, &order, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&orderItem); - ZEPHIR_INIT_VAR(&_78$$70); - zephir_fast_join_str(&_78$$70, SL(", "), &orderItems); - ZEPHIR_INIT_VAR(&_79$$70); - ZEPHIR_CONCAT_SV(&_79$$70, " ORDER BY ", &_78$$70); - zephir_concat_self(&phql, &_79$$70); - } else { - ZEPHIR_INIT_VAR(&_80$$77); - ZEPHIR_CONCAT_SV(&_80$$77, " ORDER BY ", &order); - zephir_concat_self(&phql, &_80$$77); - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("limit"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&limit, &_0); - if (Z_TYPE_P(&limit) != IS_NULL) { - ZEPHIR_INIT_VAR(&number); - ZVAL_NULL(&number); - if (Z_TYPE_P(&limit) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&number); - zephir_array_fetch_string(&number, &limit, SL("number"), PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 975); - ZEPHIR_OBS_VAR(&offset); - if (zephir_array_isset_string_fetch(&offset, &limit, SL("offset"), 0)) { - if (!(zephir_is_numeric(&offset))) { - ZEPHIR_INIT_NVAR(&offset); - ZVAL_LONG(&offset, 0); - } - } - } else { - if (zephir_is_numeric(&limit)) { - ZEPHIR_CPY_WRT(&number, &limit); - zephir_read_property(&_81$$83, this_ptr, ZEND_STRL("offset"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&offset, &_81$$83); - if (Z_TYPE_P(&offset) != IS_NULL) { - if (!(zephir_is_numeric(&offset))) { - ZEPHIR_INIT_NVAR(&offset); - ZVAL_LONG(&offset, 0); - } - } - } - } - if (zephir_is_numeric(&number)) { - zephir_concat_self_str(&phql, SL(" LIMIT :APL0:")); - ZVAL_LONG(&_82$$86, 10); - ZEPHIR_CALL_FUNCTION(&_83$$86, "intval", NULL, 41, &number, &_82$$86); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_84$$86); - ZVAL_STRING(&_84$$86, "APL0"); - zephir_update_property_array(this_ptr, SL("bindParams"), &_84$$86, &_83$$86); - ZEPHIR_INIT_VAR(&_85$$86); - ZVAL_STRING(&_85$$86, "APL0"); - ZEPHIR_INIT_VAR(&_86$$86); - ZVAL_LONG(&_86$$86, 1); - zephir_update_property_array(this_ptr, SL("bindTypes"), &_85$$86, &_86$$86); - _87$$86 = zephir_is_numeric(&offset); - if (_87$$86) { - _87$$86 = !ZEPHIR_IS_LONG_IDENTICAL(&offset, 0); - } - if (_87$$86) { - zephir_concat_self_str(&phql, SL(" OFFSET :APL1:")); - ZVAL_LONG(&_88$$87, 10); - ZEPHIR_CALL_FUNCTION(&_89$$87, "intval", NULL, 41, &offset, &_88$$87); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_90$$87); - ZVAL_STRING(&_90$$87, "APL1"); - zephir_update_property_array(this_ptr, SL("bindParams"), &_90$$87, &_89$$87); - ZEPHIR_INIT_VAR(&_91$$87); - ZVAL_STRING(&_91$$87, "APL1"); - ZEPHIR_INIT_VAR(&_92$$87); - ZVAL_LONG(&_92$$87, 1); - zephir_update_property_array(this_ptr, SL("bindTypes"), &_91$$87, &_92$$87); - } - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("forUpdate"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&forUpdate, &_0); - if (((Z_TYPE_P(&forUpdate) == IS_TRUE || Z_TYPE_P(&forUpdate) == IS_FALSE) == 1)) { - if (zephir_is_true(&forUpdate)) { - zephir_concat_self_str(&phql, SL(" FOR UPDATE")); - } - } - RETURN_CCTOR(&phql); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getQuery) -{ - zval _2; - zval query, bindParams, bindTypes, phql, container, _0, _1, _3, _4, _5$$6; + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, message, _0, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; zval *this_ptr = getThis(); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&container); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &item); + - ZEPHIR_CALL_METHOD(&phql, this_ptr, "getphql", NULL, 480); + zephir_read_property(&_0, this_ptr, ZEND_STRL("format"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 3, 0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VSV(&_4, &_2, "date", &_3); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getformatteddate", NULL, 0, item); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Query/Builder.zep", 1032); - return; - } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, &phql); - zephir_array_fast_append(&_2, &container); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query"); - ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); + zephir_array_update_zval(&_1, &_4, &_5, PH_COPY); + zephir_read_property(&_6, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_7, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_8); + ZEPHIR_CONCAT_VSV(&_8, &_6, "level", &_7); + ZEPHIR_CALL_METHOD(&_5, item, "getlevelname", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&bindParams, &_0); - if (Z_TYPE_P(&bindParams) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, &bindParams); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&bindTypes, &_0); - if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, &bindTypes); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&_4); - zephir_read_property(&_4, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC); - if (((Z_TYPE_P(&_4) == IS_TRUE || Z_TYPE_P(&_4) == IS_FALSE) == 1)) { - zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &query, "setsharedlock", NULL, 0, &_5$$6); - zephir_check_call_status(); - } - RETURN_CCTOR(&query); + zephir_array_update_zval(&_1, &_8, &_5, PH_COPY); + zephir_read_property(&_9, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_10, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_11); + ZEPHIR_CONCAT_VSV(&_11, &_9, "message", &_10); + ZEPHIR_CALL_METHOD(&_5, item, "getmessage", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&_1, &_11, &_5, PH_COPY); + ZEPHIR_CALL_FUNCTION(&message, "strtr", NULL, 5, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getinterpolatedmessage", NULL, 0, item, &message); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getWhere) +static PHP_METHOD(Phalcon_Logger_Formatter_Line, getFormat) { zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "conditions"); + RETURN_MEMBER(getThis(), "format"); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, groupBy) +static PHP_METHOD(Phalcon_Logger_Formatter_Line, setFormat) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *group = NULL, group_sub, _0$$4, _1$$4, _2$$4, _3$$3; + zval *format_param = NULL; + zval format; zval *this_ptr = getThis(); - ZVAL_UNDEF(&group_sub); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&format); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(group) + Z_PARAM_STR(format) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &group); - ZEPHIR_SEPARATE_PARAM(group); + zephir_fetch_params(1, 1, 0, &format_param); + zephir_get_strval(&format, format_param); - if (Z_TYPE_P(group) == IS_STRING) { - if (zephir_memnstr_str(group, SL(","), "phalcon/Mvc/Model/Query/Builder.zep", 1088)) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, " "); - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, ""); - zephir_fast_str_replace(&_0$$4, &_1$$4, &_2$$4, group); - ZEPHIR_CPY_WRT(group, &_0$$4); - } - ZEPHIR_INIT_VAR(&_3$$3); - zephir_fast_explode_str(&_3$$3, SL(","), group, LONG_MAX); - ZEPHIR_CPY_WRT(group, &_3$$3); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("group"), group); + zephir_update_property_zval(this_ptr, ZEND_STRL("format"), &format); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, having) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentBindParams, currentBindTypes, _0$$3, _1$$5; - zval conditions; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); + + +#ifdef HAVE_CONFIG_H #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - zephir_get_strval(&conditions, conditions_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("having"), &conditions); - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_add_function(&_0$$3, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$5); - zephir_add_function(&_1$$5, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1$$5); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - RETURN_THIS(); + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption, Crypt, phalcon, encryption_crypt, phalcon_encryption_crypt_method_entry, 0); + + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("authData"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("authTag"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_crypt_ce, SL("authTagLength"), 16, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_crypt_ce, SL("availableCiphers"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("cipher"), "aes-256-cfb", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("hashAlgorithm"), "sha256", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_crypt_ce, SL("ivLength"), 16, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("key"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_crypt_ce, SL("padding"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_crypt_ce, SL("padFactory"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_encryption_crypt_ce, SL("useSigning"), 1, ZEND_ACC_PROTECTED); + phalcon_encryption_crypt_ce->create_object = zephir_init_properties_Phalcon_Encryption_Crypt; + zephir_declare_class_constant_string(phalcon_encryption_crypt_ce, SL("DEFAULT_ALGORITHM"), "sha256"); + + zephir_declare_class_constant_string(phalcon_encryption_crypt_ce, SL("DEFAULT_CIPHER"), "aes-256-cfb"); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ANSI_X_923"), 1); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_DEFAULT"), 0); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ISO_10126"), 3); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ISO_IEC_7816_4"), 4); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_PKCS7"), 2); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_SPACE"), 6); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ZERO"), 5); + + zend_class_implements(phalcon_encryption_crypt_ce, 1, phalcon_encryption_crypt_cryptinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inHaving) +static PHP_METHOD(Phalcon_Encryption_Crypt, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; + zend_bool useSigning; + zval *cipher_param = NULL, *useSigning_param = NULL, *padFactory = NULL, padFactory_sub, __$null, _0, _1, _2, _3; + zval cipher; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&padFactory_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + Z_PARAM_STR(cipher) + Z_PARAM_BOOL(useSigning) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(padFactory, phalcon_encryption_crypt_padfactory_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); + zephir_fetch_params(1, 0, 3, &cipher_param, &useSigning_param, &padFactory); + if (!cipher_param) { + ZEPHIR_INIT_VAR(&cipher); + ZVAL_STRING(&cipher, "aes-256-cfb"); } else { - ZEPHIR_INIT_VAR(&expr); + zephir_get_strval(&cipher, cipher_param); } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); + if (!useSigning_param) { + useSigning = 1; } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); + useSigning = zephir_get_boolval(useSigning_param); } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); + if (!padFactory) { + padFactory = &padFactory_sub; + ZEPHIR_CPY_WRT(padFactory, &__$null); } else { - ZEPHIR_INIT_VAR(&operator); - } + ZEPHIR_SEPARATE_PARAM(padFactory); } + if (Z_TYPE_P(padFactory) == IS_NULL) { + ZEPHIR_INIT_NVAR(padFactory); + object_init_ex(padFactory, phalcon_encryption_crypt_padfactory_ce); + ZEPHIR_CALL_METHOD(NULL, padFactory, "__construct", NULL, 224); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("padFactory"), padFactory); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionin", NULL, 0, &_0, &operator, &expr, &values); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "sha256"); + zephir_update_property_zval(this_ptr, ZEND_STRL("hashAlgorithm"), &_0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "initializeavailableciphers", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_2, &_1, "setcipher", NULL, 0, &cipher); + zephir_check_call_status(); + if (useSigning) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_2, "usesigning", NULL, 0, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, innerJoin) +static PHP_METHOD(Phalcon_Encryption_Crypt, decrypt) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; - zval model, conditions, alias; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *key_param = NULL, __$true, __$null, blockSize, cipher, cipherText, decrypted, decryptKey, digest, hashAlgorithm, hashLength, iv, ivLength, mode, padded, _0, _1, _6, _7, _2$$5, _3$$5, _4$$5, _5$$6, _8$$7; + zval input, key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_BOOL(&__$true, 1); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&blockSize); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&cipherText); + ZVAL_UNDEF(&decrypted); + ZVAL_UNDEF(&decryptKey); + ZVAL_UNDEF(&digest); + ZVAL_UNDEF(&hashAlgorithm); + ZVAL_UNDEF(&hashLength); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&ivLength); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padded); ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_8$$7); +#if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(input) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); + zephir_fetch_params(1, 1, 1, &input_param, &key_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); } else { - zephir_get_strval(&alias, alias_param); + zephir_get_strval(&key, key_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); + ZEPHIR_OBS_VAR(&decryptKey); + zephir_read_property(&decryptKey, this_ptr, ZEND_STRL("key"), PH_NOISY_CC); + if (1 != ZEPHIR_IS_EMPTY(&key)) { + ZEPHIR_CPY_WRT(&decryptKey, &key); + } + if (1 == ZEPHIR_IS_EMPTY(&decryptKey)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Decryption key cannot be empty", "phalcon/Encryption/Crypt.zep", 175); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ivLength, &_0); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "INNER"); - zephir_array_fast_append(&_0, &_1); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); + ZVAL_STRING(&_1, "cipher"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&mode, this_ptr, "getmode", NULL, 225); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&blockSize, this_ptr, "getblocksize", NULL, 226, &mode); + zephir_check_call_status(); + ZVAL_LONG(&_0, 0); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "8bit"); + ZEPHIR_CALL_FUNCTION(&iv, "mb_substr", NULL, 227, &input, &_0, &ivLength, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&digest); + ZVAL_STRING(&digest, ""); + ZEPHIR_CALL_METHOD(&hashAlgorithm, this_ptr, "gethashalgorithm", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_INIT_VAR(&_2$$5); + ZVAL_STRING(&_2$$5, ""); + ZEPHIR_CALL_FUNCTION(&_3$$5, "hash", NULL, 71, &hashAlgorithm, &_2$$5, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&hashLength); + ZVAL_LONG(&hashLength, zephir_fast_strlen_ev(&_3$$5)); + ZEPHIR_INIT_NVAR(&_2$$5); + ZVAL_STRING(&_2$$5, "8bit"); + ZEPHIR_CALL_FUNCTION(&digest, "mb_substr", NULL, 227, &input, &ivLength, &hashLength, &_2$$5); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$5); + zephir_add_function(&_4$$5, &ivLength, &hashLength); + ZEPHIR_INIT_NVAR(&_2$$5); + ZVAL_STRING(&_2$$5, "8bit"); + ZEPHIR_CALL_FUNCTION(&cipherText, "mb_substr", NULL, 227, &input, &_4$$5, &__$null, &_2$$5); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "8bit"); + ZEPHIR_CALL_FUNCTION(&cipherText, "mb_substr", NULL, 227, &input, &ivLength, &__$null, &_5$$6); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&decrypted, this_ptr, "decryptgcmccmauth", NULL, 0, &mode, &cipherText, &decryptKey, &iv); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&padded, &decrypted); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "decryptgetunpadded", NULL, 0, &mode, &blockSize, &decrypted); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&decrypted, &_6); + zephir_read_property(&_7, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_7)) { + ZEPHIR_CALL_FUNCTION(&_8$$7, "hash_hmac", NULL, 228, &hashAlgorithm, &padded, &decryptKey, &__$true); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&digest, &_8$$7)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_mismatch_ce, "Hash does not match.", "phalcon/Encryption/Crypt.zep", 224); + return; + } + } + RETURN_CCTOR(&decrypted); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inWhere) +static PHP_METHOD(Phalcon_Encryption_Crypt, decryptBase64) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; + zend_bool safe; + zval *input_param = NULL, *key_param = NULL, *safe_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5; + zval input, key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(input) Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + Z_PARAM_STR_OR_NULL(key) + Z_PARAM_BOOL(safe) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); + zephir_fetch_params(1, 1, 2, &input_param, &key_param, &safe_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_strval(&key, key_param); } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); + if (!safe_param) { + safe = 0; } else { - ZEPHIR_INIT_VAR(&operator); - } + safe = zephir_get_boolval(safe_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionin", NULL, 0, &_0, &operator, &expr, &values); + if (safe) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "-_"); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "+/"); + ZEPHIR_CALL_FUNCTION(&_2$$3, "strtr", NULL, 5, &input, &_0$$3, &_1$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0$$3); + ZVAL_STRING(&_0$$3, "==="); + ZVAL_DOUBLE(&_3$$3, zephir_safe_mod_long_long(((zephir_fast_strlen_ev(&input) + 3)), 4)); + ZEPHIR_INIT_NVAR(&_1$$3); + zephir_substr(&_1$$3, &_0$$3, zephir_get_intval(&_3$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_VV(&_4$$3, &_2$$3, &_1$$3); + zephir_get_strval(&input, &_4$$3); + } + ZEPHIR_CALL_FUNCTION(&_5, "base64_decode", NULL, 229, &input); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", NULL, 0, &_5, &key); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, join) +static PHP_METHOD(Phalcon_Encryption_Crypt, encrypt) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, *type_param = NULL; - zval model, conditions, alias, type; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *key_param = NULL, __$true, blockSize, cipher, digest, encryptKey, encrypted, iv, ivLength, mode, padded, _0, _1, _2$$6; + zval input, key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&type); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&blockSize); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&digest); + ZVAL_UNDEF(&encryptKey); + ZVAL_UNDEF(&encrypted); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&ivLength); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padded); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(model) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(input) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) - Z_PARAM_STR_OR_NULL(type) + Z_PARAM_STR_OR_NULL(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 3, &model_param, &conditions_param, &alias_param, &type_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + zephir_fetch_params(1, 1, 1, &input_param, &key_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); } else { - ZEPHIR_INIT_VAR(&model); + zephir_get_strval(&key, key_param); } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); + + + ZEPHIR_OBS_VAR(&encryptKey); + zephir_read_property(&encryptKey, this_ptr, ZEND_STRL("key"), PH_NOISY_CC); + if (1 != ZEPHIR_IS_EMPTY(&key)) { + ZEPHIR_CPY_WRT(&encryptKey, &key); } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); + if (1 == ZEPHIR_IS_EMPTY(&encryptKey)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Encryption key cannot be empty", "phalcon/Encryption/Crypt.zep", 282); + return; } - if (!type_param) { - ZEPHIR_INIT_VAR(&type); - } else { - zephir_get_strval(&type, type_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ivLength, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cipher"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&mode, this_ptr, "getmode", NULL, 225); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&blockSize, this_ptr, "getblocksize", NULL, 226, &mode); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&iv, this_ptr, "phpopensslrandompseudobytes", NULL, 0, &ivLength); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&iv)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Cannot calculate Random Pseudo Bytes", "phalcon/Encryption/Crypt.zep", 295); + return; } - - - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - zephir_array_fast_append(&_0, &type); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&padded, this_ptr, "encryptgetpadded", NULL, 0, &mode, &input, &blockSize); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encrypted, this_ptr, "encryptgcmccm", NULL, 0, &mode, &padded, &encryptKey, &iv); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_METHOD(&_2$$6, this_ptr, "gethashalgorithm", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&digest, "hash_hmac", NULL, 228, &_2$$6, &padded, &encryptKey, &__$true); + zephir_check_call_status(); + ZEPHIR_CONCAT_VVV(return_value, &iv, &digest, &encrypted); + RETURN_MM(); + } + ZEPHIR_CONCAT_VV(return_value, &iv, &encrypted); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, leftJoin) +static PHP_METHOD(Phalcon_Encryption_Crypt, encryptBase64) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; - zval model, conditions, alias; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool safe; + zval *input_param = NULL, *key_param = NULL, *safe_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5; + zval input, key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) + Z_PARAM_STR(input) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(key) + Z_PARAM_BOOL(safe) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + zephir_fetch_params(1, 1, 2, &input_param, &key_param, &safe_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); } else { - ZEPHIR_INIT_VAR(&model); + zephir_get_strval(&key, key_param); } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); + if (!safe_param) { + safe = 0; } else { - zephir_get_strval(&conditions, conditions_param); + safe = zephir_get_boolval(safe_param); } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); + + + if (safe) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "encrypt", NULL, 0, &input, &key); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1$$3, "base64_encode", NULL, 230, &_0$$3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "+/"); + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "-_"); + ZEPHIR_CALL_FUNCTION(&_4$$3, "strtr", NULL, 5, &_1$$3, &_2$$3, &_3$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2$$3); + ZVAL_STRING(&_2$$3, "="); + zephir_fast_trim(return_value, &_4$$3, &_2$$3, ZEPHIR_TRIM_RIGHT); + RETURN_MM(); } + ZEPHIR_CALL_METHOD(&_5, this_ptr, "encrypt", NULL, 0, &input, &key); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 230, &_5); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Encryption_Crypt, getAvailableCiphers) +{ + zval *this_ptr = getThis(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "LEFT"); - zephir_array_fast_append(&_0, &_1); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); + + + RETURN_MEMBER(getThis(), "availableCiphers"); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, limit) +static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthData) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *limit_param = NULL, *offset = NULL, offset_sub, __$null, _0, _1, _2$$4, _3$$4; - zend_long limit, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&offset_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_LONG(limit) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(offset) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &limit_param, &offset); - limit = zephir_get_intval(limit_param); - if (!offset) { - offset = &offset_sub; - offset = &__$null; - } + RETURN_MEMBER(getThis(), "authData"); +} +static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthTag) +{ + zval *this_ptr = getThis(); - ZVAL_LONG(&_0, limit); - ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 283, &_0); - zephir_check_call_status(); - limit = zephir_get_numberval(&_1); - if (UNEXPECTED(limit == 0)) { - RETURN_THIS(); - } - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, limit); - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &_0); - if (zephir_is_numeric(offset)) { - ZVAL_LONG(&_2$$4, zephir_get_intval(offset)); - ZEPHIR_CALL_FUNCTION(&_3$$4, "abs", NULL, 283, &_2$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &_3$$4); - } - RETURN_THIS(); + + + RETURN_MEMBER(getThis(), "authTag"); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenHaving) +static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthTagLength) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "authTagLength"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getAvailableHashAlgorithms) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); -#endif + ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "hash_hmac_algos"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac_algos", NULL, 231); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_FUNCTION("hash_algos", NULL, 232); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenWhere) +static PHP_METHOD(Phalcon_Encryption_Crypt, getHashAlgorithm) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&_0); -#if PHP_VERSION_ID >= 80000 - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); -#endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } + RETURN_MEMBER(getThis(), "hashAlgorithm"); +} +static PHP_METHOD(Phalcon_Encryption_Crypt, getCipher) +{ + zval *this_ptr = getThis(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); - zephir_check_call_status(); - RETURN_MM(); + + + RETURN_MEMBER(getThis(), "cipher"); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInHaving) +static PHP_METHOD(Phalcon_Encryption_Crypt, getKey) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "key"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, isValidDecryptLength) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; + zval *input_param = NULL, length, _0, _1; + zval input; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } + zephir_fetch_params(1, 1, 0, &input_param); + zephir_get_strval(&input, input_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotin", NULL, 0, &_0, &operator, &expr, &values); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&length, this_ptr, "phpopensslcipherivlength", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&length)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_FUNCTION(&_1, "mb_strlen", NULL, 233, &input); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_LE(&length, &_1)); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInWhere) +static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthData) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; + zval *data_param = NULL; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); + ZVAL_UNDEF(&data); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(data) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_strval(&data, data_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotin", NULL, 0, &_0, &operator, &expr, &values); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("authData"), &data); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, offset) +static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthTag) { - zval *offset_param = NULL, _0; - zend_long offset; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *tag_param = NULL; + zval tag; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&tag); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(offset) + Z_PARAM_STR(tag) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &offset_param); - offset = zephir_get_intval(offset_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &tag_param); + zephir_get_strval(&tag, tag_param); - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, offset); - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &_0); - RETURN_THISW(); + zephir_update_property_zval(this_ptr, ZEND_STRL("authTag"), &tag); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orderBy) +static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthTagLength) { - zval *orderBy, orderBy_sub; + zval *length_param = NULL, _0; + zend_long length; zval *this_ptr = getThis(); - ZVAL_UNDEF(&orderBy_sub); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(orderBy) + Z_PARAM_LONG(length) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &orderBy); + zephir_fetch_params_without_memory_grow(1, 0, &length_param); + length = zephir_get_intval(length_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("order"), orderBy); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, length); + zephir_update_property_zval(this_ptr, ZEND_STRL("authTagLength"), &_0); RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orHaving) +static PHP_METHOD(Phalcon_Encryption_Crypt, setCipher) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; + zval *cipher_param = NULL, _0, _1; + zval cipher; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cipher) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } + zephir_fetch_params(1, 1, 0, &cipher_param); + zephir_get_strval(&cipher, cipher_param); - ZEPHIR_OBS_VAR(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("having"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "having", NULL, 0, &conditions, &bindParams, &bindTypes); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cipher"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getivlength", NULL, 234, &cipher); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("ivLength"), &_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("cipher"), &cipher); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orWhere) +static PHP_METHOD(Phalcon_Encryption_Crypt, setKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; + zval *key_param = NULL; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&key); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); - ZEPHIR_OBS_VAR(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("key"), &key); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, rightJoin) +static PHP_METHOD(Phalcon_Encryption_Crypt, setHashAlgorithm) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; - zval model, conditions, alias; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *hashAlgorithm_param = NULL, _0; + zval hashAlgorithm; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&hashAlgorithm); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(hashAlgorithm) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } + zephir_fetch_params(1, 1, 0, &hashAlgorithm_param); + zephir_get_strval(&hashAlgorithm, hashAlgorithm_param); ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "RIGHT"); - zephir_array_fast_append(&_0, &_1); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); + ZVAL_STRING(&_0, "hash"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &hashAlgorithm, &_0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("hashAlgorithm"), &hashAlgorithm); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setBindParams) +static PHP_METHOD(Phalcon_Encryption_Crypt, setPadding) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindParams_param = NULL, *merge_param = NULL, currentBindParams, _0$$4; - zval bindParams; + zval *scheme_param = NULL, _0; + zend_long scheme; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(scheme) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); - if (!merge_param) { - merge = 0; - } else { - merge = zephir_get_boolval(merge_param); - } + zephir_fetch_params_without_memory_grow(1, 0, &scheme_param); + scheme = zephir_get_intval(scheme_param); - if (merge) { - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - RETURN_THIS(); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, scheme); + zephir_update_property_zval(this_ptr, ZEND_STRL("padding"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setBindTypes) +static PHP_METHOD(Phalcon_Encryption_Crypt, useSigning) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindTypes_param = NULL, *merge_param = NULL, currentBindTypes, _0$$4; - zval bindTypes; + zval *useSigning_param = NULL, __$true, __$false; + zend_bool useSigning; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$4); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindTypes) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(useSigning) ZEND_PARSE_PARAMETERS_END(); #endif - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); - if (!merge_param) { - merge = 0; - } else { - merge = zephir_get_boolval(merge_param); - } + zephir_fetch_params_without_memory_grow(1, 0, &useSigning_param); + useSigning = zephir_get_boolval(useSigning_param); - if (UNEXPECTED(merge)) { - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } + if (useSigning) { + zephir_update_property_zval(this_ptr, ZEND_STRL("useSigning"), &__$true); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + zephir_update_property_zval(this_ptr, ZEND_STRL("useSigning"), &__$false); } - RETURN_THIS(); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setDI) +static PHP_METHOD(Phalcon_Encryption_Crypt, checkCipherHashIsAvailable) { - zval *container, container_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL, *type_param = NULL, available, lower, method, _0, _1$$5, _2$$5, _3$$5; + zval cipher, type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&available); + ZVAL_UNDEF(&lower); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(cipher) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); #endif - zephir_fetch_params_without_memory_grow(1, 0, &container); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &cipher_param, &type_param); + zephir_get_strval(&cipher, cipher_param); + zephir_get_strval(&type, type_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hash"); + ZEPHIR_INIT_VAR(&method); + if (ZEPHIR_IS_IDENTICAL(&_0, &cipher)) { + ZVAL_STRING(&method, "getAvailableHashAlgorithms"); + } else { + ZVAL_STRING(&method, "getAvailableCiphers"); + } + ZEPHIR_CALL_METHOD_ZVAL(&available, this_ptr, &method, NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&lower, "mb_strtolower", NULL, 10, &cipher); + zephir_check_call_status(); + if (1 != zephir_fast_in_array(&lower, &available)) { + ZEPHIR_INIT_VAR(&_1$$5); + object_init_ex(&_1$$5, phalcon_encryption_crypt_exception_exception_ce); + ZEPHIR_INIT_VAR(&_2$$5); + ZVAL_STRING(&_2$$5, "The %s algorithm '%s' is not supported on this system."); + ZEPHIR_CALL_FUNCTION(&_3$$5, "sprintf", NULL, 116, &_2$$5, &type, &cipher); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$5, "__construct", NULL, 32, &_3$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$5, "phalcon/Encryption/Crypt.zep", 608); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, where) +static PHP_METHOD(Phalcon_Encryption_Crypt, cryptPadText) { + zend_bool _4$$3; + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentBindParams, currentBindTypes, _0$$4, _1$$7; - zval conditions; + zend_long blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS, paddingSize = 0; + zval *input_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, padding, service, _0, _2, _9, _10, _3$$3, _5$$3, _6$$3, _7$$3, _8$$3; + zval input, mode; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$7); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(input) + Z_PARAM_STR(mode) + Z_PARAM_LONG(blockSize) + Z_PARAM_LONG(paddingType) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - zephir_get_strval(&conditions, conditions_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } + zephir_fetch_params(1, 4, 0, &input_param, &mode_param, &blockSize_param, &paddingType_param); + zephir_get_strval(&input, input_param); + zephir_get_strval(&mode, mode_param); + blockSize = zephir_get_intval(blockSize_param); + paddingType = zephir_get_intval(paddingType_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); - if (zephir_fast_count_int(&bindParams) > 0) { - ZEPHIR_OBS_VAR(¤tBindParams); - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); + ZEPHIR_INIT_VAR(&padding); + ZVAL_STRING(&padding, ""); + paddingSize = 0; + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 2, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "cbc"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "ecb"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkismode", NULL, 235, &_1, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_FUNCTION(&_3$$3, "mb_strlen", NULL, 233, &input); + zephir_check_call_status(); + paddingSize = (blockSize - zephir_safe_mod_zval_long(&_3$$3, blockSize)); + _4$$3 = paddingSize >= 256; + if (!(_4$$3)) { + _4$$3 = paddingSize < 0; } - } - if (zephir_fast_count_int(&bindTypes) > 0) { - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$7); - zephir_add_function(&_1$$7, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1$$7); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + if (_4$$3) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Padding size cannot be less than 0 or greater than 256", "phalcon/Encryption/Crypt.zep", 641); + return; } + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, paddingType); + ZEPHIR_CALL_METHOD(&service, &_5$$3, "padnumbertoservice", NULL, 0, &_6$$3); + zephir_check_call_status(); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "newinstance", NULL, 0, &service); + zephir_check_call_status(); + ZVAL_LONG(&_8$$3, paddingSize); + ZEPHIR_CALL_METHOD(&padding, &_7$$3, "pad", NULL, 0, &_8$$3); + zephir_check_call_status(); } - RETURN_THIS(); + if (0 == paddingSize) { + RETURN_CTOR(&input); + } + ZVAL_LONG(&_9, 0); + ZVAL_LONG(&_10, paddingSize); + ZEPHIR_INIT_NVAR(&_2); + zephir_substr(&_2, &padding, 0 , zephir_get_intval(&_10), 0); + ZEPHIR_CONCAT_VV(return_value, &input, &_2); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionBetween) +static PHP_METHOD(Phalcon_Encryption_Crypt, cryptUnpadText) { - zval _6; - zend_bool _0; + zval _3; + zend_bool _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, minimumKey, maximumKey, operatorMethod, _5, _1$$3, _2$$3, _3$$3; - zval clause, operator, expr, _4; + zend_long blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, length, paddingSize, service, _2, _4, _5$$3, _6$$3, _7$$3, _8$$3, _9$$6, _10$$6; + zval input, mode; zval *this_ptr = getThis(); - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&paddingSize); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(input) + Z_PARAM_STR(mode) + Z_PARAM_LONG(blockSize) + Z_PARAM_LONG(paddingType) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 5, 0, &clause_param, &operator_param, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } + zephir_fetch_params(1, 4, 0, &input_param, &mode_param, &blockSize_param, &paddingType_param); + zephir_get_strval(&input, input_param); + zephir_get_strval(&mode, mode_param); + blockSize = zephir_get_intval(blockSize_param); + paddingType = zephir_get_intval(paddingType_param); - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); + ZEPHIR_INIT_VAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + _0 = ZEPHIR_GT_LONG(&length, 0); if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); + _0 = (zephir_safe_mod_zval_long(&length, blockSize) == 0); } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 116, &_2$$3, &operator); + _1 = _0; + if (_1) { + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 2, 0); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "cbc"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "ecb"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkismode", NULL, 235, &_3, &mode); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 32, &_3$$3); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } + if (_1) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, paddingType); + ZEPHIR_CALL_METHOD(&service, &_5$$3, "padnumbertoservice", NULL, 0, &_6$$3); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1571); - ZEPHIR_MM_RESTORE(); - return; + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "newinstance", NULL, 0, &service); + zephir_check_call_status(); + ZVAL_LONG(&_8$$3, blockSize); + ZEPHIR_CALL_METHOD(&paddingSize, &_7$$3, "unpad", NULL, 0, &input, &_8$$3); + zephir_check_call_status(); + if (ZEPHIR_GT_LONG(&paddingSize, 0)) { + if (ZEPHIR_LE_LONG(&paddingSize, blockSize)) { + if (ZEPHIR_LT(&paddingSize, &length)) { + ZEPHIR_INIT_VAR(&_9$$6); + zephir_sub_function(&_9$$6, &length, &paddingSize); + ZVAL_LONG(&_10$$6, 0); + zephir_substr(return_value, &input, 0 , zephir_get_intval(&_9$$6), 0); + RETURN_MM(); + } + RETURN_MM_STRING(""); + } + ZEPHIR_INIT_NVAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + } } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - ZEPHIR_OBS_VAR(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&minimumKey); - ZEPHIR_CONCAT_SV(&minimumKey, "AP", &hiddenParam); - ZEPHIR_INIT_VAR(&maximumKey); - ZEPHIR_CONCAT_SV(&maximumKey, "AP", &nextHiddenParam); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_VSVSVS(&_5, &expr, " BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 2, 0); - zephir_array_update_zval(&_6, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_6, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5, &_6); - zephir_check_call_status(); - ZEPHIR_SEPARATE(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); + if (ZEPHIR_IS_LONG_IDENTICAL(&paddingSize, 0)) { + RETURN_CTOR(&input); + } + RETURN_MM_STRING(""); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionIn) +static PHP_METHOD(Phalcon_Encryption_Crypt, decryptGetUnpadded) { - zend_bool _0; + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, hiddenParam = 0; - zval values; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *values_param = NULL, key, queryKey, value, bindKeys, bindParams, operatorMethod, _6, *_7, _8, _13, _14, _15, _1$$3, _2$$3, _3$$3, _9$$5, _11$$6; - zval clause, operator, expr, _4, _5$$4, _10$$5, _12$$6; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *blockSize_param = NULL, decrypted, *decrypted_param = NULL, padding, _0, _2, _3$$3, _4$$3; + zval mode; zval *this_ptr = getThis(); - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&queryKey); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&bindKeys); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&decrypted); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(mode) + Z_PARAM_LONG(blockSize) + Z_PARAM_STR(decrypted) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, &clause_param, &operator_param, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + zephir_fetch_params(1, 3, 0, &mode_param, &blockSize_param, &decrypted_param); + zephir_get_strval(&mode, mode_param); + blockSize = zephir_get_intval(blockSize_param); + zephir_get_strval(&decrypted, decrypted_param); - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 116, &_2$$3, &operator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 32, &_3$$3); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 2, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "cbc"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "ecb"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkismode", NULL, 235, &_1, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&padding, &_3$$3); + ZVAL_LONG(&_3$$3, blockSize); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "cryptunpadtext", NULL, 0, &decrypted, &mode, &_3$$3, &padding); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1619); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_CPY_WRT(&decrypted, &_4$$3); } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - if (!(zephir_fast_count_int(&values))) { - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_CONCAT_VSV(&_5$$4, &expr, " != ", &expr); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5$$4); + RETURN_CCTOR(&decrypted); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, decryptGcmCcmAuth) +{ + zval _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *cipherText_param = NULL, *decryptKey_param = NULL, *iv_param = NULL, authData, authTag, authTagLength, cipher, encrypted, decrypted, _0, _1, _3, _4$$3, _5$$3, _6$$4; + zval mode, cipherText, decryptKey, iv; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&cipherText); + ZVAL_UNDEF(&decryptKey); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&authData); + ZVAL_UNDEF(&authTag); + ZVAL_UNDEF(&authTagLength); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&encrypted); + ZVAL_UNDEF(&decrypted); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(mode) + Z_PARAM_STR(cipherText) + Z_PARAM_STR(decryptKey) + Z_PARAM_STR(iv) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 4, 0, &mode_param, &cipherText_param, &decryptKey_param, &iv_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&cipherText, cipherText_param); + zephir_get_strval(&decryptKey, decryptKey_param); + zephir_get_strval(&iv, iv_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "ccm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "gcm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkismode", NULL, 235, &_2, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authData, &_4$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTagLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authTagLength, &_4$$3); + zephir_negate(&authTagLength); + ZEPHIR_INIT_VAR(&authTag); + zephir_substr(&authTag, &cipherText, zephir_get_intval(&authTagLength), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, ""); + ZEPHIR_INIT_VAR(&encrypted); + zephir_fast_str_replace(&encrypted, &authTag, &_5$$3, &cipherText); + ZVAL_LONG(&_4$$3, 1); + ZEPHIR_CALL_FUNCTION(&decrypted, "openssl_decrypt", NULL, 236, &encrypted, &cipher, &decryptKey, &_4$$3, &iv, &authTag, &authData); zephir_check_call_status(); - RETURN_THIS(); - } - ZEPHIR_OBS_VAR(&_6); - zephir_read_property(&_6, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - hiddenParam = zephir_get_intval(&_6); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query/Builder.zep", 1650); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _7) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _7); - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_LONG(&_9$$5, hiddenParam); - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_SV(&_10$$5, "AP", &_9$$5); - ZEPHIR_CPY_WRT(&key, &_10$$5); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1641); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + ZVAL_LONG(&_6$$4, 1); + ZEPHIR_CALL_FUNCTION(&decrypted, "openssl_decrypt", NULL, 236, &cipherText, &cipher, &decryptKey, &_6$$4, &iv); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_8)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$6); - ZVAL_LONG(&_11$$6, hiddenParam); - ZEPHIR_INIT_NVAR(&_12$$6); - ZEPHIR_CONCAT_SV(&_12$$6, "AP", &_11$$6); - ZEPHIR_CPY_WRT(&key, &_12$$6); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1641); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_13); - zephir_fast_join_str(&_13, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_14); - ZEPHIR_CONCAT_VSVS(&_14, &expr, " IN (", &_13, ")"); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_14, &bindParams); - zephir_check_call_status(); - ZEPHIR_INIT_ZVAL_NREF(_15); - ZVAL_LONG(&_15, hiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &_15); - RETURN_THIS(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&decrypted)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Could not decrypt data", "phalcon/Encryption/Crypt.zep", 782); + return; + } + RETURN_CCTOR(&decrypted); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionNotBetween) +static PHP_METHOD(Phalcon_Encryption_Crypt, encryptGetPadded) { - zval _6; - zend_bool _0; + zval _3; + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, minimumKey, maximumKey, operatorMethod, _5, _1$$3, _2$$3, _3$$3; - zval clause, operator, expr, _4; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *input_param = NULL, *blockSize_param = NULL, _0, _2, _4, _5$$3, _6$$3; + zval mode, input; zval *this_ptr = getThis(); - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(mode) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 5, 0, &clause_param, &operator_param, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } + zephir_fetch_params(1, 3, 0, &mode_param, &input_param, &blockSize_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 116, &_2$$3, &operator); + zephir_read_property(&_0, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); + _1 = !ZEPHIR_IS_LONG_IDENTICAL(&_0, 0); + if (_1) { + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 2, 0); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "cbc"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "ecb"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkismode", NULL, 235, &_3, &mode); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 32, &_3$$3); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } + if (_1) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, blockSize); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "cryptpadtext", NULL, 0, &input, &mode, &_6$$3, &_5$$3); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1673); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM(); } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - ZEPHIR_OBS_VAR(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&minimumKey); - ZEPHIR_CONCAT_SV(&minimumKey, "AP", &hiddenParam); - ZEPHIR_INIT_VAR(&maximumKey); - ZEPHIR_CONCAT_SV(&maximumKey, "AP", &nextHiddenParam); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_VSVSVS(&_5, &expr, " NOT BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 2, 0); - zephir_array_update_zval(&_6, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_6, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5, &_6); - zephir_check_call_status(); - ZEPHIR_SEPARATE(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); + RETURN_CTOR(&input); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionNotIn) +static PHP_METHOD(Phalcon_Encryption_Crypt, encryptGcmCcm) { - zend_bool _0; + zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, hiddenParam = 0; - zval values; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *values_param = NULL, key, queryKey, value, bindKeys, bindParams, operatorMethod, _6, *_7, _8, _13, _14, _15, _1$$3, _2$$3, _3$$3, _9$$5, _11$$6; - zval clause, operator, expr, _4, _5$$4, _10$$5, _12$$6; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *padded_param = NULL, *encryptKey_param = NULL, *iv_param = NULL, authData, authTag, authTagLength, cipher, encrypted, _0, _1, _3, _4$$3, _5$$5; + zval mode, padded, encryptKey, iv; zval *this_ptr = getThis(); - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&queryKey); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&bindKeys); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&values); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padded); + ZVAL_UNDEF(&encryptKey); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&authData); + ZVAL_UNDEF(&authTag); + ZVAL_UNDEF(&authTagLength); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&encrypted); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + Z_PARAM_STR(mode) + Z_PARAM_STR(padded) + Z_PARAM_STR(encryptKey) + Z_PARAM_STR(iv) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, &clause_param, &operator_param, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + zephir_fetch_params(1, 4, 0, &mode_param, &padded_param, &encryptKey_param, &iv_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&padded, padded_param); + zephir_get_strval(&encryptKey, encryptKey_param); + zephir_get_strval(&iv, iv_param); - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 116, &_2$$3, &operator); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + ZEPHIR_INIT_VAR(&authTag); + ZVAL_STRING(&authTag, ""); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "ccm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "gcm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkismode", NULL, 235, &_2, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authData, &_4$$3); + if (1 == ZEPHIR_IS_EMPTY(&authData)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Auth data must be provided when using AEAD mode", "phalcon/Encryption/Crypt.zep", 841); + return; + } + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTag"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authTag, &_4$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTagLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authTagLength, &_4$$3); + ZVAL_LONG(&_4$$3, 1); + ZEPHIR_MAKE_REF(&authTag); + ZEPHIR_CALL_FUNCTION(&encrypted, "openssl_encrypt", NULL, 237, &padded, &cipher, &encryptKey, &_4$$3, &iv, &authTag, &authData, &authTagLength); + ZEPHIR_UNREF(&authTag); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 32, &_3$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("authTag"), &authTag); + } else { + ZVAL_LONG(&_5$$5, 1); + ZEPHIR_CALL_FUNCTION(&encrypted, "openssl_encrypt", NULL, 237, &padded, &cipher, &encryptKey, &_5$$5, &iv); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1720); - ZEPHIR_MM_RESTORE(); + } + if (ZEPHIR_IS_FALSE_IDENTICAL(&encrypted)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Could not encrypt data", "phalcon/Encryption/Crypt.zep", 870); return; } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - if (!(zephir_fast_count_int(&values))) { - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_CONCAT_VSV(&_5$$4, &expr, " != ", &expr); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5$$4); - zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_CONCAT_VV(return_value, &encrypted, &authTag); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, initializeAvailableCiphers) +{ + zend_bool _4$$4, _5$$4, _6$$4, _7$$6, _8$$6, _9$$6; + zval allowed; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, available, cipher, _0, _1, *_2, _3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&available); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&allowed); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "openssl_get_cipher_methods"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "This class requires the openssl extension for PHP", "phalcon/Encryption/Crypt.zep", 892); + return; } - ZEPHIR_OBS_VAR(&_6); - zephir_read_property(&_6, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - hiddenParam = zephir_get_intval(&_6); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query/Builder.zep", 1751); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _7) + ZEPHIR_CALL_FUNCTION(&available, "openssl_get_cipher_methods", NULL, 238, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&allowed); + array_init(&allowed); + zephir_is_iterable(&available, 0, "phalcon/Encryption/Crypt.zep", 909); + if (Z_TYPE_P(&available) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&available), _2) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _7); - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_LONG(&_9$$5, hiddenParam); - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_SV(&_10$$5, "AP", &_9$$5); - ZEPHIR_CPY_WRT(&key, &_10$$5); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1742); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; + ZEPHIR_INIT_NVAR(&cipher); + ZVAL_COPY(&cipher, _2); + _4$$4 = 1 != zephir_start_with_str(&cipher, SL("des")); + if (_4$$4) { + _4$$4 = 1 != zephir_start_with_str(&cipher, SL("rc2")); + } + _5$$4 = _4$$4; + if (_5$$4) { + _5$$4 = 1 != zephir_start_with_str(&cipher, SL("rc4")); + } + _6$$4 = _5$$4; + if (_6$$4) { + _6$$4 = 1 != zephir_end_with_str(&cipher, SL("ecb")); + } + if (_6$$4) { + zephir_array_update_zval(&allowed, &cipher, &cipher, PH_COPY | PH_SEPARATE); + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &available, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_8, &values, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3, &available, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_8)) { + if (!zend_is_true(&_3)) { break; } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&cipher, &available, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$6); - ZVAL_LONG(&_11$$6, hiddenParam); - ZEPHIR_INIT_NVAR(&_12$$6); - ZEPHIR_CONCAT_SV(&_12$$6, "AP", &_11$$6); - ZEPHIR_CPY_WRT(&key, &_12$$6); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1742); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + _7$$6 = 1 != zephir_start_with_str(&cipher, SL("des")); + if (_7$$6) { + _7$$6 = 1 != zephir_start_with_str(&cipher, SL("rc2")); + } + _8$$6 = _7$$6; + if (_8$$6) { + _8$$6 = 1 != zephir_start_with_str(&cipher, SL("rc4")); + } + _9$$6 = _8$$6; + if (_9$$6) { + _9$$6 = 1 != zephir_end_with_str(&cipher, SL("ecb")); + } + if (_9$$6) { + zephir_array_update_zval(&allowed, &cipher, &cipher, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &available, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_13); - zephir_fast_join_str(&_13, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_14); - ZEPHIR_CONCAT_VSVS(&_14, &expr, " NOT IN (", &_13, ")"); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_14, &bindParams); - zephir_check_call_status(); - ZEPHIR_INIT_ZVAL_NREF(_15); - ZVAL_LONG(&_15, hiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &_15); + ZEPHIR_INIT_NVAR(&cipher); + zephir_update_property_zval(this_ptr, ZEND_STRL("availableCiphers"), &allowed); RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query_Builder(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Encryption_Crypt, checkIsMode) { - zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); + zval mode; + zval *modes_param = NULL, *mode_param = NULL; + zval modes; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modes); + ZVAL_UNDEF(&mode); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(modes) + Z_PARAM_STR(mode) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &modes_param, &mode_param); + zephir_get_arrval(&modes, modes_param); + zephir_get_strval(&mode, mode_param); + + + RETURN_MM_BOOL(zephir_fast_in_array(&mode, &modes)); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getBlockSize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, _0, _2, _3, _4; + zval mode, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(mode) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &mode_param); + zephir_get_strval(&mode, mode_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GT_LONG(&_0, 0)) { + RETURN_MM_MEMBER(getThis(), "ivLength"); + } + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "-", &mode); + zephir_read_property(&_2, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, ""); + ZEPHIR_CALL_FUNCTION(&_4, "str_ireplace", NULL, 239, &_1, &_3, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getivlength", NULL, 234, &_4); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getIvLength) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL, length; + zval cipher; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&length); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cipher) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &cipher_param); + zephir_get_strval(&cipher, cipher_param); + + + ZEPHIR_CALL_FUNCTION(&length, "openssl_cipher_iv_length", NULL, 240, &cipher); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&length)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Cannot calculate the initialization vector (IV) length of the cipher", "phalcon/Encryption/Crypt.zep", 962); + return; + } + RETURN_CCTOR(&length); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getMode) +{ + zval position, _0, _1, _2, _3, _4, _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "-"); + ZEPHIR_CALL_FUNCTION(&_2, "strrpos", NULL, 241, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&position); + ZVAL_LONG(&position, zephir_get_intval(&_2)); + zephir_read_property(&_3, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_5, ((zephir_get_numberval(&position) - zephir_fast_strlen_ev(&_4)) + 1)); + ZEPHIR_INIT_NVAR(&_1); + zephir_substr(&_1, &_3, zephir_get_intval(&_5), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 10, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, phpFunctionExists) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + + + RETURN_MM_BOOL((zephir_function_exists(&name) == SUCCESS)); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, phpOpensslCipherIvLength) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL; + zval cipher; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cipher); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cipher) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &cipher_param); + zephir_get_strval(&cipher, cipher_param); + + + ZEPHIR_RETURN_CALL_FUNCTION("openssl_cipher_iv_length", NULL, 240, &cipher); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, phpOpensslRandomPseudoBytes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *length_param = NULL, _0; + zend_long length, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(length) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &length_param); + length = zephir_get_intval(length_param); + + + ZVAL_LONG(&_0, length); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_random_pseudo_bytes", NULL, 242, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +zend_object *zephir_init_properties_Phalcon_Encryption_Crypt(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); ZEPHIR_MM_GROW(); @@ -87485,29 +81111,11 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query_Builder(zend_class_e { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("joins"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("availableCiphers"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("joins"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("group"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("group"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("availableCiphers"), &_1$$3); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -87524,9421 +81132,15210 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query_Builder(zend_class_e -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_BuilderInterface) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, BuilderInterface, phalcon, mvc_model_query_builderinterface, phalcon_mvc_model_query_builderinterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption, Security, phalcon, encryption_security, phalcon_di_abstractinjectionaware_ce, phalcon_encryption_security_method_entry, 0); - zephir_declare_class_constant_string(phalcon_mvc_model_query_builderinterface_ce, SL("OPERATOR_AND"), "and"); + zend_declare_property_long(phalcon_encryption_security_ce, SL("defaultHash"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_security_ce, SL("numberBytes"), 16, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("random"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("requestToken"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("token"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("tokenKey"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_security_ce, SL("tokenKeySessionId"), "$PHALCON/CSRF/KEY$", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_security_ce, SL("tokenValueSessionId"), "$PHALCON/CSRF$", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_security_ce, SL("workFactor"), 10, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("localSession"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_ce, SL("localRequest"), ZEND_ACC_PRIVATE); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_ARGON2I"), 10); - zephir_declare_class_constant_string(phalcon_mvc_model_query_builderinterface_ce, SL("OPERATOR_OR"), "or"); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_ARGON2ID"), 11); - return SUCCESS; -} + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BCRYPT"), 0); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, addFrom); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, andWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, betweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, columns); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, distinct); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, forUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, from); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getColumns); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getDistinct); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getFrom); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getGroupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getHaving); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getJoins); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getLimit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOffset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOrderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getPhql); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, groupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, having); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, innerJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, inWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, join); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, leftJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, limit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getModels); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notBetweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notInWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, offset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, rightJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, setBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, setBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, where); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_DEFAULT"), 0); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH"), 4); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_A"), 5); -#ifdef HAVE_CONFIG_H -#endif + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_X"), 6); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_Y"), 7); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_EXT_DES"), 2); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_MD5"), 3); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_SHA256"), 8); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_SHA512"), 9); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Lang) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Lang, phalcon, mvc_model_query_lang, phalcon_mvc_model_query_lang_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_STD_DES"), 1); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Lang, parsePHQL) +static PHP_METHOD(Phalcon_Encryption_Security, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *phql_param = NULL; - zval phql; + zval *session = NULL, session_sub, *request = NULL, request_sub, __$null, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&session_sub); + ZVAL_UNDEF(&request_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(phql) + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(session, phalcon_session_managerinterface_ce) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(request, phalcon_http_requestinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &phql_param); - if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 0, 2, &session, &request); + if (!session) { + session = &session_sub; + session = &__$null; } - if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { - zephir_get_strval(&phql, phql_param); + if (!request) { + request = &request_sub; + request = &__$null; + } + + + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_encryption_security_random_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("random"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("localRequest"), request); + zephir_update_property_zval(this_ptr, ZEND_STRL("localSession"), session); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, checkHash) +{ + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long maxPassLength, ZEPHIR_LAST_CALL_STATUS; + zval *password_param = NULL, *passwordHash_param = NULL, *maxPassLength_param = NULL; + zval password, passwordHash; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&passwordHash); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(password) + Z_PARAM_STR(passwordHash) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(maxPassLength) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 1, &password_param, &passwordHash_param, &maxPassLength_param); + zephir_get_strval(&password, password_param); + zephir_get_strval(&passwordHash, passwordHash_param); + if (!maxPassLength_param) { + maxPassLength = 0; } else { - ZEPHIR_INIT_VAR(&phql); + maxPassLength = zephir_get_intval(maxPassLength_param); } - ZEPHIR_LAST_CALL_STATUS = phql_parse_phql(return_value, &phql); + _0 = maxPassLength > 0; + if (_0) { + _0 = zephir_fast_strlen_ev(&password) > maxPassLength; + } + if (_0) { + RETURN_MM_BOOL(0); + } + ZEPHIR_RETURN_CALL_FUNCTION("password_verify", NULL, 246, &password, &passwordHash); zephir_check_call_status(); RETURN_MM(); } +static PHP_METHOD(Phalcon_Encryption_Security, checkToken) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool destroyIfValid, _1, _2; + zval *tokenKey_param = NULL, *tokenValue = NULL, tokenValue_sub, *destroyIfValid_param = NULL, __$null, equals, knownToken, userToken, _0; + zval tokenKey; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tokenKey); + ZVAL_UNDEF(&tokenValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&equals); + ZVAL_UNDEF(&knownToken); + ZVAL_UNDEF(&userToken); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(tokenKey) + Z_PARAM_ZVAL_OR_NULL(tokenValue) + Z_PARAM_BOOL(destroyIfValid) + ZEND_PARSE_PARAMETERS_END(); +#endif + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 3, &tokenKey_param, &tokenValue, &destroyIfValid_param); + if (!tokenKey_param) { + ZEPHIR_INIT_VAR(&tokenKey); + } else { + zephir_get_strval(&tokenKey, tokenKey_param); + } + if (!tokenValue) { + tokenValue = &tokenValue_sub; + tokenValue = &__$null; + } + if (!destroyIfValid_param) { + destroyIfValid = 1; + } else { + destroyIfValid = zephir_get_boolval(destroyIfValid_param); + } -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is include which follows the "include" declaration -** in the input file. */ -// 30 "parser.php.lemon" + ZEPHIR_CALL_METHOD(&_0, this_ptr, "processtokenkey", NULL, 247, &tokenKey); + zephir_check_call_status(); + zephir_get_strval(&tokenKey, &_0); + if (!(!(ZEPHIR_IS_EMPTY(&tokenKey)))) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&userToken, this_ptr, "processusertoken", NULL, 248, &tokenKey, tokenValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&knownToken, this_ptr, "getrequesttoken", NULL, 0); + zephir_check_call_status(); + _1 = Z_TYPE_P(&knownToken) == IS_NULL; + if (!(_1)) { + _1 = Z_TYPE_P(&userToken) == IS_NULL; + } + if (_1) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&equals); + ZEPHIR_INIT_NVAR(&equals); + ZVAL_BOOL(&equals, zephir_hash_equals(&knownToken, &userToken)); + _2 = zephir_is_true(&equals); + if (_2) { + _2 = destroyIfValid; + } + if (_2) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "destroytoken", NULL, 0); + zephir_check_call_status(); + } + RETURN_CCTOR(&equals); +} -// 12 "parser.php.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 +static PHP_METHOD(Phalcon_Encryption_Security, computeHmac) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool raw; + zval *data_param = NULL, *key_param = NULL, *algo_param = NULL, *raw_param = NULL, hmac, _0, _1$$3, _2$$3, _3$$3; + zval data, key, algo; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&algo); + ZVAL_UNDEF(&hmac); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(data) + Z_PARAM_STR(key) + Z_PARAM_STR(algo) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(raw) + ZEND_PARSE_PARAMETERS_END(); #endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** PPCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** PPNOCODE is a number of type PPCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** PPFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** PPACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** phql_TOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** PPMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is phql_TOKENTYPE. The entry in the union -** for base tokens is called "pp0". -** PPSTACKDEPTH is the maximum depth of the parser's stack. -** phql_ARG_SDECL A static variable declaration for the %extra_argument -** phql_ARG_PDECL A parameter declaration for the %extra_argument -** phql_ARG_STORE Code to store %extra_argument into pppParser -** phql_ARG_FETCH Code to extract %extra_argument from pppParser -** PPNSTATE the combined number of states. -** PPNRULE the number of rules in the grammar -** PPERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define PPCODETYPE unsigned char -#define PPNOCODE 135 -#define PPACTIONTYPE unsigned short int -#define phql_TOKENTYPE phql_parser_token* -typedef union { - phql_TOKENTYPE pp0; - zval pp202; - int pp269; -} PPMINORTYPE; -#define PPSTACKDEPTH 100 -#define phql_ARG_SDECL phql_parser_status *status; -#define phql_ARG_PDECL ,phql_parser_status *status -#define phql_ARG_FETCH phql_parser_status *status = pppParser->status -#define phql_ARG_STORE pppParser->status = status -#define PPNSTATE 295 -#define PPNRULE 162 -#define PPERRORSYMBOL 80 -#define PPERRSYMDT pp269 -#define PP_NO_ACTION (PPNSTATE+PPNRULE+2) -#define PP_ACCEPT_ACTION (PPNSTATE+PPNRULE+1) -#define PP_ERROR_ACTION (PPNSTATE+PPNRULE) -/* Next are that tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < PPNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** PPNSTATE <= N < PPNSTATE+PPNRULE Reduce by rule N-PPNSTATE. -** -** N == PPNSTATE+PPNRULE A syntax error has occurred. -** -** N == PPNSTATE+PPNRULE+1 The parser accepts its input. -** -** N == PPNSTATE+PPNRULE+2 No such action. Denotes unused -** slots in the pp_action[] table. -** -** The action table is constructed as a single large table named pp_action[]. -** Given state S and lookahead X, the action is computed as -** -** pp_action[ pp_shift_ofst[S] + X ] -** -** If the index value pp_shift_ofst[S]+X is out of range or if the value -** pp_lookahead[pp_shift_ofst[S]+X] is not equal to X or if pp_shift_ofst[S] -** is equal to PP_SHIFT_USE_DFLT, it means that the action is not in the table -** and that pp_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the pp_reduce_ofst[] array is used in place of -** the pp_shift_ofst[] array and PP_REDUCE_USE_DFLT is used in place of -** PP_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** pp_action[] A single table containing all actions. -** pp_lookahead[] A table containing the lookahead for each entry in -** pp_action. Used to detect hash collisions. -** pp_shift_ofst[] For each state, the offset into pp_action for -** shifting terminals. -** pp_reduce_ofst[] For each state, the offset into pp_action for -** shifting non-terminals after a reduce. -** pp_default[] Default action for each state. -*/ -static PPACTIONTYPE pp_action[] = { - /* 0 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, - /* 10 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 20 */ 34, 122, 74, 69, 120, 126, 128, 55, 57, 59, - /* 30 */ 61, 63, 65, 45, 47, 67, 72, 49, 51, 53, - /* 40 */ 41, 39, 43, 37, 34, 122, 74, 69, 19, 20, - /* 50 */ 21, 22, 23, 32, 33, 120, 126, 128, 55, 57, - /* 60 */ 59, 61, 63, 65, 45, 47, 67, 72, 49, 51, - /* 70 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 37, - /* 80 */ 34, 122, 74, 69, 94, 222, 81, 220, 95, 90, - /* 90 */ 111, 211, 113, 114, 213, 156, 79, 188, 89, 120, - /* 100 */ 126, 128, 55, 57, 59, 61, 63, 65, 45, 47, - /* 110 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, - /* 120 */ 122, 74, 69, 55, 57, 59, 61, 63, 65, 45, - /* 130 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 140 */ 34, 122, 74, 69, 132, 249, 120, 126, 128, 55, - /* 150 */ 57, 59, 61, 63, 65, 45, 47, 67, 72, 49, - /* 160 */ 51, 53, 41, 39, 43, 37, 34, 122, 74, 69, - /* 170 */ 41, 39, 43, 37, 34, 122, 74, 69, 142, 7, - /* 180 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, - /* 190 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 200 */ 34, 122, 74, 69, 120, 126, 128, 55, 57, 59, - /* 210 */ 61, 63, 65, 45, 47, 67, 72, 49, 51, 53, - /* 220 */ 41, 39, 43, 37, 34, 122, 74, 69, 45, 47, - /* 230 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, - /* 240 */ 122, 74, 69, 122, 74, 69, 154, 156, 148, 188, - /* 250 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, - /* 260 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 270 */ 34, 122, 74, 69, 170, 242, 158, 35, 95, 99, - /* 280 */ 171, 173, 8, 76, 112, 113, 114, 161, 49, 51, - /* 290 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 83, - /* 300 */ 170, 130, 295, 35, 84, 92, 171, 173, 296, 194, - /* 310 */ 210, 196, 198, 161, 202, 206, 107, 176, 177, 183, - /* 320 */ 184, 185, 135, 139, 145, 100, 151, 130, 432, 124, - /* 330 */ 17, 180, 178, 179, 181, 182, 297, 228, 236, 224, - /* 340 */ 225, 6, 6, 176, 177, 183, 184, 185, 135, 139, - /* 350 */ 145, 115, 151, 164, 164, 298, 94, 180, 178, 179, - /* 360 */ 181, 182, 215, 107, 24, 35, 70, 230, 171, 173, - /* 370 */ 98, 175, 175, 95, 104, 216, 92, 232, 76, 299, - /* 380 */ 123, 226, 234, 92, 160, 160, 119, 186, 186, 130, - /* 390 */ 193, 35, 191, 251, 171, 173, 91, 76, 278, 94, - /* 400 */ 292, 161, 240, 105, 175, 176, 177, 183, 184, 185, - /* 410 */ 135, 139, 145, 103, 151, 130, 82, 160, 9, 180, - /* 420 */ 178, 179, 181, 182, 194, 210, 196, 198, 26, 202, - /* 430 */ 206, 176, 177, 183, 184, 185, 135, 139, 145, 10, - /* 440 */ 151, 164, 31, 153, 190, 180, 178, 179, 181, 182, - /* 450 */ 170, 218, 96, 35, 85, 109, 171, 173, 137, 175, - /* 460 */ 175, 168, 6, 161, 110, 28, 239, 15, 162, 167, - /* 470 */ 168, 102, 160, 160, 165, 186, 11, 130, 217, 35, - /* 480 */ 13, 431, 171, 173, 12, 201, 121, 247, 199, 161, - /* 490 */ 227, 162, 14, 176, 177, 183, 184, 185, 135, 139, - /* 500 */ 145, 27, 151, 130, 175, 175, 16, 180, 178, 179, - /* 510 */ 181, 182, 244, 248, 281, 288, 284, 160, 160, 176, - /* 520 */ 177, 183, 184, 185, 135, 139, 145, 18, 151, 205, - /* 530 */ 254, 262, 203, 180, 178, 179, 181, 182, 67, 72, - /* 540 */ 49, 51, 53, 41, 39, 43, 37, 34, 122, 74, - /* 550 */ 69, 209, 78, 25, 207, 223, 219, 253, 258, 458, - /* 560 */ 1, 2, 3, 4, 5, 6, 133, 29, 168, 107, - /* 570 */ 6, 77, 260, 263, 175, 31, 272, 69, 257, 283, - /* 580 */ 284, 256, 131, 260, 261, 75, 127, 160, 235, 108, - /* 590 */ 175, 273, 267, 175, 86, 261, 109, 289, 94, 30, - /* 600 */ 175, 175, 164, 160, 175, 279, 160, 80, 214, 219, - /* 610 */ 84, 212, 247, 160, 160, 87, 84, 160, 88, 260, - /* 620 */ 175, 238, 107, 287, 93, 97, 36, 175, 107, 101, - /* 630 */ 175, 259, 106, 160, 110, 38, 169, 175, 246, 175, - /* 640 */ 160, 175, 286, 160, 175, 40, 42, 44, 269, 46, - /* 650 */ 160, 386, 160, 175, 160, 48, 50, 160, 116, 125, - /* 660 */ 118, 52, 117, 175, 175, 175, 160, 175, 264, 258, - /* 670 */ 54, 134, 56, 175, 175, 58, 160, 160, 160, 175, - /* 680 */ 160, 60, 62, 136, 64, 76, 160, 160, 175, 268, - /* 690 */ 175, 66, 160, 175, 138, 140, 143, 149, 144, 175, - /* 700 */ 175, 160, 175, 160, 146, 187, 160, 68, 71, 175, - /* 710 */ 276, 73, 160, 160, 129, 160, 141, 147, 150, 152, - /* 720 */ 155, 163, 160, 157, 166, 175, 175, 192, 159, 175, - /* 730 */ 195, 172, 175, 174, 175, 175, 323, 175, 160, 160, - /* 740 */ 189, 175, 160, 231, 197, 160, 175, 160, 160, 175, - /* 750 */ 160, 175, 241, 324, 160, 250, 200, 325, 175, 160, - /* 760 */ 326, 175, 160, 204, 160, 327, 328, 294, 208, 329, - /* 770 */ 175, 160, 84, 175, 160, 330, 331, 221, 229, 245, - /* 780 */ 243, 233, 255, 160, 107, 237, 160, 334, 271, 335, - /* 790 */ 252, 270, 265, 342, 266, 274, 275, 277, 385, 280, - /* 800 */ 282, 285, 290, 291, 348, 293, -}; -static PPCODETYPE pp_lookahead[] = { - /* 0 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 10 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 20 */ 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, - /* 30 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - /* 40 */ 17, 18, 19, 20, 21, 22, 23, 24, 61, 62, - /* 50 */ 63, 64, 65, 54, 55, 1, 2, 3, 4, 5, - /* 60 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - /* 70 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 20, - /* 80 */ 21, 22, 23, 24, 31, 31, 97, 33, 120, 121, - /* 90 */ 101, 102, 103, 104, 26, 72, 28, 74, 45, 1, - /* 100 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - /* 110 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - /* 120 */ 22, 23, 24, 4, 5, 6, 7, 8, 9, 10, - /* 130 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 140 */ 21, 22, 23, 24, 46, 51, 1, 2, 3, 4, - /* 150 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - /* 160 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - /* 170 */ 17, 18, 19, 20, 21, 22, 23, 24, 33, 88, - /* 180 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 190 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 200 */ 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, - /* 210 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - /* 220 */ 17, 18, 19, 20, 21, 22, 23, 24, 10, 11, - /* 230 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - /* 240 */ 22, 23, 24, 22, 23, 24, 71, 72, 69, 74, - /* 250 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 260 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 270 */ 21, 22, 23, 24, 18, 56, 73, 21, 120, 121, - /* 280 */ 24, 25, 89, 27, 102, 103, 104, 31, 14, 15, - /* 290 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 100, - /* 300 */ 18, 45, 0, 21, 105, 26, 24, 25, 0, 34, - /* 310 */ 35, 36, 37, 31, 39, 40, 117, 61, 62, 63, - /* 320 */ 64, 65, 66, 67, 68, 46, 70, 45, 46, 24, - /* 330 */ 26, 75, 76, 77, 78, 79, 0, 83, 83, 29, - /* 340 */ 30, 87, 87, 61, 62, 63, 64, 65, 66, 67, - /* 350 */ 68, 105, 70, 99, 99, 0, 31, 75, 76, 77, - /* 360 */ 78, 79, 18, 117, 60, 21, 12, 13, 24, 25, - /* 370 */ 45, 117, 117, 120, 121, 31, 26, 23, 27, 0, - /* 380 */ 75, 127, 127, 26, 130, 130, 99, 133, 133, 45, - /* 390 */ 31, 21, 33, 42, 24, 25, 46, 27, 47, 31, - /* 400 */ 49, 31, 57, 46, 117, 61, 62, 63, 64, 65, - /* 410 */ 66, 67, 68, 45, 70, 45, 26, 130, 90, 75, - /* 420 */ 76, 77, 78, 79, 34, 35, 36, 37, 52, 39, - /* 430 */ 40, 61, 62, 63, 64, 65, 66, 67, 68, 91, - /* 440 */ 70, 99, 99, 128, 129, 75, 76, 77, 78, 79, - /* 450 */ 18, 18, 31, 21, 33, 32, 24, 25, 83, 117, - /* 460 */ 117, 26, 87, 31, 31, 122, 123, 59, 45, 127, - /* 470 */ 26, 50, 130, 130, 132, 133, 92, 45, 32, 21, - /* 480 */ 58, 46, 24, 25, 93, 35, 99, 99, 38, 31, - /* 490 */ 46, 45, 47, 61, 62, 63, 64, 65, 66, 67, - /* 500 */ 68, 53, 70, 45, 117, 117, 126, 75, 76, 77, - /* 510 */ 78, 79, 124, 125, 115, 116, 117, 130, 130, 61, - /* 520 */ 62, 63, 64, 65, 66, 67, 68, 126, 70, 35, - /* 530 */ 44, 45, 38, 75, 76, 77, 78, 79, 12, 13, - /* 540 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - /* 550 */ 24, 35, 95, 126, 38, 98, 99, 105, 26, 81, - /* 560 */ 82, 83, 84, 85, 86, 87, 83, 26, 26, 117, - /* 570 */ 87, 94, 99, 109, 117, 99, 112, 24, 46, 116, - /* 580 */ 117, 108, 99, 99, 111, 45, 99, 130, 46, 31, - /* 590 */ 117, 113, 108, 117, 31, 111, 32, 119, 31, 123, - /* 600 */ 117, 117, 99, 130, 117, 100, 130, 96, 98, 99, - /* 610 */ 105, 100, 99, 130, 130, 50, 105, 130, 120, 99, - /* 620 */ 117, 99, 117, 99, 120, 50, 99, 117, 117, 120, - /* 630 */ 117, 111, 120, 130, 31, 99, 133, 117, 125, 117, - /* 640 */ 130, 117, 118, 130, 117, 99, 99, 99, 26, 99, - /* 650 */ 130, 0, 130, 117, 130, 99, 99, 130, 106, 75, - /* 660 */ 41, 99, 107, 117, 117, 117, 130, 117, 46, 26, - /* 670 */ 99, 46, 99, 117, 117, 99, 130, 130, 130, 117, - /* 680 */ 130, 99, 99, 45, 99, 27, 130, 130, 117, 46, - /* 690 */ 117, 99, 130, 117, 46, 45, 31, 31, 46, 117, - /* 700 */ 117, 130, 117, 130, 45, 29, 130, 99, 99, 117, - /* 710 */ 59, 99, 130, 130, 99, 130, 99, 99, 46, 99, - /* 720 */ 129, 131, 130, 99, 46, 117, 117, 31, 99, 117, - /* 730 */ 35, 99, 117, 99, 117, 117, 31, 117, 130, 130, - /* 740 */ 99, 117, 130, 99, 35, 130, 117, 130, 130, 117, - /* 750 */ 130, 117, 99, 31, 130, 99, 35, 31, 117, 130, - /* 760 */ 31, 117, 130, 35, 130, 31, 31, 100, 35, 31, - /* 770 */ 117, 130, 105, 117, 130, 31, 31, 31, 46, 26, - /* 780 */ 53, 45, 45, 130, 117, 46, 130, 0, 31, 0, - /* 790 */ 43, 112, 44, 0, 45, 88, 114, 126, 0, 48, - /* 800 */ 26, 4, 88, 114, 0, 28, -}; -#define PP_SHIFT_USE_DFLT (-14) -static short pp_shift_ofst[] = { - /* 0 */ 351, 302, 308, 336, 355, 379, 94, 219, 345, 376, - /* 10 */ 408, 422, -14, 445, -14, -13, 304, -13, -14, -14, - /* 20 */ -14, -14, -14, -14, -13, -14, 448, 458, 541, 458, - /* 30 */ -14, -1, -14, -14, 458, 458, 221, 458, 221, 458, - /* 40 */ 59, 458, 59, 458, 59, 458, 526, 458, 526, 458, - /* 50 */ 153, 458, 153, 458, 153, 458, 218, 458, 218, 458, - /* 60 */ 218, 458, 218, 458, 218, 458, 218, 458, 274, 354, - /* 70 */ 458, 553, 458, 274, 540, 256, 310, 344, 68, 558, - /* 80 */ 390, -14, 558, -14, 421, 563, 565, 53, -14, 567, - /* 90 */ 350, -14, 567, -14, -14, -14, 575, 325, 567, 279, - /* 100 */ -14, -14, 368, 567, 357, -14, -14, -14, 564, 603, - /* 110 */ -14, 275, -14, -14, 558, 359, 619, -14, 458, 249, - /* 120 */ 458, 249, 305, -14, 584, -14, 458, 119, 458, 119, - /* 130 */ 370, 98, -14, 625, -14, 638, 658, 648, -14, 650, - /* 140 */ 458, 145, 665, 652, -14, 659, 458, 179, 666, 672, - /* 150 */ -14, 458, 23, 175, -14, -14, 458, 203, 458, 249, - /* 160 */ -14, 423, 676, 282, 249, 678, -14, 435, 432, -14, - /* 170 */ -14, 458, 553, 458, 553, -14, -14, -14, -14, -14, - /* 180 */ -14, -14, -14, -14, -14, -14, -14, -14, 458, 249, - /* 190 */ -14, 696, -14, -14, 695, 705, 709, 722, 450, 721, - /* 200 */ 726, 729, 494, 728, 734, 735, 516, 733, 738, 744, - /* 210 */ 745, -14, -14, 344, -14, -14, 446, 433, -14, 54, - /* 220 */ 746, -14, -14, -14, -14, -14, 444, -14, 732, -14, - /* 230 */ 458, 553, 736, 256, 542, -14, 739, -14, 221, -14, - /* 240 */ 458, 249, 727, 458, 753, 458, -14, 249, -14, 458, - /* 250 */ 249, 747, 558, 486, 737, 458, 532, 787, 458, -14, - /* 260 */ 249, -14, 757, 622, 748, 749, 458, 643, 789, 757, - /* 270 */ -14, -14, -14, 94, 651, 793, -13, 798, 558, 751, - /* 280 */ 558, 774, 558, -14, 797, 458, -14, 249, -14, 94, - /* 290 */ 651, 804, 777, 558, -14, -}; -#define PP_REDUCE_USE_DFLT (-33) -static short pp_reduce_ofst[] = { - /* 0 */ 478, -33, -33, -33, -33, -33, 91, 193, 328, 348, - /* 10 */ 384, 391, -33, -33, -33, 380, -33, 401, -33, -33, - /* 20 */ -33, -33, -33, -33, 427, -33, -33, 343, -33, 476, - /* 30 */ -33, -33, -33, -33, 522, 527, -33, 536, -33, 546, - /* 40 */ -33, 547, -33, 548, -33, 550, -33, 556, -33, 557, - /* 50 */ -33, 562, -33, 571, -33, 573, -33, 576, -33, 582, - /* 60 */ -33, 583, -33, 585, -33, 592, -33, 608, -33, -33, - /* 70 */ 609, -33, 612, -33, -33, 254, 477, 457, -33, 511, - /* 80 */ -11, -33, 199, -33, -33, -33, -33, 498, -33, -32, - /* 90 */ -33, -33, 504, -33, -33, -33, -33, 509, 158, -33, - /* 100 */ -33, -33, 512, 253, -33, -33, -33, -33, -33, -33, - /* 110 */ -33, 182, -33, -33, 246, 552, 555, -33, 287, -33, - /* 120 */ 387, -33, -33, -33, -33, -33, 487, -33, 615, -33, - /* 130 */ 483, -33, -33, -33, -33, -33, 375, -33, -33, -33, - /* 140 */ 617, -33, -33, -33, -33, -33, 618, -33, -33, -33, - /* 150 */ -33, 620, 315, 591, -33, -33, 624, -33, 629, -33, - /* 160 */ -33, -33, 590, 342, -33, -33, -33, -33, 503, -33, - /* 170 */ -33, 632, -33, 634, -33, -33, -33, -33, -33, -33, - /* 180 */ -33, -33, -33, -33, -33, -33, -33, -33, 641, -33, - /* 190 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - /* 200 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - /* 210 */ -33, -33, -33, 510, -33, -33, -33, -33, -33, -33, - /* 220 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - /* 230 */ 644, -33, -33, 255, -33, -33, -33, -33, -33, -33, - /* 240 */ 653, -33, -33, 388, -33, 513, -33, -33, -33, 656, - /* 250 */ -33, -33, 452, -33, -33, 473, -33, -33, 520, -33, - /* 260 */ -33, -33, 464, -33, -33, -33, 484, -33, -33, 679, - /* 270 */ -33, -33, -33, 707, 682, -33, 671, -33, 505, -33, - /* 280 */ 399, -33, 463, -33, -33, 524, -33, -33, -33, 714, - /* 290 */ 689, -33, -33, 667, -33, -}; -static PPACTIONTYPE pp_default[] = { - /* 0 */ 457, 457, 457, 457, 457, 457, 364, 373, 378, 366, - /* 10 */ 384, 380, 300, 457, 379, 457, 381, 457, 382, 387, - /* 20 */ 388, 389, 390, 391, 457, 383, 457, 457, 365, 457, - /* 30 */ 367, 369, 370, 371, 457, 457, 392, 457, 394, 457, - /* 40 */ 395, 457, 396, 457, 397, 457, 398, 457, 399, 457, - /* 50 */ 400, 457, 401, 457, 402, 457, 403, 457, 404, 457, - /* 60 */ 405, 457, 406, 457, 407, 457, 408, 457, 409, 457, - /* 70 */ 457, 410, 457, 411, 457, 457, 304, 457, 457, 457, - /* 80 */ 315, 301, 457, 312, 352, 457, 350, 457, 353, 457, - /* 90 */ 457, 354, 457, 359, 361, 360, 351, 457, 457, 457, - /* 100 */ 355, 356, 457, 457, 457, 357, 358, 362, 456, 457, - /* 110 */ 455, 314, 316, 318, 457, 322, 333, 319, 457, 332, - /* 120 */ 457, 419, 457, 437, 457, 438, 457, 439, 457, 440, - /* 130 */ 457, 457, 443, 457, 415, 457, 457, 457, 418, 457, - /* 140 */ 457, 457, 457, 457, 420, 457, 457, 457, 457, 457, - /* 150 */ 421, 457, 457, 457, 422, 423, 457, 457, 457, 425, - /* 160 */ 427, 456, 430, 457, 436, 457, 428, 457, 457, 433, - /* 170 */ 435, 457, 441, 457, 442, 444, 445, 446, 447, 448, - /* 180 */ 449, 450, 451, 452, 453, 454, 434, 429, 457, 426, - /* 190 */ 424, 457, 320, 321, 457, 457, 457, 457, 457, 457, - /* 200 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, - /* 210 */ 457, 317, 313, 457, 305, 307, 456, 457, 308, 311, - /* 220 */ 457, 309, 310, 306, 302, 303, 457, 413, 457, 416, - /* 230 */ 457, 412, 457, 457, 457, 414, 457, 417, 393, 368, - /* 240 */ 457, 377, 457, 457, 372, 457, 374, 376, 375, 457, - /* 250 */ 363, 457, 457, 457, 457, 457, 457, 457, 457, 336, - /* 260 */ 338, 337, 457, 457, 457, 457, 457, 457, 457, 457, - /* 270 */ 339, 341, 340, 364, 457, 457, 457, 457, 457, 457, - /* 280 */ 457, 343, 457, 344, 457, 457, 346, 347, 345, 364, - /* 290 */ 457, 457, 457, 457, 349, -}; -#define PP_SZ_ACTTAB (sizeof(pp_action)/sizeof(pp_action[0])) -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammer, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef PPFALLBACK -static const PPCODETYPE ppFallback[] = { -}; -#endif /* PPFALLBACK */ + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 1, &data_param, &key_param, &algo_param, &raw_param); + zephir_get_strval(&data, data_param); + zephir_get_strval(&key, key_param); + zephir_get_strval(&algo, algo_param); + if (!raw_param) { + raw = 0; + } else { + raw = zephir_get_boolval(raw_param); + } -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct ppStackEntry { - int stateno; /* The state-number */ - int major; /* The major token value. This is the code - ** number for the token at this stack level */ - PPMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct ppStackEntry ppStackEntry; -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct ppParser { - int ppidx; /* Index of top element in stack */ - int pperrcnt; /* Shifts left before out of the error */ - phql_ARG_SDECL /* A place to hold %extra_argument */ - ppStackEntry ppstack[PPSTACKDEPTH]; /* The parser's stack */ -}; -typedef struct ppParser ppParser; + ZVAL_BOOL(&_0, (raw ? 1 : 0)); + ZEPHIR_CALL_FUNCTION(&hmac, "hash_hmac", NULL, 228, &algo, &data, &key, &_0); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&hmac))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_encryption_security_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Unknown hashing algorithm: %s"); + ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 116, &_2$$3, &algo); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 32, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Encryption/Security.zep", 219); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_CCTOR(&hmac); +} -#ifndef NDEBUG -static FILE *ppTraceFILE = 0; -static char *ppTracePrompt = 0; -#endif /* NDEBUG */ +static PHP_METHOD(Phalcon_Encryption_Security, destroyToken) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$null, session, _0, _1, _2$$3, _3$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); -#ifndef NDEBUG -static void phql_Trace(FILE *TraceFILE, char *zTracePrompt){ - ppTraceFILE = TraceFILE; - ppTracePrompt = zTracePrompt; - if( ppTraceFILE==0 ) ppTracePrompt = 0; - else if( ppTracePrompt==0 ) ppTraceFILE = 0; + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "session"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + zephir_check_call_status(); + if (UNEXPECTED(zephir_is_true(&session))) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_2$$3); + zephir_check_call_status(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_3$$3); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), &__$null); + zephir_update_property_zval(this_ptr, ZEND_STRL("tokenKey"), &__$null); + zephir_update_property_zval(this_ptr, ZEND_STRL("requestToken"), &__$null); + RETURN_THIS(); } -#endif /* NDEBUG */ -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *ppTokenName[] = { - "$", "AGAINST", "BETWEEN", "BETWEEN_NOT", - "EQUALS", "NOTEQUALS", "LESS", "GREATER", - "GREATEREQUAL", "LESSEQUAL", "AND", "OR", - "LIKE", "ILIKE", "BITWISE_AND", "BITWISE_OR", - "BITWISE_XOR", "DIVIDE", "TIMES", "MOD", - "PLUS", "MINUS", "IS", "IN", - "NOT", "BITWISE_NOT", "COMMA", "SELECT", - "FROM", "DISTINCT", "ALL", "IDENTIFIER", - "DOT", "AS", "INNER", "JOIN", - "CROSS", "LEFT", "OUTER", "RIGHT", - "FULL", "ON", "INSERT", "INTO", - "VALUES", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "UPDATE", - "SET", "DELETE", "WITH", "WHERE", - "ORDER", "BY", "ASC", "DESC", - "GROUP", "HAVING", "FOR", "LIMIT", - "OFFSET", "INTEGER", "HINTEGER", "NPLACEHOLDER", - "SPLACEHOLDER", "BPLACEHOLDER", "EXISTS", "CAST", - "CONVERT", "USING", "CASE", "END", - "WHEN", "THEN", "ELSE", "NULL", - "STRING", "DOUBLE", "TRUE", "FALSE", - "error", "program", "query_language", "select_statement", - "insert_statement", "update_statement", "delete_statement", "select_clause", - "where_clause", "group_clause", "having_clause", "order_clause", - "select_limit_clause", "for_update_clause", "distinct_all", "column_list", - "associated_name_list", "join_list_or_null", "column_item", "expr", - "associated_name", "join_list", "join_item", "join_clause", - "join_type", "aliased_or_qualified_name", "join_associated_name", "join_conditions", - "values_list", "field_list", "value_list", "value_item", - "field_item", "update_clause", "limit_clause", "update_item_list", - "update_item", "qualified_name", "new_value", "delete_clause", - "with_item", "with_list", "order_list", "order_item", - "group_list", "group_item", "integer_or_placeholder", "argument_list", - "when_clauses", "when_clause", "function_call", "distinct_or_null", - "argument_list_or_null", "argument_item", -}; -#endif /* NDEBUG */ +static PHP_METHOD(Phalcon_Encryption_Security, getDefaultHash) +{ + zval *this_ptr = getThis(); -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *ppRuleName[] = { - /* 0 */ "program ::= query_language", - /* 1 */ "query_language ::= select_statement", - /* 2 */ "query_language ::= insert_statement", - /* 3 */ "query_language ::= update_statement", - /* 4 */ "query_language ::= delete_statement", - /* 5 */ "select_statement ::= select_clause where_clause group_clause having_clause order_clause select_limit_clause for_update_clause", - /* 6 */ "select_clause ::= SELECT distinct_all column_list FROM associated_name_list join_list_or_null", - /* 7 */ "distinct_all ::= DISTINCT", - /* 8 */ "distinct_all ::= ALL", - /* 9 */ "distinct_all ::=", - /* 10 */ "column_list ::= column_list COMMA column_item", - /* 11 */ "column_list ::= column_item", - /* 12 */ "column_item ::= TIMES", - /* 13 */ "column_item ::= IDENTIFIER DOT TIMES", - /* 14 */ "column_item ::= expr AS IDENTIFIER", - /* 15 */ "column_item ::= expr IDENTIFIER", - /* 16 */ "column_item ::= expr", - /* 17 */ "associated_name_list ::= associated_name_list COMMA associated_name", - /* 18 */ "associated_name_list ::= associated_name", - /* 19 */ "join_list_or_null ::= join_list", - /* 20 */ "join_list_or_null ::=", - /* 21 */ "join_list ::= join_list join_item", - /* 22 */ "join_list ::= join_item", - /* 23 */ "join_item ::= join_clause", - /* 24 */ "join_clause ::= join_type aliased_or_qualified_name join_associated_name join_conditions", - /* 25 */ "join_associated_name ::= AS IDENTIFIER", - /* 26 */ "join_associated_name ::= IDENTIFIER", - /* 27 */ "join_associated_name ::=", - /* 28 */ "join_type ::= INNER JOIN", - /* 29 */ "join_type ::= CROSS JOIN", - /* 30 */ "join_type ::= LEFT OUTER JOIN", - /* 31 */ "join_type ::= LEFT JOIN", - /* 32 */ "join_type ::= RIGHT OUTER JOIN", - /* 33 */ "join_type ::= RIGHT JOIN", - /* 34 */ "join_type ::= FULL OUTER JOIN", - /* 35 */ "join_type ::= FULL JOIN", - /* 36 */ "join_type ::= JOIN", - /* 37 */ "join_conditions ::= ON expr", - /* 38 */ "join_conditions ::=", - /* 39 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", - /* 40 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name PARENTHESES_OPEN field_list PARENTHESES_CLOSE VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", - /* 41 */ "values_list ::= values_list COMMA value_item", - /* 42 */ "values_list ::= value_item", - /* 43 */ "value_item ::= expr", - /* 44 */ "field_list ::= field_list COMMA field_item", - /* 45 */ "field_list ::= field_item", - /* 46 */ "field_item ::= IDENTIFIER", - /* 47 */ "update_statement ::= update_clause where_clause limit_clause", - /* 48 */ "update_clause ::= UPDATE associated_name SET update_item_list", - /* 49 */ "update_item_list ::= update_item_list COMMA update_item", - /* 50 */ "update_item_list ::= update_item", - /* 51 */ "update_item ::= qualified_name EQUALS new_value", - /* 52 */ "new_value ::= expr", - /* 53 */ "delete_statement ::= delete_clause where_clause limit_clause", - /* 54 */ "delete_clause ::= DELETE FROM associated_name", - /* 55 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER", - /* 56 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER", - /* 57 */ "associated_name ::= aliased_or_qualified_name", - /* 58 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH with_item", - /* 59 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", - /* 60 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", - /* 61 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH with_item", - /* 62 */ "associated_name ::= aliased_or_qualified_name WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", - /* 63 */ "associated_name ::= aliased_or_qualified_name WITH with_item", - /* 64 */ "with_list ::= with_list COMMA with_item", - /* 65 */ "with_list ::= with_item", - /* 66 */ "with_item ::= IDENTIFIER", - /* 67 */ "aliased_or_qualified_name ::= qualified_name", - /* 68 */ "where_clause ::= WHERE expr", - /* 69 */ "where_clause ::=", - /* 70 */ "order_clause ::= ORDER BY order_list", - /* 71 */ "order_clause ::=", - /* 72 */ "order_list ::= order_list COMMA order_item", - /* 73 */ "order_list ::= order_item", - /* 74 */ "order_item ::= expr", - /* 75 */ "order_item ::= expr ASC", - /* 76 */ "order_item ::= expr DESC", - /* 77 */ "group_clause ::= GROUP BY group_list", - /* 78 */ "group_clause ::=", - /* 79 */ "group_list ::= group_list COMMA group_item", - /* 80 */ "group_list ::= group_item", - /* 81 */ "group_item ::= expr", - /* 82 */ "having_clause ::= HAVING expr", - /* 83 */ "having_clause ::=", - /* 84 */ "for_update_clause ::= FOR UPDATE", - /* 85 */ "for_update_clause ::=", - /* 86 */ "select_limit_clause ::= LIMIT integer_or_placeholder", - /* 87 */ "select_limit_clause ::= LIMIT integer_or_placeholder COMMA integer_or_placeholder", - /* 88 */ "select_limit_clause ::= LIMIT integer_or_placeholder OFFSET integer_or_placeholder", - /* 89 */ "select_limit_clause ::=", - /* 90 */ "limit_clause ::= LIMIT integer_or_placeholder", - /* 91 */ "limit_clause ::=", - /* 92 */ "integer_or_placeholder ::= INTEGER", - /* 93 */ "integer_or_placeholder ::= HINTEGER", - /* 94 */ "integer_or_placeholder ::= NPLACEHOLDER", - /* 95 */ "integer_or_placeholder ::= SPLACEHOLDER", - /* 96 */ "integer_or_placeholder ::= BPLACEHOLDER", - /* 97 */ "expr ::= MINUS expr", - /* 98 */ "expr ::= expr MINUS expr", - /* 99 */ "expr ::= expr PLUS expr", - /* 100 */ "expr ::= expr TIMES expr", - /* 101 */ "expr ::= expr DIVIDE expr", - /* 102 */ "expr ::= expr MOD expr", - /* 103 */ "expr ::= expr AND expr", - /* 104 */ "expr ::= expr OR expr", - /* 105 */ "expr ::= expr BITWISE_AND expr", - /* 106 */ "expr ::= expr BITWISE_OR expr", - /* 107 */ "expr ::= expr BITWISE_XOR expr", - /* 108 */ "expr ::= expr EQUALS expr", - /* 109 */ "expr ::= expr NOTEQUALS expr", - /* 110 */ "expr ::= expr LESS expr", - /* 111 */ "expr ::= expr GREATER expr", - /* 112 */ "expr ::= expr GREATEREQUAL expr", - /* 113 */ "expr ::= expr LESSEQUAL expr", - /* 114 */ "expr ::= expr LIKE expr", - /* 115 */ "expr ::= expr NOT LIKE expr", - /* 116 */ "expr ::= expr ILIKE expr", - /* 117 */ "expr ::= expr NOT ILIKE expr", - /* 118 */ "expr ::= expr IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", - /* 119 */ "expr ::= expr NOT IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", - /* 120 */ "expr ::= PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 121 */ "expr ::= expr IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 122 */ "expr ::= expr NOT IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 123 */ "expr ::= EXISTS PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 124 */ "expr ::= expr AGAINST expr", - /* 125 */ "expr ::= CAST PARENTHESES_OPEN expr AS IDENTIFIER PARENTHESES_CLOSE", - /* 126 */ "expr ::= CONVERT PARENTHESES_OPEN expr USING IDENTIFIER PARENTHESES_CLOSE", - /* 127 */ "expr ::= CASE expr when_clauses END", - /* 128 */ "when_clauses ::= when_clauses when_clause", - /* 129 */ "when_clauses ::= when_clause", - /* 130 */ "when_clause ::= WHEN expr THEN expr", - /* 131 */ "when_clause ::= ELSE expr", - /* 132 */ "expr ::= function_call", - /* 133 */ "function_call ::= IDENTIFIER PARENTHESES_OPEN distinct_or_null argument_list_or_null PARENTHESES_CLOSE", - /* 134 */ "distinct_or_null ::= DISTINCT", - /* 135 */ "distinct_or_null ::=", - /* 136 */ "argument_list_or_null ::= argument_list", - /* 137 */ "argument_list_or_null ::=", - /* 138 */ "argument_list ::= argument_list COMMA argument_item", - /* 139 */ "argument_list ::= argument_item", - /* 140 */ "argument_item ::= TIMES", - /* 141 */ "argument_item ::= expr", - /* 142 */ "expr ::= expr IS NULL", - /* 143 */ "expr ::= expr IS NOT NULL", - /* 144 */ "expr ::= expr BETWEEN expr", - /* 145 */ "expr ::= expr BETWEEN_NOT expr", - /* 146 */ "expr ::= NOT expr", - /* 147 */ "expr ::= BITWISE_NOT expr", - /* 148 */ "expr ::= PARENTHESES_OPEN expr PARENTHESES_CLOSE", - /* 149 */ "expr ::= qualified_name", - /* 150 */ "expr ::= INTEGER", - /* 151 */ "expr ::= HINTEGER", - /* 152 */ "expr ::= STRING", - /* 153 */ "expr ::= DOUBLE", - /* 154 */ "expr ::= NULL", - /* 155 */ "expr ::= TRUE", - /* 156 */ "expr ::= FALSE", - /* 157 */ "expr ::= NPLACEHOLDER", - /* 158 */ "expr ::= SPLACEHOLDER", - /* 159 */ "expr ::= BPLACEHOLDER", - /* 160 */ "qualified_name ::= IDENTIFIER DOT IDENTIFIER", - /* 161 */ "qualified_name ::= IDENTIFIER", -}; -#endif /* NDEBUG */ -const char *phql_TokenName(int tokenType){ -#ifndef NDEBUG - if( tokenType>0 && tokenType<(sizeof(ppTokenName)/sizeof(ppTokenName[0])) ){ - return ppTokenName[tokenType]; - }else{ - return "Unknown"; - } -#else - return ""; -#endif -} -void *phql_Alloc(void *(*mallocProc)(size_t)){ - ppParser *pParser; - pParser = (ppParser*)(*mallocProc)( (size_t)sizeof(ppParser) ); - if( pParser ){ - pParser->ppidx = -1; - } - return pParser; + RETURN_MEMBER(getThis(), "defaultHash"); } -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "ppmajor" is the symbol code, and "pppminor" is a pointer to -** the value. -*/ -static void pp_destructor(PPCODETYPE ppmajor, PPMINORTYPE *pppminor){ - switch( ppmajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: - case 30: - case 31: - case 32: - case 33: - case 34: - case 35: - case 36: - case 37: - case 38: - case 39: - case 40: - case 41: - case 42: - case 43: - case 44: - case 45: - case 46: - case 47: - case 48: - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - case 58: - case 59: - case 60: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 68: - case 69: - case 70: - case 71: - case 72: - case 73: - case 74: - case 75: - case 76: - case 77: - case 78: - case 79: -// 101 "parser.php.lemon" +static PHP_METHOD(Phalcon_Encryption_Security, getHashInformation) { - if ((pppminor->pp0)) { - if ((pppminor->pp0)->free_flag) { - efree((pppminor->pp0)->token); - } - efree((pppminor->pp0)); - } + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *hash_param = NULL; + zval hash; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&hash); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(hash) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &hash_param); + zephir_get_strval(&hash, hash_param); + + + ZEPHIR_RETURN_CALL_FUNCTION("password_get_info", NULL, 249, &hash); + zephir_check_call_status(); + RETURN_MM(); } -// 826 "parser.php.c" - break; - case 82: - case 83: - case 84: - case 85: - case 86: - case 87: - case 89: - case 95: - case 96: - case 98: - case 99: - case 100: - case 101: - case 102: - case 103: - case 104: - case 105: - case 109: - case 110: - case 112: - case 113: - case 115: - case 116: - case 117: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 130: - case 133: -// 114 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, getRandom) { - zval_ptr_dtor(&(pppminor->pp202)); + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "random"); } -// 866 "parser.php.c" - break; - case 88: - case 90: - case 91: - case 92: - case 93: - case 94: - case 106: - case 107: - case 114: - case 131: - case 132: -// 496 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, getRandomBytes) { - zephir_safe_zval_ptr_dtor((pppminor->pp202)); -} -// 883 "parser.php.c" - break; - default: break; /* If no destructor action specified: do nothing */ - } -} + zval *this_ptr = getThis(); -static int pp_pop_parser_stack(ppParser *pParser){ - PPCODETYPE ppmajor; - ppStackEntry *pptos = &pParser->ppstack[pParser->ppidx]; - if( pParser->ppidx<0 ) return 0; -#ifndef NDEBUG - if( ppTraceFILE && pParser->ppidx>=0 ){ - fprintf(ppTraceFILE,"%sPopping %s\n", - ppTracePrompt, - ppTokenName[pptos->major]); - } -#endif - ppmajor = pptos->major; - pp_destructor( ppmajor, &pptos->minor); - pParser->ppidx--; - return ppmajor; -} -static void phql_Free( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - ppParser *pParser = (ppParser*)p; - if( pParser==0 ) return; - while( pParser->ppidx>=0 ) pp_pop_parser_stack(pParser); - (*freeProc)((void*)pParser); + RETURN_MEMBER(getThis(), "numberBytes"); } -static int pp_find_shift_action( - ppParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->ppstack[pParser->ppidx].stateno; +static PHP_METHOD(Phalcon_Encryption_Security, getRequestToken) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - /* if( pParser->ppidx<0 ) return PP_NO_ACTION; */ - i = pp_shift_ofst[stateno]; - if( i==PP_SHIFT_USE_DFLT ){ - return pp_default[stateno]; - } - if( iLookAhead==PPNOCODE ){ - return PP_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ -#ifdef PPFALLBACK - int iFallback; /* Fallback token */ - if( iLookAhead %s\n", - ppTracePrompt, ppTokenName[iLookAhead], ppTokenName[iFallback]); - } -#endif - return pp_find_shift_action(pParser, iFallback); - } -#endif - return pp_default[stateno]; - }else{ - return pp_action[i]; - } + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("requestToken"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_EMPTY(&_0)) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsessiontoken", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_MM_MEMBER(getThis(), "requestToken"); } -static int pp_find_reduce_action( - ppParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->ppstack[pParser->ppidx].stateno; +static PHP_METHOD(Phalcon_Encryption_Security, getSessionToken) +{ + zval session, _0, _1, _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - i = pp_reduce_ofst[stateno]; - if( i==PP_REDUCE_USE_DFLT ){ - return pp_default[stateno]; - } - if( iLookAhead==PPNOCODE ){ - return PP_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ - return pp_default[stateno]; - }else{ - return pp_action[i]; - } + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "session"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + zephir_check_call_status(); + if (UNEXPECTED(zephir_is_true(&session))) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&session, "get", NULL, 0, &_2$$3); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_MM_NULL(); } -static void pp_shift( - ppParser *pppParser, /* The parser to be shifted */ - int ppNewState, /* The new state to shift in */ - int ppMajor, /* The major token to shift in */ - PPMINORTYPE *pppMinor /* Pointer ot the minor token to shift in */ -){ - ppStackEntry *pptos; - pppParser->ppidx++; - if( pppParser->ppidx>=PPSTACKDEPTH ){ - phql_ARG_FETCH; - pppParser->ppidx--; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sStack Overflow!\n",ppTracePrompt); - } -#endif - while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - phql_ARG_STORE; /* Suppress warning about unused %extra_argument var */ - return; - } - pptos = &pppParser->ppstack[pppParser->ppidx]; - pptos->stateno = ppNewState; - pptos->major = ppMajor; - pptos->minor = *pppMinor; -#ifndef NDEBUG - if( ppTraceFILE && pppParser->ppidx>0 ){ - int i; - fprintf(ppTraceFILE,"%sShift %d\n",ppTracePrompt,ppNewState); - fprintf(ppTraceFILE,"%sStack:",ppTracePrompt); - for(i=1; i<=pppParser->ppidx; i++) - fprintf(ppTraceFILE," %s",ppTokenName[pppParser->ppstack[i].major]); - fprintf(ppTraceFILE,"\n"); - } +static PHP_METHOD(Phalcon_Encryption_Security, getSaltBytes) +{ + zend_bool _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *numberBytes_param = NULL, safeBytes, _0$$3, _1$$4, _2$$4; + zend_long numberBytes, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&safeBytes); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(numberBytes) + ZEND_PARSE_PARAMETERS_END(); #endif -} -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static struct { - PPCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} ppRuleInfo[] = { - { 81, 1 }, - { 82, 1 }, - { 82, 1 }, - { 82, 1 }, - { 82, 1 }, - { 83, 7 }, - { 87, 6 }, - { 94, 1 }, - { 94, 1 }, - { 94, 0 }, - { 95, 3 }, - { 95, 1 }, - { 98, 1 }, - { 98, 3 }, - { 98, 3 }, - { 98, 2 }, - { 98, 1 }, - { 96, 3 }, - { 96, 1 }, - { 97, 1 }, - { 97, 0 }, - { 101, 2 }, - { 101, 1 }, - { 102, 1 }, - { 103, 4 }, - { 106, 2 }, - { 106, 1 }, - { 106, 0 }, - { 104, 2 }, - { 104, 2 }, - { 104, 3 }, - { 104, 2 }, - { 104, 3 }, - { 104, 2 }, - { 104, 3 }, - { 104, 2 }, - { 104, 1 }, - { 107, 2 }, - { 107, 0 }, - { 84, 7 }, - { 84, 10 }, - { 108, 3 }, - { 108, 1 }, - { 111, 1 }, - { 109, 3 }, - { 109, 1 }, - { 112, 1 }, - { 85, 3 }, - { 113, 4 }, - { 115, 3 }, - { 115, 1 }, - { 116, 3 }, - { 118, 1 }, - { 86, 3 }, - { 119, 3 }, - { 100, 3 }, - { 100, 2 }, - { 100, 1 }, - { 100, 5 }, - { 100, 7 }, - { 100, 6 }, - { 100, 4 }, - { 100, 5 }, - { 100, 3 }, - { 121, 3 }, - { 121, 1 }, - { 120, 1 }, - { 105, 1 }, - { 88, 2 }, - { 88, 0 }, - { 91, 3 }, - { 91, 0 }, - { 122, 3 }, - { 122, 1 }, - { 123, 1 }, - { 123, 2 }, - { 123, 2 }, - { 89, 3 }, - { 89, 0 }, - { 124, 3 }, - { 124, 1 }, - { 125, 1 }, - { 90, 2 }, - { 90, 0 }, - { 93, 2 }, - { 93, 0 }, - { 92, 2 }, - { 92, 4 }, - { 92, 4 }, - { 92, 0 }, - { 114, 2 }, - { 114, 0 }, - { 126, 1 }, - { 126, 1 }, - { 126, 1 }, - { 126, 1 }, - { 126, 1 }, - { 99, 2 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 4 }, - { 99, 3 }, - { 99, 4 }, - { 99, 5 }, - { 99, 6 }, - { 99, 3 }, - { 99, 5 }, - { 99, 6 }, - { 99, 4 }, - { 99, 3 }, - { 99, 6 }, - { 99, 6 }, - { 99, 4 }, - { 128, 2 }, - { 128, 1 }, - { 129, 4 }, - { 129, 2 }, - { 99, 1 }, - { 130, 5 }, - { 131, 1 }, - { 131, 0 }, - { 132, 1 }, - { 132, 0 }, - { 127, 3 }, - { 127, 1 }, - { 133, 1 }, - { 133, 1 }, - { 99, 3 }, - { 99, 4 }, - { 99, 3 }, - { 99, 3 }, - { 99, 2 }, - { 99, 2 }, - { 99, 3 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 117, 3 }, - { 117, 1 }, -}; -static void pp_accept(ppParser*); /* Forward Declaration */ + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &numberBytes_param); + if (!numberBytes_param) { + numberBytes = 0; + } else { + numberBytes = zephir_get_intval(numberBytes_param); + } -static void pp_reduce( - ppParser *pppParser, /* The parser */ - int ppruleno /* Number of the rule by which to reduce */ -){ - int ppgoto; /* The next state */ - int ppact; /* The next action */ - PPMINORTYPE ppgotominor; /* The LHS of the rule reduced */ - ppStackEntry *ppmsp; /* The top of the parser's stack */ - int ppsize; /* Amount to pop the stack */ - phql_ARG_FETCH; - ppmsp = &pppParser->ppstack[pppParser->ppidx]; -#ifndef NDEBUG - if( ppTraceFILE && ppruleno>=0 - && ppruleno - ** { ... } // User supplied code - ** // - ** break; - */ - case 0: -// 110 "parser.php.lemon" -{ - ZVAL_ZVAL(&status->ret, &ppmsp[0].minor.pp202, 1, 1); + if (!(numberBytes)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); + numberBytes = zephir_get_numberval(&_0$$3); + } + while (1) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$4, numberBytes); + ZEPHIR_CALL_METHOD(&safeBytes, &_1$$4, "base64safe", NULL, 0, &_2$$4); + zephir_check_call_status(); + _3$$4 = zephir_is_true(&safeBytes); + if (_3$$4) { + _3$$4 = zephir_fast_strlen_ev(&safeBytes) >= numberBytes; + } + if (_3$$4) { + break; + } + } + RETURN_CCTOR(&safeBytes); } -// 1262 "parser.php.c" - break; - case 1: - case 2: - case 3: - case 4: - case 18: - case 19: - case 22: - case 23: - case 43: - case 50: - case 52: - case 65: - case 67: - case 73: - case 80: - case 81: - case 132: - case 136: - case 141: - case 149: -// 118 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, getToken) { - ppgotominor.pp202 = ppmsp[0].minor.pp202; + zval session, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$4, _8$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "getsessiontoken", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("requestToken"), &_1$$3); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "base64safe", NULL, 0, &_4$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), &_3$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "session"); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_5$$3, &_6$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&session) != IS_NULL) { + zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_7$$4, &_8$$4); + zephir_check_call_status(); + } + } + RETURN_MM_MEMBER(getThis(), "token"); } -// 1288 "parser.php.c" - break; - case 5: -// 138 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, getTokenKey) { - phql_ret_select_statement(&ppgotominor.pp202, &ppmsp[-6].minor.pp202, &ppmsp[-5].minor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-4].minor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); + zval session, _0, _1$$3, _2$$3, _3$$4, _4$$4, _5$$4, _6$$4, _7$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("tokenKey"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "session"); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_1$$3, &_2$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&session) != IS_NULL) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4$$4, &_3$$4, "base64safe", NULL, 0, &_5$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("tokenKey"), &_4$$4); + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("tokenKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_6$$4, &_7$$4); + zephir_check_call_status(); + } + } + RETURN_MM_MEMBER(getThis(), "tokenKey"); } -// 1295 "parser.php.c" - break; - case 6: -// 146 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, getWorkFactor) { - phql_ret_select_clause(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(27,&ppmsp[-5].minor); - pp_destructor(28,&ppmsp[-2].minor); + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "workFactor"); } -// 1304 "parser.php.c" - break; - case 7: -// 154 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, hash) { - phql_ret_distinct_all(&ppgotominor.pp202, 1); - pp_destructor(29,&ppmsp[0].minor); + zend_bool legacy = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, bytes = 0; + zval options; + zval *password_param = NULL, *options_param = NULL, algorithm, arguments, cost, formatted, prefix, salt, _0, _1, _6, _2$$6, _3$$7, _4$$9, _5$$9; + zval password; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&algorithm); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&cost); + ZVAL_UNDEF(&formatted); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&salt); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_2$$6); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&options); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(password) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &password_param, &options_param); + zephir_get_strval(&password, password_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + + + ZEPHIR_CALL_METHOD(&cost, this_ptr, "processcost", NULL, 250, &options); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "%02s"); + ZEPHIR_CALL_FUNCTION(&formatted, "sprintf", NULL, 116, &_0, &cost); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&prefix); + ZVAL_STRING(&prefix, ""); + bytes = 22; + legacy = 1; + ZEPHIR_OBS_VAR(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_LONG(&_1, 3)) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, "$1$"); + bytes = 12; + break; + } + if (ZEPHIR_IS_LONG(&_1, 8)) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, "$5$"); + bytes = 16; + break; + } + if (ZEPHIR_IS_LONG(&_1, 9)) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, "$6$"); + bytes = 16; + break; + } + if (ZEPHIR_IS_LONG(&_1, 5)) { + ZEPHIR_INIT_VAR(&_2$$6); + ZVAL_STRING(&_2$$6, "$2a$%s$"); + ZEPHIR_CALL_FUNCTION(&prefix, "sprintf", NULL, 116, &_2$$6, &formatted); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_1, 6)) { + ZEPHIR_INIT_VAR(&_3$$7); + ZVAL_STRING(&_3$$7, "$2x$%s$"); + ZEPHIR_CALL_FUNCTION(&prefix, "sprintf", NULL, 116, &_3$$7, &formatted); + zephir_check_call_status(); + break; + } + legacy = 0; + break; + } while(0); + + if (UNEXPECTED(legacy)) { + ZVAL_LONG(&_5$$9, bytes); + ZEPHIR_CALL_METHOD(&_4$$9, this_ptr, "getsaltbytes", NULL, 0, &_5$$9); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&salt); + ZEPHIR_CONCAT_VVS(&salt, &prefix, &_4$$9, "$"); + ZEPHIR_RETURN_CALL_FUNCTION("crypt", NULL, 251, &password, &salt); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 1, 0); + zephir_array_update_string(&_6, SL("cost"), &cost, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&options, &_6); + ZEPHIR_CALL_METHOD(&algorithm, this_ptr, "processalgorithm", NULL, 252); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&arguments, this_ptr, "processargonoptions", NULL, 253, &options); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("password_hash", NULL, 254, &password, &algorithm, &arguments); + zephir_check_call_status(); + RETURN_MM(); } -// 1312 "parser.php.c" - break; - case 8: -// 158 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, isLegacyHash) { - phql_ret_distinct_all(&ppgotominor.pp202, 0); - pp_destructor(30,&ppmsp[0].minor); -} -// 1320 "parser.php.c" - break; - case 9: - case 20: - case 27: - case 38: - case 69: - case 71: - case 78: - case 83: - case 85: - case 89: - case 91: - case 135: - case 137: -// 162 "parser.php.lemon" -{ - ZVAL_UNDEF(&ppgotominor.pp202); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *passwordHash_param = NULL; + zval passwordHash; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&passwordHash); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(passwordHash) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &passwordHash_param); + zephir_get_strval(&passwordHash, passwordHash_param); + + + RETURN_MM_BOOL(zephir_start_with_str(&passwordHash, SL("$2a$"))); } -// 1339 "parser.php.c" - break; - case 10: - case 17: - case 41: - case 44: - case 49: - case 64: - case 72: - case 79: - case 138: -// 170 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, setDefaultHash) { - phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(26,&ppmsp[-1].minor); + zval *defaultHash_param = NULL, _0; + zend_long defaultHash; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(defaultHash) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &defaultHash_param); + defaultHash = zephir_get_intval(defaultHash_param); + + + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, defaultHash); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHash"), &_0); + RETURN_THISW(); } -// 1355 "parser.php.c" - break; - case 11: - case 42: - case 45: - case 129: - case 139: -// 174 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, setRandomBytes) { - phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL); + zval *randomBytes_param = NULL, _0; + zend_long randomBytes; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(randomBytes) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &randomBytes_param); + if (UNEXPECTED(Z_TYPE_P(randomBytes_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'randomBytes' must be of the type int")); + RETURN_NULL(); + } + randomBytes = Z_LVAL_P(randomBytes_param); + + + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, randomBytes); + zephir_update_property_zval(this_ptr, ZEND_STRL("numberBytes"), &_0); + RETURN_THISW(); } -// 1366 "parser.php.c" - break; - case 12: - case 140: -// 182 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, setWorkFactor) { - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_STARALL, NULL, NULL, NULL); - pp_destructor(18,&ppmsp[0].minor); + zval *workFactor_param = NULL, _0; + zend_long workFactor; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(workFactor) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &workFactor_param); + workFactor = zephir_get_intval(workFactor_param); + + + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, workFactor); + zephir_update_property_zval(this_ptr, ZEND_STRL("workFactor"), &_0); + RETURN_THISW(); } -// 1375 "parser.php.c" - break; - case 13: -// 186 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, getLocalService) { - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_DOMAINALL, NULL, ppmsp[-2].minor.pp0, NULL); - pp_destructor(32,&ppmsp[-1].minor); - pp_destructor(18,&ppmsp[0].minor); + zend_bool _1, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *property_param = NULL, _0, _2, _4, _5, _8, _6$$3, _7$$3; + zval name, property; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &property_param); + zephir_get_strval(&name, name_param); + zephir_get_strval(&property, property_param); + + + ZEPHIR_OBS_VAR(&_0); + zephir_read_property_zval(&_0, this_ptr, &property, PH_NOISY_CC); + _1 = Z_TYPE_P(&_0) == IS_NULL; + if (_1) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + _1 = Z_TYPE_P(&_2) != IS_NULL; + } + _3 = _1; + if (_3) { + zephir_read_property(&_4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "has", NULL, 0, &name); + zephir_check_call_status(); + _3 = ZEPHIR_IS_TRUE_IDENTICAL(&_5); + } + if (_3) { + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "getshared", NULL, 0, &name); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &property, &_7$$3); + } + ZEPHIR_OBS_VAR(&_8); + zephir_read_property_zval(&_8, this_ptr, &property, PH_NOISY_CC); + RETURN_CCTOR(&_8); } -// 1384 "parser.php.c" - break; - case 14: -// 190 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, processAlgorithm) { - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[-2].minor.pp202, NULL, ppmsp[0].minor.pp0); - pp_destructor(33,&ppmsp[-1].minor); + zval algorithm, _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&algorithm); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&algorithm); + ZVAL_STRING(&algorithm, "2y"); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_0, 10)) { + ZEPHIR_INIT_NVAR(&algorithm); + ZVAL_STRING(&algorithm, "argon2i"); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_1, 11)) { + ZEPHIR_INIT_NVAR(&algorithm); + ZVAL_STRING(&algorithm, "argon2id"); + } + RETURN_CCTOR(&algorithm); } -// 1392 "parser.php.c" - break; - case 15: -// 194 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, processArgonOptions) { - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[-1].minor.pp202, NULL, ppmsp[0].minor.pp0); + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, value, _0, _2; + zval options; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + _1 = ZEPHIR_IS_LONG_IDENTICAL(&_0, 10); + if (!(_1)) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + _1 = ZEPHIR_IS_LONG_IDENTICAL(&_2, 11); + } + if (_1) { + ZEPHIR_OBS_VAR(&value); + if (!(zephir_array_isset_string_fetch(&value, &options, SL("memory_cost"), 0))) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&value, 65536); + } + zephir_array_update_string(&options, SL("memory_cost"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&value); + if (!(zephir_array_isset_string_fetch(&value, &options, SL("time_cost"), 0))) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&value, 4); + } + zephir_array_update_string(&options, SL("time_cost"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&value); + if (!(zephir_array_isset_string_fetch(&value, &options, SL("threads"), 0))) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&value, 1); + } + zephir_array_update_string(&options, SL("threads"), &value, PH_COPY | PH_SEPARATE); + } + RETURN_CTOR(&options); } -// 1399 "parser.php.c" - break; - case 16: -// 198 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, processCost) { - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[0].minor.pp202, NULL, NULL); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, cost; + zval options; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&cost); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + + + ZEPHIR_OBS_VAR(&cost); + if (!(zephir_array_isset_string_fetch(&cost, &options, SL("cost"), 0))) { + ZEPHIR_OBS_NVAR(&cost); + zephir_read_property(&cost, this_ptr, ZEND_STRL("workFactor"), PH_NOISY_CC); + } + if (ZEPHIR_LT_LONG(&cost, 4)) { + ZEPHIR_INIT_NVAR(&cost); + ZVAL_LONG(&cost, 4); + } + if (ZEPHIR_GT_LONG(&cost, 31)) { + ZEPHIR_INIT_NVAR(&cost); + ZVAL_LONG(&cost, 31); + } + RETURN_CCTOR(&cost); } -// 1406 "parser.php.c" - break; - case 21: - case 128: -// 226 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, processTokenKey) { - phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); + zend_bool _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tokenKey_param = NULL, key, session, _0, _1, _3$$3; + zval tokenKey; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tokenKey); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(tokenKey) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &tokenKey_param); + if (!tokenKey_param) { + ZEPHIR_INIT_VAR(&tokenKey); + } else { + zephir_get_strval(&tokenKey, tokenKey_param); + } + + + ZEPHIR_CPY_WRT(&key, &tokenKey); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "session"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + zephir_check_call_status(); + _2 = Z_TYPE_P(&session) != IS_NULL; + if (_2) { + _2 = 1 == ZEPHIR_IS_EMPTY(&key); + } + if (_2) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&key, &session, "get", NULL, 0, &_3$$3); + zephir_check_call_status(); + } + RETURN_CCTOR(&key); } -// 1414 "parser.php.c" - break; - case 24: -// 247 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security, processUserToken) { - phql_ret_join_item(&ppgotominor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tokenKey_param = NULL, *tokenValue_param = NULL, request, userToken, _0$$3, _1$$3, _2$$4; + zval tokenKey, tokenValue; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tokenKey); + ZVAL_UNDEF(&tokenValue); + ZVAL_UNDEF(&request); + ZVAL_UNDEF(&userToken); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tokenKey) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(tokenValue) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &tokenKey_param, &tokenValue_param); + zephir_get_strval(&tokenKey, tokenKey_param); + if (!tokenValue_param) { + ZEPHIR_INIT_VAR(&tokenValue); + } else { + zephir_get_strval(&tokenValue, tokenValue_param); + } + + + ZEPHIR_CPY_WRT(&userToken, &tokenValue); + if (!(!(ZEPHIR_IS_EMPTY(&tokenValue)))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "request"); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "localRequest"); + ZEPHIR_CALL_METHOD(&request, this_ptr, "getlocalservice", NULL, 0, &_0$$3, &_1$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&request) != IS_NULL) { + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "string"); + ZEPHIR_CALL_METHOD(&userToken, &request, "getpost", NULL, 0, &tokenKey, &_2$$4); + zephir_check_call_status(); + } + } + RETURN_CCTOR(&userToken); } -// 1421 "parser.php.c" - break; - case 25: -// 255 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_CryptInterface) { - phql_ret_qualified_name(&ppgotominor.pp202, NULL, NULL, ppmsp[0].minor.pp0); - pp_destructor(33,&ppmsp[-1].minor); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Crypt, CryptInterface, phalcon, encryption_crypt_cryptinterface, phalcon_encryption_crypt_cryptinterface_method_entry); + + return SUCCESS; } -// 1429 "parser.php.c" - break; - case 26: - case 46: - case 66: - case 161: -// 259 "parser.php.lemon" + +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, decrypt); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, decryptBase64); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, encrypt); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, encryptBase64); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAvailableCiphers); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthTag); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthData); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthTagLength); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getCipher); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getKey); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthTag); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthData); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthTagLength); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setCipher); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setKey); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setPadding); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, useSigning); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_PadFactory) { - phql_ret_qualified_name(&ppgotominor.pp202, NULL, NULL, ppmsp[0].minor.pp0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt, PadFactory, phalcon, encryption_crypt_padfactory, phalcon_factory_abstractfactory_ce, phalcon_encryption_crypt_padfactory_method_entry, 0); + + zend_declare_property_string(phalcon_encryption_crypt_padfactory_ce, SL("exception"), "Phalcon\\Encryption\\Crypt\\Exception\\Exception", ZEND_ACC_PROTECTED); + return SUCCESS; } -// 1439 "parser.php.c" - break; - case 28: -// 271 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, __construct) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_INNERJOIN); - pp_destructor(34,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *services_param = NULL; + zval services; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&services); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -// 1448 "parser.php.c" - break; - case 29: -// 275 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, newInstance) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_CROSSJOIN); - pp_destructor(36,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, definition; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + + + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &definition); + zephir_check_call_status(); + RETURN_MM(); } -// 1457 "parser.php.c" - break; - case 30: -// 279 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, padNumberToService) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_LEFTJOIN); - pp_destructor(37,&ppmsp[-2].minor); - pp_destructor(38,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + zval map; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *number_param = NULL, _0, _1, _2; + zend_long number, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&map); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(number) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &number_param); + number = zephir_get_intval(number_param); + + + ZEPHIR_INIT_VAR(&map); + zephir_create_array(&map, 6, 0); + add_index_stringl(&map, 1, SL("ansi")); + add_index_stringl(&map, 3, SL("iso10126")); + add_index_stringl(&map, 4, SL("isoiek")); + add_index_stringl(&map, 2, SL("pjcs7")); + add_index_stringl(&map, 6, SL("space")); + add_index_stringl(&map, 5, SL("zero")); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_support_helper_arr_get_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZVAL_LONG(&_1, number); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "noop"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "__invoke", NULL, 158, &map, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -// 1467 "parser.php.c" - break; - case 31: -// 283 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, getServices) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_LEFTJOIN); - pp_destructor(37,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + zval *this_ptr = getThis(); + + + + zephir_create_array(return_value, 7, 0); + add_assoc_stringl_ex(return_value, SL("ansi"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Ansi")); + add_assoc_stringl_ex(return_value, SL("iso10126"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Iso10126")); + add_assoc_stringl_ex(return_value, SL("isoiek"), SL("Phalcon\\Encryption\\Crypt\\Padding\\IsoIek")); + add_assoc_stringl_ex(return_value, SL("noop"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Noop")); + add_assoc_stringl_ex(return_value, SL("pjcs7"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Pkcs7")); + add_assoc_stringl_ex(return_value, SL("space"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Space")); + add_assoc_stringl_ex(return_value, SL("zero"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Zero")); + return; } -// 1476 "parser.php.c" - break; - case 32: -// 287 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Ansi) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_RIGHTJOIN); - pp_destructor(39,&ppmsp[-2].minor); - pp_destructor(38,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Ansi, phalcon, encryption_crypt_padding_ansi, phalcon_encryption_crypt_padding_ansi_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_ansi_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1486 "parser.php.c" - break; - case 33: -// 291 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Ansi, pad) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_RIGHTJOIN); - pp_destructor(39,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1, _2, _3; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 243, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, (paddingSize - 1)); + ZEPHIR_CALL_FUNCTION(&_2, "str_repeat", NULL, 1, &_1, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_CALL_FUNCTION(&_3, "chr", NULL, 243, &_0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &_2, &_3); + RETURN_MM(); } -// 1495 "parser.php.c" - break; - case 34: -// 295 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Ansi, unpad) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_FULLJOIN); - pp_destructor(40,&ppmsp[-2].minor); - pp_destructor(38,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *blockSize_param = NULL, last, length, ord, padding, paddingSize, repeat, _0, _1, _2$$4, _3$$4, _4$$3, _5$$3; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&ord); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&paddingSize); + ZVAL_UNDEF(&repeat); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + ZEPHIR_INIT_VAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); + ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); + ZVAL_LONG(&_1, 1); + ZEPHIR_INIT_VAR(&last); + zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); + ZEPHIR_CALL_FUNCTION(&ord, "ord", NULL, 244, &last); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&ord, blockSize)) { + ZEPHIR_CPY_WRT(&paddingSize, &ord); + ZEPHIR_INIT_VAR(&repeat); + ZVAL_STRING(&repeat, ""); + if (ZEPHIR_GT_LONG(&paddingSize, 1)) { + ZVAL_LONG(&_2$$4, 0); + ZEPHIR_CALL_FUNCTION(&_3$$4, "chr", NULL, 243, &_2$$4); + zephir_check_call_status(); + ZVAL_LONG(&_2$$4, (zephir_get_numberval(&paddingSize) - 1)); + ZEPHIR_CALL_FUNCTION(&repeat, "str_repeat", NULL, 1, &_3$$4, &_2$$4); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&padding); + ZEPHIR_CONCAT_VV(&padding, &repeat, &last); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_sub_function(&_4$$3, &length, &paddingSize); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_substr(&_5$$3, &input, zephir_get_intval(&_4$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + if (!ZEPHIR_IS_IDENTICAL(&_5$$3, &padding)) { + ZEPHIR_INIT_NVAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + } + } + RETURN_CCTOR(&paddingSize); } -// 1505 "parser.php.c" - break; - case 35: -// 299 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Iso10126) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_FULLJOIN); - pp_destructor(40,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Iso10126, phalcon, encryption_crypt_padding_iso10126, phalcon_encryption_crypt_padding_iso10126_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_iso10126_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1514 "parser.php.c" - break; - case 36: -// 303 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Iso10126, pad) { - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_INNERJOIN); - pp_destructor(35,&ppmsp[0].minor); + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; + zval *paddingSize_param = NULL, counter, padding, _7, _8, _3$$3, _5$$3; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS, _1, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&counter); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + ZEPHIR_INIT_VAR(&padding); + ZVAL_STRING(&padding, ""); + _2 = (paddingSize - 2); + _1 = 0; + _0 = 0; + if (_1 <= _2) { + while (1) { + if (_0) { + _1++; + if (!(_1 <= _2)) { + break; + } + } else { + _0 = 1; + } + ZEPHIR_INIT_NVAR(&counter); + ZVAL_LONG(&counter, _1); + ZEPHIR_CALL_FUNCTION(&_3$$3, "rand", &_4, 245); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_5$$3, "chr", &_6, 243, &_3$$3); + zephir_check_call_status(); + zephir_concat_self(&padding, &_5$$3); + } + } + ZVAL_LONG(&_7, paddingSize); + ZEPHIR_CALL_FUNCTION(&_8, "chr", &_6, 243, &_7); + zephir_check_call_status(); + zephir_concat_self(&padding, &_8); + RETURN_CCTOR(&padding); } -// 1522 "parser.php.c" - break; - case 37: -// 311 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Iso10126, unpad) { - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(41,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *blockSize_param = NULL, last, length, _0, _1; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); + ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); + ZVAL_LONG(&_1, 1); + ZEPHIR_INIT_VAR(&last); + zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); + ZEPHIR_RETURN_CALL_FUNCTION("ord", NULL, 244, &last); + zephir_check_call_status(); + RETURN_MM(); } -// 1530 "parser.php.c" - break; - case 39: -// 324 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_IsoIek) { - phql_ret_insert_statement(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, NULL, &ppmsp[-1].minor.pp202); - pp_destructor(42,&ppmsp[-6].minor); - pp_destructor(43,&ppmsp[-5].minor); - pp_destructor(44,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, IsoIek, phalcon, encryption_crypt_padding_isoiek, phalcon_encryption_crypt_padding_isoiek_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_isoiek_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1542 "parser.php.c" - break; - case 40: -// 328 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_IsoIek, pad) { - phql_ret_insert_statement(&ppgotominor.pp202, &ppmsp[-7].minor.pp202, &ppmsp[-5].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(42,&ppmsp[-9].minor); - pp_destructor(43,&ppmsp[-8].minor); - pp_destructor(45,&ppmsp[-6].minor); - pp_destructor(46,&ppmsp[-4].minor); - pp_destructor(44,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1, _2, _3; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + ZVAL_LONG(&_0, 0x80); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 243, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_FUNCTION(&_2, "chr", NULL, 243, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, (paddingSize - 1)); + ZEPHIR_CALL_FUNCTION(&_3, "str_repeat", NULL, 1, &_2, &_0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &_1, &_3); + RETURN_MM(); } -// 1556 "parser.php.c" - break; - case 47: -// 374 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_IsoIek, unpad) { - phql_ret_update_statement(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); -} -// 1563 "parser.php.c" - break; - case 48: -// 382 "parser.php.lemon" -{ - phql_ret_update_clause(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(47,&ppmsp[-3].minor); - pp_destructor(48,&ppmsp[-1].minor); -} -// 1572 "parser.php.c" - break; - case 51: -// 402 "parser.php.lemon" -{ - phql_ret_update_item(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(4,&ppmsp[-1].minor); -} -// 1580 "parser.php.c" - break; - case 53: -// 416 "parser.php.lemon" -{ - phql_ret_delete_statement(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); + zend_bool _0, _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; + zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3, _6, _7; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&inputArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + paddingSize = 0; + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 233, &input); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 87, &input); + zephir_check_call_status(); + counter = (zephir_get_numberval(&length) - 1); + while (1) { + _0 = counter > 0; + if (_0) { + zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/IsoIek.zep", 48); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 243, &_2); + zephir_check_call_status(); + _0 = ZEPHIR_IS_IDENTICAL(&_1, &_3); + } + _5 = _0; + if (_5) { + _5 = paddingSize < blockSize; + } + if (!(_5)) { + break; + } + paddingSize++; + counter--; + } + zephir_array_fetch_long(&_6, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/IsoIek.zep", 55); + ZVAL_LONG(&_2, 0x80); + ZEPHIR_CALL_FUNCTION(&_7, "chr", &_4, 243, &_2); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&_6, &_7)) { + paddingSize++; + } else { + paddingSize = 0; + } + RETURN_MM_LONG(paddingSize); } -// 1587 "parser.php.c" - break; - case 54: -// 424 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Noop) { - phql_ret_delete_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(49,&ppmsp[-2].minor); - pp_destructor(28,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Noop, phalcon, encryption_crypt_padding_noop, phalcon_encryption_crypt_padding_noop_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_noop_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1596 "parser.php.c" - break; - case 55: -// 432 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, pad) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, ppmsp[0].minor.pp0, NULL); - pp_destructor(33,&ppmsp[-1].minor); + zval *paddingSize_param = NULL; + zend_long paddingSize; + zval *this_ptr = getThis(); + +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + RETURN_STRING(""); } -// 1604 "parser.php.c" - break; - case 56: -// 436 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, unpad) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, ppmsp[0].minor.pp0, NULL); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize; + zval *input_param = NULL, *blockSize_param = NULL; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + RETURN_MM_LONG(0); } -// 1611 "parser.php.c" - break; - case 57: -// 440 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_PadInterface) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL, NULL); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Crypt\\Padding, PadInterface, phalcon, encryption_crypt_padding_padinterface, phalcon_encryption_crypt_padding_padinterface_method_entry); + + return SUCCESS; } -// 1618 "parser.php.c" - break; - case 58: -// 444 "parser.php.lemon" + +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_Padding_PadInterface, pad); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_Padding_PadInterface, unpad); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Pkcs7) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, ppmsp[-2].minor.pp0, &ppmsp[0].minor.pp202); - pp_destructor(33,&ppmsp[-3].minor); - pp_destructor(50,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Pkcs7, phalcon, encryption_crypt_padding_pkcs7, phalcon_encryption_crypt_padding_pkcs7_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_pkcs7_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1627 "parser.php.c" - break; - case 59: -// 448 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Pkcs7, pad) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-6].minor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202); - pp_destructor(33,&ppmsp[-5].minor); - pp_destructor(50,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 243, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_1, &_0); + zephir_check_call_status(); + RETURN_MM(); } -// 1638 "parser.php.c" - break; - case 60: -// 452 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Pkcs7, unpad) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-5].minor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202); - pp_destructor(50,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *blockSize_param = NULL, last, length, ord, padding, paddingSize, _0, _1, _2$$3, _3$$3, _4$$3; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&ord); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&paddingSize); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 233, &input); + zephir_check_call_status(); + ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); + ZVAL_LONG(&_1, 1); + ZEPHIR_INIT_VAR(&last); + zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); + ZEPHIR_CALL_FUNCTION(&ord, "ord", NULL, 244, &last); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&ord, blockSize)) { + ZEPHIR_CPY_WRT(&paddingSize, &ord); + ZEPHIR_CALL_FUNCTION(&_2$$3, "chr", NULL, 243, &paddingSize); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", NULL, 1, &_2$$3, &paddingSize); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_sub_function(&_3$$3, &length, &paddingSize); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_substr(&_4$$3, &input, zephir_get_intval(&_3$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + if (!ZEPHIR_IS_IDENTICAL(&_4$$3, &padding)) { + ZEPHIR_INIT_NVAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + } + } + RETURN_CCTOR(&paddingSize); } -// 1648 "parser.php.c" - break; - case 61: -// 456 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Space) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-3].minor.pp202, ppmsp[-2].minor.pp0, &ppmsp[0].minor.pp202); - pp_destructor(50,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Space, phalcon, encryption_crypt_padding_space, phalcon_encryption_crypt_padding_space_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_space_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1656 "parser.php.c" - break; - case 62: -// 460 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Space, pad) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, NULL, &ppmsp[-1].minor.pp202); - pp_destructor(50,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, " "); + ZVAL_LONG(&_1, paddingSize); + ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -// 1666 "parser.php.c" - break; - case 63: -// 464 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Space, unpad) { - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, NULL, &ppmsp[0].minor.pp202); - pp_destructor(50,&ppmsp[-1].minor); + zend_bool _0, _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; + zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&inputArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 233, &input); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 87, &input); + zephir_check_call_status(); + counter = (zephir_get_numberval(&length) - 1); + paddingSize = 0; + while (1) { + _0 = counter >= 0; + if (_0) { + zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/Space.zep", 48); + ZVAL_LONG(&_2, 32); + ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 243, &_2); + zephir_check_call_status(); + _0 = ZEPHIR_IS_EQUAL(&_1, &_3); + } + _5 = _0; + if (_5) { + _5 = paddingSize <= blockSize; + } + if (!(_5)) { + break; + } + paddingSize++; + counter--; + } + RETURN_MM_LONG(paddingSize); } -// 1674 "parser.php.c" - break; - case 68: -// 500 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Zero) { - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(51,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Zero, phalcon, encryption_crypt_padding_zero, phalcon_encryption_crypt_padding_zero_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_zero_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -// 1682 "parser.php.c" - break; - case 70: -// 512 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Zero, pad) { - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(52,&ppmsp[-2].minor); - pp_destructor(53,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + paddingSize = zephir_get_intval(paddingSize_param); + + + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 243, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_1, &_0); + zephir_check_call_status(); + RETURN_MM(); } -// 1691 "parser.php.c" - break; - case 74: -// 536 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Zero, unpad) { - phql_ret_order_item(&ppgotominor.pp202, &ppmsp[0].minor.pp202, 0); + zend_bool _0, _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; + zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&inputArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + blockSize = zephir_get_intval(blockSize_param); + + + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 233, &input); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 87, &input); + zephir_check_call_status(); + counter = (zephir_get_numberval(&length) - 1); + paddingSize = 0; + while (1) { + _0 = counter >= 0; + if (_0) { + zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/Zero.zep", 48); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 243, &_2); + zephir_check_call_status(); + _0 = ZEPHIR_IS_EQUAL(&_1, &_3); + } + _5 = _0; + if (_5) { + _5 = paddingSize <= blockSize; + } + if (!(_5)) { + break; + } + paddingSize++; + counter--; + } + RETURN_MM_LONG(paddingSize); } -// 1698 "parser.php.c" - break; - case 75: -// 540 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Exception_Exception) { - phql_ret_order_item(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, PHQL_T_ASC); - pp_destructor(54,&ppmsp[0].minor); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt\\Exception, Exception, phalcon, encryption_crypt_exception_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; } -// 1706 "parser.php.c" - break; - case 76: -// 544 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Exception_Mismatch) { - phql_ret_order_item(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, PHQL_T_DESC); - pp_destructor(55,&ppmsp[0].minor); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt\\Exception, Mismatch, phalcon, encryption_crypt_exception_mismatch, phalcon_encryption_crypt_exception_exception_ce, NULL, 0); + + return SUCCESS; } -// 1714 "parser.php.c" - break; - case 77: -// 552 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Exception) { - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(56,&ppmsp[-2].minor); - pp_destructor(53,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security, Exception, phalcon, encryption_security_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; } -// 1723 "parser.php.c" - break; - case 82: -// 584 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Random) { - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(57,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security, Random, phalcon, encryption_security_random, phalcon_encryption_security_random_method_entry, 0); + + return SUCCESS; } -// 1731 "parser.php.c" - break; - case 84: -// 596 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base58) { - phql_ret_for_update_clause(&ppgotominor.pp202); - pp_destructor(58,&ppmsp[-1].minor); - pp_destructor(47,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1, _2; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { + len = zephir_get_intval(len_param); + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); + ZVAL_LONG(&_1, 58); + ZVAL_LONG(&_2, len); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "base", NULL, 0, &_0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -// 1740 "parser.php.c" - break; - case 86: - case 90: -// 608 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base62) { - phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL); - pp_destructor(59,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1, _2; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { + len = zephir_get_intval(len_param); + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); + ZVAL_LONG(&_1, 62); + ZVAL_LONG(&_2, len); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "base", NULL, 0, &_0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -// 1749 "parser.php.c" - break; - case 87: -// 612 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base64) { - phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202, &ppmsp[-2].minor.pp202); - pp_destructor(59,&ppmsp[-3].minor); - pp_destructor(26,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { + len = zephir_get_intval(len_param); + } + + + ZVAL_LONG(&_1, len); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 230, &_0); + zephir_check_call_status(); + RETURN_MM(); } -// 1758 "parser.php.c" - break; - case 88: -// 616 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base64Safe) { - phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(59,&ppmsp[-3].minor); - pp_destructor(60,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_bool padding; + zval *len_param = NULL, *padding_param = NULL, s, _0, _1, _2, _3, _4, _5, _6$$3; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&s); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + Z_PARAM_BOOL(padding) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 2, &len_param, &padding_param); + if (!len_param) { + len = 0; + } else { + len = zephir_get_intval(len_param); + } + if (!padding_param) { + padding = 0; + } else { + padding = zephir_get_boolval(padding_param); + } + + + ZVAL_LONG(&_1, len); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "base64", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_2, "base64_encode", NULL, 230, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "+/"); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "-_"); + ZEPHIR_CALL_FUNCTION(&s, "strtr", NULL, 5, &_2, &_3, &_4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "#[^a-z0-9_=-]+#i"); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, ""); + ZEPHIR_CALL_FUNCTION(&_5, "preg_replace", NULL, 40, &_3, &_4, &s); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&s, &_5); + if (!(padding)) { + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "="); + zephir_fast_trim(return_value, &s, &_6$$3, ZEPHIR_TRIM_RIGHT); + RETURN_MM(); + } + RETURN_CCTOR(&s); } -// 1767 "parser.php.c" - break; - case 92: - case 150: -// 636 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, bytes) { - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_INTEGER, ppmsp[0].minor.pp0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(len) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 16; + } else { + len = zephir_get_intval(len_param); + } + + + if (len <= 0) { + len = 16; + } + ZVAL_LONG(&_0, len); + ZEPHIR_RETURN_CALL_FUNCTION("random_bytes", NULL, 266, &_0); + zephir_check_call_status(); + RETURN_MM(); } -// 1775 "parser.php.c" - break; - case 93: - case 151: -// 640 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, hex) { - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_HINTEGER, ppmsp[0].minor.pp0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1, _2, _3; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { + len = zephir_get_intval(len_param); + } + + + ZVAL_LONG(&_1, len); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "H*"); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 267, &_2, &_0); + zephir_check_call_status(); + ZEPHIR_MAKE_REF(&_3); + ZEPHIR_RETURN_CALL_FUNCTION("array_shift", NULL, 21, &_3); + ZEPHIR_UNREF(&_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1783 "parser.php.c" - break; - case 94: - case 157: -// 644 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, number) { - phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_NPLACEHOLDER, ppmsp[0].minor.pp0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(len) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &len_param); + len = zephir_get_intval(len_param); + + + if (UNEXPECTED(len <= 0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_exception_ce, "Input number must be a positive integer", "phalcon/Encryption/Security/Random.zep", 272); + return; + } + ZVAL_LONG(&_0, 0); + ZVAL_LONG(&_1, len); + ZEPHIR_RETURN_CALL_FUNCTION("random_int", NULL, 268, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -// 1791 "parser.php.c" - break; - case 95: - case 158: -// 648 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, uuid) { - phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_SPLACEHOLDER, ppmsp[0].minor.pp0); + zval ary, _0, _1, _2, _3, _4, _5, _6, _7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&ary); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + + + ZEPHIR_MM_GROW(); + + ZVAL_LONG(&_1, 16); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "N1a/n1b/n1c/n1d/n1e/N1f"); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 267, &_2, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&ary, "array_values", NULL, 14, &_3); + zephir_check_call_status(); + zephir_array_fetch_long(&_4, &ary, 2, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/Random.zep", 311); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_LONG(&_2, ((((int) (zephir_get_numberval(&_4)) & 0x0fff)) | 0x4000)); + zephir_array_update_long(&ary, 2, &_2, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + zephir_array_fetch_long(&_5, &ary, 3, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/Random.zep", 312); + ZEPHIR_INIT_VAR(&_6); + ZVAL_LONG(&_6, ((((int) (zephir_get_numberval(&_5)) & 0x3fff)) | 0x8000)); + zephir_array_update_long(&ary, 3, &_6, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_INIT_VAR(&_7); + ZVAL_STRING(&_7, "%08x-%04x-%04x-%04x-%04x%08x"); + ZEPHIR_MAKE_REF(&ary); + ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 269, &ary, &_7); + ZEPHIR_UNREF(&ary); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_STRING(&_7, "sprintf"); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_7, &ary); + zephir_check_call_status(); + RETURN_MM(); } -// 1799 "parser.php.c" - break; - case 96: - case 159: -// 652 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base) { - phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_BPLACEHOLDER, ppmsp[0].minor.pp0); -} -// 1807 "parser.php.c" - break; - case 97: -// 660 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_MINUS, NULL, &ppmsp[0].minor.pp202); - pp_destructor(21,&ppmsp[-1].minor); -} -// 1815 "parser.php.c" - break; - case 98: -// 664 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_SUB, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(21,&ppmsp[-1].minor); -} -// 1823 "parser.php.c" - break; - case 99: -// 668 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ADD, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(20,&ppmsp[-1].minor); -} -// 1831 "parser.php.c" - break; - case 100: -// 672 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_MUL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(18,&ppmsp[-1].minor); + unsigned char _7$$3, _10$$5; + double _4$$3, _8$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL; + zend_long base, ZEPHIR_LAST_CALL_STATUS; + zval *alphabet_param = NULL, *base_param = NULL, *n = NULL, n_sub, __$null, bytes, idx, _0, _1, *_2, _3, _5$$4, _9$$6; + zval alphabet, byteString; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&alphabet); + ZVAL_UNDEF(&byteString); + ZVAL_UNDEF(&n_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&bytes); + ZVAL_UNDEF(&idx); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_9$$6); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(alphabet) + Z_PARAM_LONG(base) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(n) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 1, &alphabet_param, &base_param, &n); + zephir_get_strval(&alphabet, alphabet_param); + base = zephir_get_intval(base_param); + if (!n) { + n = &n_sub; + n = &__$null; + } + + + ZEPHIR_INIT_VAR(&byteString); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, n); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "C*"); + ZEPHIR_CALL_FUNCTION(&bytes, "unpack", NULL, 267, &_1, &_0); + zephir_check_call_status(); + zephir_is_iterable(&bytes, 0, "phalcon/Encryption/Security/Random.zep", 351); + if (Z_TYPE_P(&bytes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&bytes), _2) + { + ZEPHIR_INIT_NVAR(&idx); + ZVAL_COPY(&idx, _2); + _4$$3 = zephir_safe_mod_zval_long(&idx, 64); + ZEPHIR_INIT_NVAR(&idx); + ZVAL_DOUBLE(&idx, _4$$3); + if (ZEPHIR_GE_LONG(&idx, base)) { + ZVAL_LONG(&_5$$4, (base - 1)); + ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_6, 0, &_5$$4); + zephir_check_call_status(); + } + _7$$3 = ZEPHIR_STRING_OFFSET(&alphabet, zephir_get_intval(&idx)); + zephir_concat_self_char(&byteString, _7$$3); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &bytes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &bytes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&idx, &bytes, "current", NULL, 0); + zephir_check_call_status(); + _8$$5 = zephir_safe_mod_zval_long(&idx, 64); + ZEPHIR_INIT_NVAR(&idx); + ZVAL_DOUBLE(&idx, _8$$5); + if (ZEPHIR_GE_LONG(&idx, base)) { + ZVAL_LONG(&_9$$6, (base - 1)); + ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_6, 0, &_9$$6); + zephir_check_call_status(); + } + _10$$5 = ZEPHIR_STRING_OFFSET(&alphabet, zephir_get_intval(&idx)); + zephir_concat_self_char(&byteString, _10$$5); + ZEPHIR_CALL_METHOD(NULL, &bytes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&idx); + RETURN_CTOR(&byteString); } -// 1839 "parser.php.c" - break; - case 101: -// 676 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Builder) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_DIV, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(17,&ppmsp[-1].minor); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT, Builder, phalcon, encryption_security_jwt_builder, phalcon_encryption_security_jwt_builder_method_entry, 0); + + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("claims"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("encode"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("jose"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("passphrase"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("signer"), ZEND_ACC_PRIVATE); + return SUCCESS; } -// 1847 "parser.php.c" - break; - case 102: -// 680 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, __construct) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_MOD, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(19,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *signer, signer_sub, _0, _1, _2, _3, _4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &signer); + + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("signer"), signer); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_support_helper_json_encode_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("signer"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getalgheader", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "alg"); + ZEPHIR_CALL_METHOD(NULL, &_1, "set", NULL, 0, &_4, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -// 1855 "parser.php.c" - break; - case 103: -// 684 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, init) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_AND, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(10,&ppmsp[-1].minor); + zval _2; + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, ""); + zephir_update_property_zval(this_ptr, ZEND_STRL("passphrase"), &_0); + ZEPHIR_INIT_NVAR(&_0); + object_init_ex(&_0, phalcon_support_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 22); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), &_0); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_support_collection_ce); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + add_assoc_stringl_ex(&_2, SL("typ"), SL("JWT")); + add_assoc_stringl_ex(&_2, SL("alg"), SL("none")); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 22, &_2); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("jose"), &_1); + RETURN_THIS(); } -// 1863 "parser.php.c" - break; - case 104: -// 688 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addClaim) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_OR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(11,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &value); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); } -// 1871 "parser.php.c" - break; - case 105: -// 692 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addHeader) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_AND, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(14,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &value); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); } -// 1879 "parser.php.c" - break; - case 106: -// 696 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getAudience) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_OR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(15,&ppmsp[-1].minor); + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "aud"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -// 1887 "parser.php.c" - break; - case 107: -// 700 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getClaims) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_XOR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(16,&ppmsp[-1].minor); + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -// 1895 "parser.php.c" - break; - case 108: -// 704 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getContentType) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_EQUALS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(4,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cty"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1903 "parser.php.c" - break; - case 109: -// 708 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getExpirationTime) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOTEQUALS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(5,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "exp"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "int"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1911 "parser.php.c" - break; - case 110: -// 712 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getHeaders) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_LESS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(6,&ppmsp[-1].minor); + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -// 1919 "parser.php.c" - break; - case 111: -// 716 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getId) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_GREATER, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(7,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "jti"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1927 "parser.php.c" - break; - case 112: -// 720 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getIssuedAt) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_GREATEREQUAL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(8,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "iat"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "int"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1935 "parser.php.c" - break; - case 113: -// 724 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getIssuer) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_LESSEQUAL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(9,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "iss"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1943 "parser.php.c" - break; - case 114: -// 728 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getNotBefore) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_LIKE, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(12,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "nbf"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "int"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1951 "parser.php.c" - break; - case 115: -// 732 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getSubject) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NLIKE, &ppmsp[-3].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(24,&ppmsp[-2].minor); - pp_destructor(12,&ppmsp[-1].minor); + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "sub"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); } -// 1960 "parser.php.c" - break; - case 116: -// 736 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getToken) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ILIKE, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(13,&ppmsp[-1].minor); + zval claims, encodedClaims, encodedHeaders, encodedSignature, headers, signature, signatureHash, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&claims); + ZVAL_UNDEF(&encodedClaims); + ZVAL_UNDEF(&encodedHeaders); + ZVAL_UNDEF(&encodedSignature); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&signature); + ZVAL_UNDEF(&signatureHash); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("passphrase"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_EMPTY(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid passphrase (empty)", "phalcon/Encryption/Security/JWT/Builder.zep", 220); + return; + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &_1, "__invoke", NULL, 0, &_3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encodedClaims, this_ptr, "encodeurl", NULL, 255, &_2); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&claims); + object_init_ex(&claims, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &claims, "__construct", NULL, 256, &_4, &encodedClaims); + zephir_check_call_status(); + zephir_read_property(&_5, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6, &_5, "__invoke", NULL, 0, &_7); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encodedHeaders, this_ptr, "encodeurl", NULL, 255, &_6); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&headers); + object_init_ex(&headers, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &headers, "__construct", NULL, 256, &_8, &encodedHeaders); + zephir_check_call_status(); + zephir_read_property(&_9, this_ptr, ZEND_STRL("signer"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_CONCAT_VSV(&_10, &encodedHeaders, ".", &encodedClaims); + zephir_read_property(&_11, this_ptr, ZEND_STRL("passphrase"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&signatureHash, &_9, "sign", NULL, 0, &_10, &_11); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encodedSignature, this_ptr, "encodeurl", NULL, 255, &signatureHash); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&signature); + object_init_ex(&signature, phalcon_encryption_security_jwt_token_signature_ce); + ZEPHIR_CALL_METHOD(NULL, &signature, "__construct", NULL, 257, &signatureHash, &encodedSignature); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_token_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 258, &headers, &claims, &signature); + zephir_check_call_status(); + RETURN_MM(); } -// 1968 "parser.php.c" - break; - case 117: -// 740 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getPassphrase) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NILIKE, &ppmsp[-3].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(24,&ppmsp[-2].minor); - pp_destructor(13,&ppmsp[-1].minor); + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "passphrase"); } -// 1977 "parser.php.c" - break; - case 118: - case 121: -// 744 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setAudience) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_IN, &ppmsp[-4].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(23,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *audience, audience_sub, aud, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&audience_sub); + ZVAL_UNDEF(&aud); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(audience) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &audience); + + + _0 = Z_TYPE_P(audience) != IS_STRING; + if (_0) { + _0 = Z_TYPE_P(audience) != IS_ARRAY; + } + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Audience", "phalcon/Encryption/Security/JWT/Builder.zep", 270); + return; + } + if (Z_TYPE_P(audience) == IS_STRING) { + ZEPHIR_INIT_VAR(&aud); + zephir_create_array(&aud, 1, 0); + zephir_array_fast_append(&aud, audience); + } else { + ZEPHIR_CPY_WRT(&aud, audience); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "aud"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &aud); + zephir_check_call_status(); + RETURN_MM(); } -// 1988 "parser.php.c" - break; - case 119: - case 122: -// 748 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setContentType) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOTIN, &ppmsp[-5].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(24,&ppmsp[-4].minor); - pp_destructor(23,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *contentType_param = NULL, _0, _1; + zval contentType; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&contentType); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(contentType) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &contentType_param); + zephir_get_strval(&contentType, contentType_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cty"); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &_1, &contentType); + zephir_check_call_status(); + RETURN_THIS(); } -// 2000 "parser.php.c" - break; - case 120: -// 752 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setExpirationTime) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_SUBQUERY, &ppmsp[-1].minor.pp202, NULL); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ×tamp_param); + timestamp = zephir_get_intval(timestamp_param); + + + ZEPHIR_INIT_VAR(&_0); + zephir_time(&_0); + if (ZEPHIR_GT_LONG(&_0, timestamp)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Expiration Time", "phalcon/Encryption/Security/JWT/Builder.zep", 315); + return; + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "exp"); + ZVAL_LONG(&_2, timestamp); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -// 2009 "parser.php.c" - break; - case 123: -// 764 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setId) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_EXISTS, NULL, &ppmsp[-1].minor.pp202); - pp_destructor(66,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *id_param = NULL, _0; + zval id; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&id); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(id) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &id_param); + if (UNEXPECTED(Z_TYPE_P(id_param) != IS_STRING && Z_TYPE_P(id_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(id_param) == IS_STRING)) { + zephir_get_strval(&id, id_param); + } else { + ZEPHIR_INIT_VAR(&id); + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "jti"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &id); + zephir_check_call_status(); + RETURN_MM(); } -// 2019 "parser.php.c" - break; - case 124: -// 768 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setIssuedAt) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_AGAINST, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(1,&ppmsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ×tamp_param); + if (UNEXPECTED(Z_TYPE_P(timestamp_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'timestamp' must be of the type int")); + RETURN_MM_NULL(); + } + timestamp = Z_LVAL_P(timestamp_param); + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "iat"); + ZVAL_LONG(&_1, timestamp); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -// 2027 "parser.php.c" - break; - case 125: -// 772 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setIssuer) { - { - zval qualified; - phql_ret_raw_qualified_name(&qualified, ppmsp[-1].minor.pp0, NULL); - phql_ret_expr(&ppgotominor.pp202, PHQL_T_CAST, &ppmsp[-3].minor.pp202, &qualified); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *issuer_param = NULL, _0; + zval issuer; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&issuer); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(issuer) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &issuer_param); + if (UNEXPECTED(Z_TYPE_P(issuer_param) != IS_STRING && Z_TYPE_P(issuer_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'issuer' must be of the type string")); + RETURN_MM_NULL(); } - pp_destructor(67,&ppmsp[-5].minor); - pp_destructor(45,&ppmsp[-4].minor); - pp_destructor(33,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + if (EXPECTED(Z_TYPE_P(issuer_param) == IS_STRING)) { + zephir_get_strval(&issuer, issuer_param); + } else { + ZEPHIR_INIT_VAR(&issuer); + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "iss"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &issuer); + zephir_check_call_status(); + RETURN_MM(); } -// 2042 "parser.php.c" - break; - case 126: -// 780 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setNotBefore) { - { - zval qualified; - phql_ret_raw_qualified_name(&qualified, ppmsp[-1].minor.pp0, NULL); - phql_ret_expr(&ppgotominor.pp202, PHQL_T_CONVERT, &ppmsp[-3].minor.pp202, &qualified); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ×tamp_param); + if (UNEXPECTED(Z_TYPE_P(timestamp_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'timestamp' must be of the type int")); + RETURN_MM_NULL(); } - pp_destructor(68,&ppmsp[-5].minor); - pp_destructor(45,&ppmsp[-4].minor); - pp_destructor(69,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); + timestamp = Z_LVAL_P(timestamp_param); + + + ZEPHIR_INIT_VAR(&_0); + zephir_time(&_0); + if (ZEPHIR_LT_LONG(&_0, timestamp)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Not Before", "phalcon/Encryption/Security/JWT/Builder.zep", 389); + return; + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "nbf"); + ZVAL_LONG(&_2, timestamp); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -// 2057 "parser.php.c" - break; - case 127: -// 788 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setSubject) { - phql_ret_expr(&ppgotominor.pp202, PHQL_T_CASE, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(70,&ppmsp[-3].minor); - pp_destructor(71,&ppmsp[0].minor); -} -// 2066 "parser.php.c" - break; - case 130: -// 800 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_WHEN, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(72,&ppmsp[-3].minor); - pp_destructor(73,&ppmsp[-1].minor); -} -// 2075 "parser.php.c" - break; - case 131: -// 804 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ELSE, &ppmsp[0].minor.pp202, NULL); - pp_destructor(74,&ppmsp[-1].minor); -} -// 2083 "parser.php.c" - break; - case 133: -// 816 "parser.php.lemon" -{ - phql_ret_func_call(&ppgotominor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202, &ppmsp[-2].minor.pp202); - pp_destructor(45,&ppmsp[-3].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2092 "parser.php.c" - break; - case 134: -// 824 "parser.php.lemon" -{ - phql_ret_distinct(&ppgotominor.pp202); - pp_destructor(29,&ppmsp[0].minor); -} -// 2100 "parser.php.c" - break; - case 142: -// 868 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ISNULL, &ppmsp[-2].minor.pp202, NULL); - pp_destructor(22,&ppmsp[-1].minor); - pp_destructor(75,&ppmsp[0].minor); -} -// 2109 "parser.php.c" - break; - case 143: -// 872 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ISNOTNULL, &ppmsp[-3].minor.pp202, NULL); - pp_destructor(22,&ppmsp[-2].minor); - pp_destructor(24,&ppmsp[-1].minor); - pp_destructor(75,&ppmsp[0].minor); -} -// 2119 "parser.php.c" - break; - case 144: -// 876 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BETWEEN, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(2,&ppmsp[-1].minor); -} -// 2127 "parser.php.c" - break; - case 145: -// 880 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BETWEEN_NOT, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(3,&ppmsp[-1].minor); -} -// 2135 "parser.php.c" - break; - case 146: -// 884 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOT, NULL, &ppmsp[0].minor.pp202); - pp_destructor(24,&ppmsp[-1].minor); -} -// 2143 "parser.php.c" - break; - case 147: -// 888 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_NOT, NULL, &ppmsp[0].minor.pp202); - pp_destructor(25,&ppmsp[-1].minor); -} -// 2151 "parser.php.c" - break; - case 148: -// 892 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ENCLOSED, &ppmsp[-1].minor.pp202, NULL); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2160 "parser.php.c" - break; - case 152: -// 908 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_STRING, ppmsp[0].minor.pp0); -} -// 2167 "parser.php.c" - break; - case 153: -// 912 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_DOUBLE, ppmsp[0].minor.pp0); -} -// 2174 "parser.php.c" - break; - case 154: -// 916 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_NULL, NULL); - pp_destructor(75,&ppmsp[0].minor); -} -// 2182 "parser.php.c" - break; - case 155: -// 920 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_TRUE, NULL); - pp_destructor(78,&ppmsp[0].minor); -} -// 2190 "parser.php.c" - break; - case 156: -// 924 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_FALSE, NULL); - pp_destructor(79,&ppmsp[0].minor); -} -// 2198 "parser.php.c" - break; - case 160: -// 947 "parser.php.lemon" -{ - phql_ret_qualified_name(&ppgotominor.pp202, NULL, ppmsp[-2].minor.pp0, ppmsp[0].minor.pp0); - pp_destructor(32,&ppmsp[-1].minor); -} -// 2206 "parser.php.c" - break; - }; - ppgoto = ppRuleInfo[ppruleno].lhs; - ppsize = ppRuleInfo[ppruleno].nrhs; - pppParser->ppidx -= ppsize; - ppact = pp_find_reduce_action(pppParser,ppgoto); - if( ppact < PPNSTATE ){ - pp_shift(pppParser,ppact,ppgoto,&ppgotominor); - }else if( ppact == PPNSTATE + PPNRULE + 1 ){ - pp_accept(pppParser); - } -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *subject_param = NULL, _0; + zval subject; + zval *this_ptr = getThis(); -static void pp_parse_failed( - ppParser *pppParser /* The parser */ -){ - phql_ARG_FETCH; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sFail!\n",ppTracePrompt); - } + ZVAL_UNDEF(&subject); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(subject) + ZEND_PARSE_PARAMETERS_END(); #endif - while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &subject_param); + if (UNEXPECTED(Z_TYPE_P(subject_param) != IS_STRING && Z_TYPE_P(subject_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'subject' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(subject_param) == IS_STRING)) { + zephir_get_strval(&subject, subject_param); + } else { + ZEPHIR_INIT_VAR(&subject); + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "sub"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &subject); + zephir_check_call_status(); + RETURN_MM(); } -static void pp_syntax_error( - ppParser *pppParser, /* The parser */ - int ppmajor, /* The major type of the error token */ - PPMINORTYPE ppminor /* The minor type of the error token */ -){ - phql_ARG_FETCH; -#define PPTOKEN (ppminor.pp0) -// 34 "parser.php.lemon" +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setPassphrase) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *passphrase_param = NULL, _0, _1, _2, _3; + zval passphrase; + zval *this_ptr = getThis(); - if (status->scanner_state->start_length) { - { + ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif - char *token_name = NULL; - int token_found = 0; - unsigned int token_length; - const phql_token_names *tokens = phql_tokens; - int active_token = status->scanner_state->active_token; - int near_length = status->scanner_state->start_length; - if (active_token) { + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &passphrase_param); + if (UNEXPECTED(Z_TYPE_P(passphrase_param) != IS_STRING && Z_TYPE_P(passphrase_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'passphrase' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(passphrase_param) == IS_STRING)) { + zephir_get_strval(&passphrase, passphrase_param); + } else { + ZEPHIR_INIT_VAR(&passphrase); + } - do { - if (tokens->code == active_token) { - token_name = tokens->name; - token_length = tokens->length; - token_found = 1; - break; - } - ++tokens; - } while (tokens[0].code != 0); - } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/(?=^.{16,}$)((?=.*\\d)|(?=.*\\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/"); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "/(?=^.{16,}$)((?=.*\\d)|(?=.*\\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/"); + zephir_preg_match(&_2, &_3, &passphrase, &_0, 0, 0 , 0 ); + if (!(zephir_is_true(&_2))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid passphrase (too weak)", "phalcon/Encryption/Security/JWT/Builder.zep", 427); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("passphrase"), &passphrase); + RETURN_THIS(); +} - if (!token_name) { - token_length = strlen("UNKNOWN"); - token_name = estrndup("UNKNOWN", token_length); - token_found = 0; - } +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setClaim) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); - status->syntax_error_len = 96 + status->token->len + token_length + near_length + status->phql_length;; - status->syntax_error = emalloc(sizeof(char) * status->syntax_error_len); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); +#endif - if (near_length > 0) { - if (status->token->value) { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), near to '%s', when parsing: %s (%d)", token_name, status->token->value, status->scanner_state->start, status->phql, status->phql_length); - } else { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, near to '%s', when parsing: %s (%d)", token_name, status->scanner_state->start, status->phql, status->phql_length); - } - } else { - if (active_token != PHQL_T_IGNORE) { - if (status->token->value) { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), at the end of query, when parsing: %s (%d)", token_name, status->token->value, status->phql, status->phql_length); - } else { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, at the end of query, when parsing: %s (%d)", token_name, status->phql, status->phql_length); - } - } else { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected EOF, at the end of query"); - } - status->syntax_error[status->syntax_error_len - 1] = '\0'; - } - if (!token_found) { - if (token_name) { - efree(token_name); - } - } - } + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &name_param, &value); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - status->syntax_error_len = strlen("Syntax error, unexpected EOF"); - status->syntax_error = estrndup("Syntax error, unexpected EOF", status->syntax_error_len); + ZEPHIR_INIT_VAR(&name); } - status->status = PHQL_PARSING_FAILED; -// 2315 "parser.php.c" - phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); } -static void pp_accept( - ppParser *pppParser /* The parser */ -){ - phql_ARG_FETCH; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sAccept!\n",ppTracePrompt); - } +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, encodeUrl) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, _0, _1, _2, _3, _4; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); #endif - while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + + + ZEPHIR_CALL_FUNCTION(&_0, "base64_encode", NULL, 230, &input); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "+/"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "-_"); + ZEPHIR_CALL_FUNCTION(&_3, "strtr", NULL, 5, &_0, &_1, &_2); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "="); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, ""); + ZEPHIR_INIT_VAR(&_4); + zephir_fast_str_replace(&_4, &_1, &_2, &_3); + RETURN_CCTOR(&_4); } -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "phql_Alloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -static void phql_( - void *ppp, /* The parser */ - int ppmajor, /* The major token code number */ - phql_TOKENTYPE ppminor /* The value for the token */ - phql_ARG_PDECL /* Optional %extra_argument parameter */ -){ - PPMINORTYPE ppminorunion; - int ppact; /* The parser action. */ - int ppendofinput; /* True if we are at the end of input */ - int pperrorhit = 0; /* True if ppmajor has invoked an error */ - ppParser *pppParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - pppParser = (ppParser*)ppp; - if( pppParser->ppidx<0 ){ - if( ppmajor==0 ) return; - pppParser->ppidx = 0; - pppParser->pperrcnt = -1; - pppParser->ppstack[0].stateno = 0; - pppParser->ppstack[0].major = 0; - } - ppminorunion.pp0 = ppminor; - ppendofinput = (ppmajor==0); - phql_ARG_STORE; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sInput %s\n",ppTracePrompt,ppTokenName[ppmajor]); - } -#endif - do{ - ppact = pp_find_shift_action(pppParser,ppmajor); - if( ppactpperrcnt--; - if( ppendofinput && pppParser->ppidx>=0 ){ - ppmajor = 0; - }else{ - ppmajor = PPNOCODE; - } - }else if( ppact < PPNSTATE + PPNRULE ){ - pp_reduce(pppParser,ppact-PPNSTATE); - }else if( ppact == PP_ERROR_ACTION ){ - int ppmx; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sSyntax Error!\n",ppTracePrompt); - } -#endif -#ifdef PPERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( pppParser->pperrcnt<0 ){ - pp_syntax_error(pppParser,ppmajor,ppminorunion); - } - ppmx = pppParser->ppstack[pppParser->ppidx].major; - if( ppmx==PPERRORSYMBOL || pperrorhit ){ -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sDiscard input token %s\n", - ppTracePrompt,ppTokenName[ppmajor]); - } -#endif - pp_destructor(ppmajor,&ppminorunion); - ppmajor = PPNOCODE; - }else{ - while( - pppParser->ppidx >= 0 && - ppmx != PPERRORSYMBOL && - (ppact = pp_find_shift_action(pppParser,PPERRORSYMBOL)) >= PPNSTATE - ){ - pp_pop_parser_stack(pppParser); - } - if( pppParser->ppidx < 0 || ppmajor==0 ){ - pp_destructor(ppmajor,&ppminorunion); - pp_parse_failed(pppParser); - ppmajor = PPNOCODE; - }else if( ppmx!=PPERRORSYMBOL ){ - PPMINORTYPE u2; - u2.PPERRSYMDT = 0; - pp_shift(pppParser,ppact,PPERRORSYMBOL,&u2); - } - } - pppParser->pperrcnt = 3; - pperrorhit = 1; -#else /* PPERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( pppParser->pperrcnt<=0 ){ - pp_syntax_error(pppParser,ppmajor,ppminorunion); - } - pppParser->pperrcnt = 3; - pp_destructor(ppmajor,&ppminorunion); - if( ppendofinput ){ - pp_parse_failed(pppParser); - } - ppmajor = PPNOCODE; +#ifdef HAVE_CONFIG_H #endif - }else{ - pp_accept(pppParser); - ppmajor = PPNOCODE; - } - }while( ppmajor!=PPNOCODE && pppParser->ppidx>=0 ); - return; -} -/* base.c - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ -const phql_token_names phql_tokens[] = -{ - { SL("INTEGER"), PHQL_T_INTEGER }, - { SL("DOUBLE"), PHQL_T_DOUBLE }, - { SL("STRING"), PHQL_T_STRING }, - { SL("IDENTIFIER"), PHQL_T_IDENTIFIER }, - { SL("HEXAINTEGER"), PHQL_T_HINTEGER }, - { SL("MINUS"), PHQL_T_MINUS }, - { SL("+"), PHQL_T_ADD }, - { SL("-"), PHQL_T_SUB }, - { SL("*"), PHQL_T_MUL }, - { SL("/"), PHQL_T_DIV }, - { SL("&"), PHQL_T_BITWISE_AND }, - { SL("|"), PHQL_T_BITWISE_OR }, - { SL("%%"), PHQL_T_MOD }, - { SL("AND"), PHQL_T_AND }, - { SL("OR"), PHQL_T_OR }, - { SL("LIKE"), PHQL_T_LIKE }, - { SL("ILIKE"), PHQL_T_ILIKE }, - { SL("DOT"), PHQL_T_DOT }, - { SL("COLON"), PHQL_T_COLON }, - { SL("COMMA"), PHQL_T_COMMA }, - { SL("EQUALS"), PHQL_T_EQUALS }, - { SL("NOT EQUALS"), PHQL_T_NOTEQUALS }, - { SL("NOT"), PHQL_T_NOT }, - { SL("<"), PHQL_T_LESS }, - { SL("<="), PHQL_T_LESSEQUAL }, - { SL(">"), PHQL_T_GREATER }, - { SL(">="), PHQL_T_GREATEREQUAL }, - { SL("("), PHQL_T_PARENTHESES_OPEN }, - { SL(")"), PHQL_T_PARENTHESES_CLOSE }, - { SL("NUMERIC PLACEHOLDER"), PHQL_T_NPLACEHOLDER }, - { SL("STRING PLACEHOLDER"), PHQL_T_SPLACEHOLDER }, - { SL("UPDATE"), PHQL_T_UPDATE }, - { SL("SET"), PHQL_T_SET }, - { SL("WHERE"), PHQL_T_WHERE }, - { SL("DELETE"), PHQL_T_DELETE }, - { SL("FROM"), PHQL_T_FROM }, - { SL("AS"), PHQL_T_AS }, - { SL("INSERT"), PHQL_T_INSERT }, - { SL("INTO"), PHQL_T_INTO }, - { SL("VALUES"), PHQL_T_VALUES }, - { SL("SELECT"), PHQL_T_SELECT }, - { SL("ORDER"), PHQL_T_ORDER }, - { SL("BY"), PHQL_T_BY }, - { SL("LIMIT"), PHQL_T_LIMIT }, - { SL("OFFSET"), PHQL_T_OFFSET }, - { SL("GROUP"), PHQL_T_GROUP }, - { SL("HAVING"), PHQL_T_HAVING }, - { SL("IN"), PHQL_T_IN }, - { SL("ON"), PHQL_T_ON }, - { SL("INNER"), PHQL_T_INNER }, - { SL("JOIN"), PHQL_T_JOIN }, - { SL("LEFT"), PHQL_T_LEFT }, - { SL("RIGHT"), PHQL_T_RIGHT }, - { SL("IS"), PHQL_T_IS }, - { SL("NULL"), PHQL_T_NULL }, - { SL("NOT IN"), PHQL_T_NOTIN }, - { SL("CROSS"), PHQL_T_CROSS }, - { SL("OUTER"), PHQL_T_OUTER }, - { SL("FULL"), PHQL_T_FULL }, - { SL("ASC"), PHQL_T_ASC }, - { SL("DESC"), PHQL_T_DESC }, - { SL("BETWEEN"), PHQL_T_BETWEEN }, - { SL("DISTINCT"), PHQL_T_DISTINCT }, - { SL("AGAINST"), PHQL_T_AGAINST }, - { SL("CAST"), PHQL_T_CAST }, - { SL("CONVERT"), PHQL_T_CONVERT }, - { SL("USING"), PHQL_T_USING }, - { SL("ALL"), PHQL_T_ALL }, - { SL("EXISTS"), PHQL_T_EXISTS }, - { SL("CASE"), PHQL_T_CASE }, - { SL("WHEN"), PHQL_T_WHEN }, - { SL("THEN"), PHQL_T_THEN }, - { SL("ELSE"), PHQL_T_ELSE }, - { SL("END"), PHQL_T_END }, - { SL("FOR"), PHQL_T_FOR }, - { SL("WITH"), PHQL_T_WITH }, - { NULL, 0, 0 } -}; -static void *phql_wrapper_alloc(size_t bytes) -{ - return emalloc(bytes); -} -static void phql_wrapper_free(void *pointer) -{ - efree(pointer); -} -static void phql_parse_with_token(void* phql_parser, int opcode, int parsercode, phql_scanner_token *token, phql_parser_status *parser_status) -{ - phql_parser_token *pToken; +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Validator) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT, Validator, phalcon, encryption_security_jwt_validator, phalcon_encryption_security_jwt_validator_method_entry, 0); - pToken = emalloc(sizeof(phql_parser_token)); - pToken->opcode = opcode; - pToken->token = token->value; - pToken->token_len = token->len; - pToken->free_flag = 1; - phql_(phql_parser, parsercode, pToken, parser_status); + zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("claims"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("errors"), ZEND_ACC_PRIVATE); + zend_declare_property_long(phalcon_encryption_security_jwt_validator_ce, SL("timeShift"), 0, ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("token"), ZEND_ACC_PRIVATE); + phalcon_encryption_security_jwt_validator_ce->create_object = zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator; - token->value = NULL; - token->len = 0; + return SUCCESS; } -static void phql_scanner_error_msg(phql_parser_status *parser_status, zval **error_msg) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, __construct) { + zval _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long timeShift; + zval *token, token_sub, *timeShift_param = NULL, __$null, now, _0; + zval *this_ptr = getThis(); - char *error = NULL, *error_part; - unsigned int length; - phql_scanner_state *state = parser_status->scanner_state; + ZVAL_UNDEF(&token_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&now); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(token, phalcon_encryption_security_jwt_token_token_ce) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(timeShift) + ZEND_PARSE_PARAMETERS_END(); +#endif - ZVAL_UNDEF(*error_msg); - if (state->start) { - length = 64 + state->start_length + parser_status->phql_length; - error = emalloc(sizeof(char) * length); - if (state->start_length > 16) { - error_part = estrndup(state->start, 16); - snprintf(error, length, "Scanning error before '%s...' when parsing: %s (%d)", error_part, parser_status->phql, parser_status->phql_length); - efree(error_part); - } else { - snprintf(error, length, "Scanning error before '%s' when parsing: %s (%d)", state->start, parser_status->phql, parser_status->phql_length); - } - error[length - 1] = '\0'; - ZVAL_STRING(*error_msg, error); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &token, &timeShift_param); + if (!timeShift_param) { + timeShift = 0; } else { - ZVAL_STRING(*error_msg, "Scanning error near to EOF"); + timeShift = zephir_get_intval(timeShift_param); } - if (error) { - efree(error); - } + + ZEPHIR_INIT_VAR(&now); + zephir_time(&now); + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), token); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_LONG(&_0, timeShift); + zephir_update_property_zval(this_ptr, ZEND_STRL("timeShift"), &_0); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 7, 0); + zephir_array_update_string(&_1, SL("aud"), &__$null, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("exp"), &now, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("jti"), &__$null, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("iat"), &now, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("iss"), &__$null, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("nbf"), &now, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("sub"), &__$null, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), &_1); + ZEPHIR_MM_RESTORE(); } -static int phql_parse_phql(zval *result, zval *phql) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, getErrors) { - zval err_msg, *error_msg = &err_msg; - ZVAL_UNDEF(error_msg); - ZVAL_NULL(result); + zval *this_ptr = getThis(); - if (phql_internal_parse_phql(&result, Z_STRVAL_P(phql), Z_STRLEN_P(phql), &error_msg) == FAILURE) { - ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, Z_STRVAL_P(error_msg)); - return FAILURE; - } - return SUCCESS; + + RETURN_MEMBER(getThis(), "errors"); } -static int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length, zval **error_msg) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, get) { - zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; - phql_parser_status *parser_status = NULL; - int scanner_status, status = SUCCESS, error_length, cache_level; - phql_scanner_state *state; - phql_scanner_token token; - void* phql_parser; - char *error; - unsigned long phql_key = 0; - zval *temp_ast; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *claim_param = NULL, _0, _1$$3, _2$$3; + zval claim; + zval *this_ptr = getThis(); - if (!phql) { - ZVAL_STRING(*error_msg, "PHQL statement cannot be NULL"); - return FAILURE; - } + ZVAL_UNDEF(&claim); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(claim) + ZEND_PARSE_PARAMETERS_END(); +#endif - cache_level = phalcon_globals_ptr->orm.cache_level; - if (cache_level >= 0) { - phql_key = zend_inline_hash_func(phql, phql_length + 1); - if (phalcon_globals_ptr->orm.parser_cache != NULL) { - if ((temp_ast = zend_hash_index_find(phalcon_globals_ptr->orm.parser_cache, phql_key)) != NULL) { - ZVAL_ZVAL(*result, temp_ast, 1, 0); - Z_TRY_ADDREF_P(*result); - return SUCCESS; - } - } - } - phql_parser = phql_Alloc(phql_wrapper_alloc); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &claim_param); + zephir_get_strval(&claim, claim_param); - parser_status = emalloc(sizeof(phql_parser_status)); - state = emalloc(sizeof(phql_scanner_state)); - parser_status->status = PHQL_PARSING_OK; - parser_status->scanner_state = state; - ZVAL_UNDEF(&parser_status->ret); + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &claim)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2$$3, &_1$$3, &claim, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Validator.zep", 87); + RETURN_CTOR(&_2$$3); + } + RETURN_MM_NULL(); +} - parser_status->syntax_error = NULL; - parser_status->token = &token; - parser_status->enable_literals = phalcon_globals_ptr->orm.enable_literals; - parser_status->phql = phql; - parser_status->phql_length = phql_length; +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, set) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *claim_param = NULL, *value, value_sub; + zval claim; + zval *this_ptr = getThis(); - state->active_token = 0; - state->start = phql; - state->start_length = 0; - state->end = state->start; + ZVAL_UNDEF(&claim); + ZVAL_UNDEF(&value_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(claim) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); +#endif - token.value = NULL; - token.len = 0; - while (0 <= (scanner_status = phql_get_token(state, &token))) { + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &claim_param, &value); + zephir_get_strval(&claim, claim_param); - /* Calculate the 'start' length */ - state->start_length = (phql + phql_length - state->start); - state->active_token = token.opcode; + zephir_update_property_array(this_ptr, SL("claims"), &claim, value); + RETURN_THIS(); +} - /* Parse the token found */ - switch (token.opcode) { +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, setToken) +{ + zval *token, token_sub; + zval *this_ptr = getThis(); - case PHQL_T_IGNORE: - break; + ZVAL_UNDEF(&token_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(token, phalcon_encryption_security_jwt_token_token_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif - case PHQL_T_ADD: - phql_(phql_parser, PHQL_PLUS, NULL, parser_status); - break; - case PHQL_T_SUB: - phql_(phql_parser, PHQL_MINUS, NULL, parser_status); - break; - case PHQL_T_MUL: - phql_(phql_parser, PHQL_TIMES, NULL, parser_status); - break; - case PHQL_T_DIV: - phql_(phql_parser, PHQL_DIVIDE, NULL, parser_status); - break; - case PHQL_T_MOD: - phql_(phql_parser, PHQL_MOD, NULL, parser_status); - break; - case PHQL_T_AND: - phql_(phql_parser, PHQL_AND, NULL, parser_status); - break; - case PHQL_T_OR: - phql_(phql_parser, PHQL_OR, NULL, parser_status); - break; - case PHQL_T_EQUALS: - phql_(phql_parser, PHQL_EQUALS, NULL, parser_status); - break; - case PHQL_T_NOTEQUALS: - phql_(phql_parser, PHQL_NOTEQUALS, NULL, parser_status); - break; - case PHQL_T_LESS: - phql_(phql_parser, PHQL_LESS, NULL, parser_status); - break; - case PHQL_T_GREATER: - phql_(phql_parser, PHQL_GREATER, NULL, parser_status); - break; - case PHQL_T_GREATEREQUAL: - phql_(phql_parser, PHQL_GREATEREQUAL, NULL, parser_status); - break; - case PHQL_T_LESSEQUAL: - phql_(phql_parser, PHQL_LESSEQUAL, NULL, parser_status); - break; - case PHQL_T_IDENTIFIER: - phql_parse_with_token(phql_parser, PHQL_T_IDENTIFIER, PHQL_IDENTIFIER, &token, parser_status); - break; + zephir_fetch_params_without_memory_grow(1, 0, &token); - case PHQL_T_DOT: - phql_(phql_parser, PHQL_DOT, NULL, parser_status); - break; - case PHQL_T_COMMA: - phql_(phql_parser, PHQL_COMMA, NULL, parser_status); - break; - case PHQL_T_PARENTHESES_OPEN: - phql_(phql_parser, PHQL_PARENTHESES_OPEN, NULL, parser_status); - break; - case PHQL_T_PARENTHESES_CLOSE: - phql_(phql_parser, PHQL_PARENTHESES_CLOSE, NULL, parser_status); - break; + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), token); + RETURN_THISW(); +} - case PHQL_T_LIKE: - phql_(phql_parser, PHQL_LIKE, NULL, parser_status); - break; - case PHQL_T_ILIKE: - phql_(phql_parser, PHQL_ILIKE, NULL, parser_status); - break; - case PHQL_T_NOT: - phql_(phql_parser, PHQL_NOT, NULL, parser_status); - break; - case PHQL_T_BITWISE_AND: - phql_(phql_parser, PHQL_BITWISE_AND, NULL, parser_status); - break; - case PHQL_T_BITWISE_OR: - phql_(phql_parser, PHQL_BITWISE_OR, NULL, parser_status); - break; - case PHQL_T_BITWISE_NOT: - phql_(phql_parser, PHQL_BITWISE_NOT, NULL, parser_status); - break; - case PHQL_T_BITWISE_XOR: - phql_(phql_parser, PHQL_BITWISE_XOR, NULL, parser_status); - break; - case PHQL_T_AGAINST: - phql_(phql_parser, PHQL_AGAINST, NULL, parser_status); - break; - case PHQL_T_CASE: - phql_(phql_parser, PHQL_CASE, NULL, parser_status); - break; - case PHQL_T_WHEN: - phql_(phql_parser, PHQL_WHEN, NULL, parser_status); - break; - case PHQL_T_THEN: - phql_(phql_parser, PHQL_THEN, NULL, parser_status); - break; - case PHQL_T_END: - phql_(phql_parser, PHQL_END, NULL, parser_status); - break; - case PHQL_T_ELSE: - phql_(phql_parser, PHQL_ELSE, NULL, parser_status); - break; - case PHQL_T_FOR: - phql_(phql_parser, PHQL_FOR, NULL, parser_status); - break; - case PHQL_T_WITH: - phql_(phql_parser, PHQL_WITH, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateAudience) +{ + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *audience = NULL, audience_sub, item, tokenAudience, _2, _3, _4, _5, *_6, _7, _1$$4, _8$$6, _9$$8; + zval *this_ptr = getThis(); - case PHQL_T_INTEGER: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_INTEGER, PHQL_INTEGER, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_DOUBLE: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_DOUBLE, PHQL_DOUBLE, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_STRING: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_STRING, PHQL_STRING, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_TRUE: - if (parser_status->enable_literals) { - phql_(phql_parser, PHQL_TRUE, NULL, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_FALSE: - if (parser_status->enable_literals) { - phql_(phql_parser, PHQL_FALSE, NULL, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_HINTEGER: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_HINTEGER, PHQL_HINTEGER, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; + ZVAL_UNDEF(&audience_sub); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&tokenAudience); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_9$$8); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(audience) + ZEND_PARSE_PARAMETERS_END(); +#endif - case PHQL_T_NPLACEHOLDER: - phql_parse_with_token(phql_parser, PHQL_T_NPLACEHOLDER, PHQL_NPLACEHOLDER, &token, parser_status); - break; - case PHQL_T_SPLACEHOLDER: - phql_parse_with_token(phql_parser, PHQL_T_SPLACEHOLDER, PHQL_SPLACEHOLDER, &token, parser_status); - break; - case PHQL_T_BPLACEHOLDER: - phql_parse_with_token(phql_parser, PHQL_T_BPLACEHOLDER, PHQL_BPLACEHOLDER, &token, parser_status); - break; - case PHQL_T_FROM: - phql_(phql_parser, PHQL_FROM, NULL, parser_status); - break; - case PHQL_T_UPDATE: - phql_(phql_parser, PHQL_UPDATE, NULL, parser_status); - break; - case PHQL_T_SET: - phql_(phql_parser, PHQL_SET, NULL, parser_status); - break; - case PHQL_T_WHERE: - phql_(phql_parser, PHQL_WHERE, NULL, parser_status); - break; - case PHQL_T_DELETE: - phql_(phql_parser, PHQL_DELETE, NULL, parser_status); - break; - case PHQL_T_INSERT: - phql_(phql_parser, PHQL_INSERT, NULL, parser_status); - break; - case PHQL_T_INTO: - phql_(phql_parser, PHQL_INTO, NULL, parser_status); - break; - case PHQL_T_VALUES: - phql_(phql_parser, PHQL_VALUES, NULL, parser_status); - break; - case PHQL_T_SELECT: - phql_(phql_parser, PHQL_SELECT, NULL, parser_status); - break; - case PHQL_T_AS: - phql_(phql_parser, PHQL_AS, NULL, parser_status); - break; - case PHQL_T_ORDER: - phql_(phql_parser, PHQL_ORDER, NULL, parser_status); - break; - case PHQL_T_BY: - phql_(phql_parser, PHQL_BY, NULL, parser_status); - break; - case PHQL_T_LIMIT: - phql_(phql_parser, PHQL_LIMIT, NULL, parser_status); - break; - case PHQL_T_OFFSET: - phql_(phql_parser, PHQL_OFFSET, NULL, parser_status); - break; - case PHQL_T_GROUP: - phql_(phql_parser, PHQL_GROUP, NULL, parser_status); - break; - case PHQL_T_HAVING: - phql_(phql_parser, PHQL_HAVING, NULL, parser_status); - break; - case PHQL_T_ASC: - phql_(phql_parser, PHQL_ASC, NULL, parser_status); - break; - case PHQL_T_DESC: - phql_(phql_parser, PHQL_DESC, NULL, parser_status); - break; - case PHQL_T_IN: - phql_(phql_parser, PHQL_IN, NULL, parser_status); - break; - case PHQL_T_ON: - phql_(phql_parser, PHQL_ON, NULL, parser_status); - break; - case PHQL_T_INNER: - phql_(phql_parser, PHQL_INNER, NULL, parser_status); - break; - case PHQL_T_JOIN: - phql_(phql_parser, PHQL_JOIN, NULL, parser_status); - break; - case PHQL_T_LEFT: - phql_(phql_parser, PHQL_LEFT, NULL, parser_status); - break; - case PHQL_T_RIGHT: - phql_(phql_parser, PHQL_RIGHT, NULL, parser_status); - break; - case PHQL_T_CROSS: - phql_(phql_parser, PHQL_CROSS, NULL, parser_status); - break; - case PHQL_T_FULL: - phql_(phql_parser, PHQL_FULL, NULL, parser_status); - break; - case PHQL_T_OUTER: - phql_(phql_parser, PHQL_OUTER, NULL, parser_status); - break; - case PHQL_T_IS: - phql_(phql_parser, PHQL_IS, NULL, parser_status); - break; - case PHQL_T_NULL: - phql_(phql_parser, PHQL_NULL, NULL, parser_status); - break; - case PHQL_T_BETWEEN: - phql_(phql_parser, PHQL_BETWEEN, NULL, parser_status); - break; - case PHQL_T_BETWEEN_NOT: - phql_(phql_parser, PHQL_BETWEEN_NOT, NULL, parser_status); - break; - case PHQL_T_DISTINCT: - phql_(phql_parser, PHQL_DISTINCT, NULL, parser_status); - break; - case PHQL_T_ALL: - phql_(phql_parser, PHQL_ALL, NULL, parser_status); - break; - case PHQL_T_CAST: - phql_(phql_parser, PHQL_CAST, NULL, parser_status); - break; - case PHQL_T_CONVERT: - phql_(phql_parser, PHQL_CONVERT, NULL, parser_status); - break; - case PHQL_T_USING: - phql_(phql_parser, PHQL_USING, NULL, parser_status); - break; - case PHQL_T_EXISTS: - phql_(phql_parser, PHQL_EXISTS, NULL, parser_status); - break; + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &audience); + ZEPHIR_SEPARATE_PARAM(audience); - default: - parser_status->status = PHQL_PARSING_FAILED; - error_length = sizeof(char) * 32; - error = emalloc(error_length); - snprintf(error, error_length, "Scanner: Unknown opcode %d", token.opcode); - error[error_length - 1] = '\0'; - ZVAL_STRING(*error_msg, error); - efree(error); + + _0 = Z_TYPE_P(audience) != IS_STRING; + if (_0) { + _0 = Z_TYPE_P(audience) != IS_ARRAY; + } + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Audience must be a string or an array", "phalcon/Encryption/Security/JWT/Validator.zep", 137); + return; + } + if (Z_TYPE_P(audience) == IS_STRING) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, audience); + ZEPHIR_CPY_WRT(audience, &_1$$4); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + array_init(&_4); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "aud"); + ZEPHIR_CALL_METHOD(&tokenAudience, &_3, "get", NULL, 0, &_5, &_4); + zephir_check_call_status(); + zephir_is_iterable(audience, 0, "phalcon/Encryption/Security/JWT/Validator.zep", 152); + if (Z_TYPE_P(audience) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(audience), _6) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _6); + if (1 != zephir_fast_in_array(&item, &tokenAudience)) { + ZEPHIR_INIT_ZVAL_NREF(_8$$6); + ZEPHIR_INIT_NVAR(&_8$$6); + ZVAL_STRING(&_8$$6, "Validation: audience not allowed"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_8$$6); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, audience, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7, audience, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7)) { break; + } + ZEPHIR_CALL_METHOD(&item, audience, "current", NULL, 0); + zephir_check_call_status(); + if (1 != zephir_fast_in_array(&item, &tokenAudience)) { + ZEPHIR_INIT_ZVAL_NREF(_9$$8); + ZEPHIR_INIT_NVAR(&_9$$8); + ZVAL_STRING(&_9$$8, "Validation: audience not allowed"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_9$$8); + } + ZEPHIR_CALL_METHOD(NULL, audience, "next", NULL, 0); + zephir_check_call_status(); } + } + ZEPHIR_INIT_NVAR(&item); + RETURN_THIS(); +} - if (parser_status->status != PHQL_PARSING_OK) { - status = FAILURE; - break; - } +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateExpiration) +{ + zend_bool _7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6, _8, _9, _10$$3; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenExpirationTime = 0; + zval *this_ptr = getThis(); - state->end = state->start; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ×tamp_param); + timestamp = zephir_get_intval(timestamp_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "exp"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + tokenExpirationTime = zephir_get_intval(&_2); + zephir_read_property(&_4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "exp"); + ZEPHIR_CALL_METHOD(&_6, &_5, "has", NULL, 0, &_3); + zephir_check_call_status(); + _7 = zephir_is_true(&_6); + if (_7) { + ZVAL_LONG(&_9, timestamp); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "gettimestamp", NULL, 265, &_9); + zephir_check_call_status(); + _7 = ZEPHIR_GT_LONG(&_8, tokenExpirationTime); + } + if (_7) { + ZEPHIR_INIT_ZVAL_NREF(_10$$3); + ZEPHIR_INIT_VAR(&_10$$3); + ZVAL_STRING(&_10$$3, "Validation: the token has expired"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_10$$3); } + RETURN_THIS(); +} - if (status != FAILURE) { - switch (scanner_status) { +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateId) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *id_param = NULL, tokenId, _0, _1, _2, _3, _5$$3; + zval id, _4; + zval *this_ptr = getThis(); - case PHQL_SCANNER_RETCODE_ERR: - case PHQL_SCANNER_RETCODE_IMPOSSIBLE: - if (Z_TYPE_P(*error_msg) == IS_UNDEF) { - phql_scanner_error_msg(parser_status, error_msg); - } + ZVAL_UNDEF(&id); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&tokenId); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(id) + ZEND_PARSE_PARAMETERS_END(); +#endif - status = FAILURE; - break; - default: - phql_(phql_parser, 0, NULL, parser_status); - } + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &id_param); + zephir_get_strval(&id, id_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "jti"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + zephir_cast_to_string(&_4, &_2); + ZEPHIR_CPY_WRT(&tokenId, &_4); + if (!ZEPHIR_IS_IDENTICAL(&id, &tokenId)) { + ZEPHIR_INIT_ZVAL_NREF(_5$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "Validation: incorrect Id"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_5$$3); } + RETURN_THIS(); +} - state->active_token = 0; - state->start = NULL; +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateIssuedAt) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenIssuedAt = 0; + zval *this_ptr = getThis(); - if (parser_status->status != PHQL_PARSING_OK) { - status = FAILURE; - if (parser_status->syntax_error) { - if (Z_TYPE_P(*error_msg) == IS_UNDEF) { - ZVAL_STRING(*error_msg, parser_status->syntax_error); - } + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif - efree(parser_status->syntax_error); - } + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ×tamp_param); + timestamp = zephir_get_intval(timestamp_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "iat"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + tokenIssuedAt = zephir_get_intval(&_2); + ZVAL_LONG(&_5, timestamp); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettimestamp", NULL, 265, &_5); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&_4, tokenIssuedAt)) { + ZEPHIR_INIT_ZVAL_NREF(_6$$3); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "Validation: the token cannot be used yet (future)"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); } + RETURN_THIS(); +} - phql_Free(phql_parser, phql_wrapper_free); +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateIssuer) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *issuer_param = NULL, tokenIssuer, _0, _1, _2, _3, _5$$3; + zval issuer, _4; + zval *this_ptr = getThis(); - if (status != FAILURE) { - if (parser_status->status == PHQL_PARSING_OK) { - if (Z_TYPE_P(&parser_status->ret) == IS_ARRAY) { + ZVAL_UNDEF(&issuer); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&tokenIssuer); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(issuer) + ZEND_PARSE_PARAMETERS_END(); +#endif - if (phalcon_globals_ptr->orm.cache_level >= 1) { - if (Z_TYPE_P(&parser_status->ret) == IS_ARRAY) { - add_assoc_long(&parser_status->ret, "id", phalcon_globals_ptr->orm.unique_cache_id++); - } - } - ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &issuer_param); + if (UNEXPECTED(Z_TYPE_P(issuer_param) != IS_STRING && Z_TYPE_P(issuer_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'issuer' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(issuer_param) == IS_STRING)) { + zephir_get_strval(&issuer, issuer_param); + } else { + ZEPHIR_INIT_VAR(&issuer); + } - if (cache_level >= 0) { - if (!phalcon_globals_ptr->orm.parser_cache) { - ALLOC_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); - zend_hash_init(phalcon_globals_ptr->orm.parser_cache, 0, NULL, ZVAL_PTR_DTOR, 0); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "iss"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + zephir_cast_to_string(&_4, &_2); + ZEPHIR_CPY_WRT(&tokenIssuer, &_4); + if (!ZEPHIR_IS_IDENTICAL(&issuer, &tokenIssuer)) { + ZEPHIR_INIT_ZVAL_NREF(_5$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "Validation: incorrect issuer"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_5$$3); + } + RETURN_THIS(); +} - Z_TRY_ADDREF_P(*result); +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateNotBefore) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenNotBefore = 0; + zval *this_ptr = getThis(); - zend_hash_index_update( - phalcon_globals_ptr->orm.parser_cache, - phql_key, - *result - ); - } + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif - } + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, ×tamp_param); + timestamp = zephir_get_intval(timestamp_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "nbf"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + tokenNotBefore = zephir_get_intval(&_2); + ZVAL_LONG(&_5, timestamp); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettimestamp", NULL, 265, &_5); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&_4, tokenNotBefore)) { + ZEPHIR_INIT_ZVAL_NREF(_6$$3); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "Validation: the token cannot be used yet (not before)"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); + } + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateSignature) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval passphrase; + zval *signer, signer_sub, *passphrase_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&passphrase); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &signer, &passphrase_param); + zephir_get_strval(&passphrase, passphrase_param); + + + zephir_read_property(&_1, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "getsignature", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, &_2, "gethash", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "getpayload", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, signer, "verify", NULL, 0, &_3, &_5, &passphrase); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_INIT_ZVAL_NREF(_6$$3); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "Validation: the signature does not match"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); + } + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, getTimestamp) +{ + zval *timestamp_param = NULL, _0; + zend_long timestamp; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(1, 0, ×tamp_param); + timestamp = zephir_get_intval(timestamp_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("timeShift"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG((timestamp + zephir_get_numberval(&_0))); +} + +zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator(zend_class_entry *class_type) +{ + zval _0, _2, _1$$3, _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + + + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("errors"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errors"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("claims"), &_3$$4); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } +} - efree(parser_status); - efree(state); - return status; + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Exceptions_UnsupportedAlgorithmException) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Exceptions, UnsupportedAlgorithmException, phalcon, encryption_security_jwt_exceptions_unsupportedalgorithmexception, zend_ce_exception, NULL, 0); + + return SUCCESS; } -/* Generated by re2c 1.1.1 */ -/* scanner.re - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ + #ifdef HAVE_CONFIG_H #endif -#define PPCTYPE unsigned char -#define PPCURSOR (s->start) -#define PPLIMIT (s->end) -#define PPMARKER q -static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { - char *q = PPCURSOR; - int status = PHQL_SCANNER_RETCODE_IMPOSSIBLE; +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Exceptions_ValidatorException) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Exceptions, ValidatorException, phalcon, encryption_security_jwt_exceptions_validatorexception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_AbstractItem) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, AbstractItem, phalcon, encryption_security_jwt_token_abstractitem, phalcon_encryption_security_jwt_token_abstractitem_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_encryption_security_jwt_token_abstractitem_ce, SL("data"), ZEND_ACC_PROTECTED); + phalcon_encryption_security_jwt_token_abstractitem_ce->create_object = zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_AbstractItem; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_AbstractItem, getEncoded) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("encoded"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/AbstractItem.zep", 28); + RETURN_CTORW(&_1); +} + +zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_AbstractItem(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); - while (PHQL_SCANNER_RETCODE_IMPOSSIBLE == status) { - - { - PPCTYPE ppch; - unsigned int ppaccept = 0; - ppch = *PPCURSOR; - switch (ppch) { - case 0x00: goto pp2; - case '\t': - case '\n': - case '\r': - case ' ': goto pp6; - case '!': goto pp9; - case '"': goto pp11; - case '%': goto pp12; - case '&': goto pp14; - case '\'': goto pp16; - case '(': goto pp17; - case ')': goto pp19; - case '*': goto pp21; - case '+': goto pp23; - case ',': goto pp25; - case '-': goto pp27; - case '.': goto pp29; - case '/': goto pp31; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp33; - case ':': goto pp36; - case '<': goto pp38; - case '=': goto pp40; - case '>': goto pp42; - case '?': goto pp44; - case '@': goto pp45; - case 'A': - case 'a': goto pp46; - case 'B': - case 'b': goto pp48; - case 'C': - case 'c': goto pp49; - case 'D': - case 'd': goto pp50; - case 'E': - case 'e': goto pp51; - case 'F': - case 'f': goto pp52; - case 'G': - case 'g': goto pp53; - case 'H': - case 'h': goto pp55; - case 'I': - case 'i': goto pp56; - case 'J': - case 'j': goto pp57; - case 'K': - case 'M': - case 'P': - case 'Q': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'k': - case 'm': - case 'p': - case 'q': - case 'y': - case 'z': goto pp58; - case 'L': - case 'l': goto pp60; - case 'N': - case 'n': goto pp61; - case 'O': - case 'o': goto pp62; - case 'R': - case 'r': goto pp63; - case 'S': - case 's': goto pp64; - case 'T': - case 't': goto pp65; - case 'U': - case 'u': goto pp66; - case 'V': - case 'v': goto pp67; - case 'W': - case 'w': goto pp68; - case '[': goto pp69; - case '\\': goto pp70; - case '^': goto pp71; - case 'x': goto pp73; - case '{': goto pp75; - case '|': goto pp76; - case '~': goto pp78; - default: goto pp4; - } -pp2: - ++PPCURSOR; - { - status = PHQL_SCANNER_RETCODE_EOF; - break; - } -pp4: - ++PPCURSOR; -pp5: - { - status = PHQL_SCANNER_RETCODE_ERR; - break; - } -pp6: - ppch = *++PPCURSOR; - switch (ppch) { - case '\t': - case '\n': - case '\r': - case ' ': goto pp6; - default: goto pp8; - } -pp8: - { - token->opcode = PHQL_T_IGNORE; - return 0; - } -pp9: - ppch = *++PPCURSOR; - switch (ppch) { - case '!': goto pp80; - case '=': goto pp82; - default: goto pp10; - } -pp10: - { - token->opcode = PHQL_T_NOT; - return 0; - } -pp11: - ppaccept = 0; - ppch = *(PPMARKER = ++PPCURSOR); - if (ppch <= 0x00) goto pp5; - goto pp85; -pp12: - ++PPCURSOR; - { - token->opcode = PHQL_T_MOD; - return 0; - } -pp14: - ppch = *++PPCURSOR; - switch (ppch) { - case '&': goto pp90; - default: goto pp15; - } -pp15: - { - token->opcode = PHQL_T_BITWISE_AND; - return 0; - } -pp16: - ppaccept = 0; - ppch = *(PPMARKER = ++PPCURSOR); - if (ppch <= 0x00) goto pp5; - goto pp93; -pp17: - ++PPCURSOR; - { - token->opcode = PHQL_T_PARENTHESES_OPEN; - return 0; - } -pp19: - ++PPCURSOR; - { - token->opcode = PHQL_T_PARENTHESES_CLOSE; - return 0; - } -pp21: - ++PPCURSOR; - { - token->opcode = PHQL_T_MUL; - return 0; - } -pp23: - ++PPCURSOR; - { - token->opcode = PHQL_T_ADD; - return 0; - } -pp25: - ++PPCURSOR; - { - token->opcode = PHQL_T_COMMA; - return 0; - } -pp27: - ++PPCURSOR; - { - token->opcode = PHQL_T_SUB; - return 0; - } -pp29: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp95; - default: goto pp30; - } -pp30: - { - token->opcode = PHQL_T_DOT; - return 0; - } -pp31: - ++PPCURSOR; - { - token->opcode = PHQL_T_DIV; - return 0; - } -pp33: - ppch = *++PPCURSOR; - switch (ppch) { - case '.': goto pp95; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp33; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'x': goto pp98; - default: goto pp35; - } -pp35: - { - token->opcode = PHQL_T_INTEGER; - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - q = PPCURSOR; - return 0; - } -pp36: - ppaccept = 1; - ppch = *(PPMARKER = ++PPCURSOR); - switch (ppch) { - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp100; - default: goto pp37; - } -pp37: - { - token->opcode = PHQL_T_COLON; - return 0; - } -pp38: - ppch = *++PPCURSOR; - switch (ppch) { - case '=': goto pp102; - case '>': goto pp104; - default: goto pp39; - } -pp39: - { - token->opcode = PHQL_T_LESS; - return 0; - } -pp40: - ++PPCURSOR; - { - token->opcode = PHQL_T_EQUALS; - return 0; + ZEPHIR_MM_GROW(); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_1$$3); } -pp42: - ppch = *++PPCURSOR; - switch (ppch) { - case '=': goto pp106; - default: goto pp43; - } -pp43: - { - token->opcode = PHQL_T_GREATER; - return 0; + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Enum) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Enum, phalcon, encryption_security_jwt_token_enum, NULL, 0); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("TYPE"), "typ"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ALGO"), "alg"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("CONTENT_TYPE"), "cty"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("AUDIENCE"), "aud"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("EXPIRATION_TIME"), "exp"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ID"), "jti"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ISSUED_AT"), "iat"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ISSUER"), "iss"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("NOT_BEFORE"), "nbf"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("SUBJECT"), "sub"); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Item) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Token, Item, phalcon, encryption_security_jwt_token_item, phalcon_encryption_security_jwt_token_abstractitem_ce, phalcon_encryption_security_jwt_token_item_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval encoded; + zval *payload_param = NULL, *encoded_param = NULL, _0, _1; + zval payload; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&encoded); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(payload) + Z_PARAM_STR(encoded) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &payload_param, &encoded_param); + ZEPHIR_OBS_COPY_OR_DUP(&payload, payload_param); + if (UNEXPECTED(Z_TYPE_P(encoded_param) != IS_STRING && Z_TYPE_P(encoded_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoded' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(encoded_param) == IS_STRING)) { + zephir_get_strval(&encoded, encoded_param); + } else { + ZEPHIR_INIT_VAR(&encoded); + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "encoded"); + zephir_update_property_array(this_ptr, SL("data"), &_0, &encoded); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "payload"); + zephir_update_property_array(this_ptr, SL("data"), &_1, &payload); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, get) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, _0, _1, _2, _3; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &name_param, &defaultValue); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &name); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("payload"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 42); + zephir_array_fetch(&_3, &_2, &name, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 42); + RETURN_CTOR(&_3); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, getPayload) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("payload"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 50); + RETURN_CTORW(&_1); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, has) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _0, _1; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("payload"), PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 60); + RETURN_MM_BOOL(zephir_array_isset(&_1, &name)); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Parser) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Parser, phalcon, encryption_security_jwt_token_parser, phalcon_encryption_security_jwt_token_parser_method_entry, 0); + + zend_declare_property_null(phalcon_encryption_security_jwt_token_parser_ce, SL("decode"), ZEND_ACC_PRIVATE); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *decode = NULL, decode_sub, __$null, service; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&decode_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&service); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(decode, phalcon_support_helper_json_decode_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &decode); + if (!decode) { + decode = &decode_sub; + decode = &__$null; + } + + + ZEPHIR_CPY_WRT(&service, decode); + if (Z_TYPE_P(&service) == IS_NULL) { + ZEPHIR_INIT_NVAR(&service); + object_init_ex(&service, phalcon_support_helper_json_decode_ce); + if (zephir_has_constructor(&service)) { + ZEPHIR_CALL_METHOD(NULL, &service, "__construct", NULL, 0); + zephir_check_call_status(); } -pp44: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp108; - default: goto pp5; - } -pp45: - ppch = *++PPCURSOR; - switch (ppch) { - case '>': goto pp111; - case '@': goto pp113; - default: goto pp5; - } -pp46: - ppch = *++PPCURSOR; - switch (ppch) { - case 'G': - case 'g': goto pp115; - case 'L': - case 'l': goto pp116; - case 'N': - case 'n': goto pp117; - case 'S': - case 's': goto pp118; - default: goto pp74; - } -pp47: - { - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - if (token->len > 2 && !memcmp(token->value, "0x", 2)) { - token->opcode = PHQL_T_HINTEGER; + + } + zephir_update_property_zval(this_ptr, ZEND_STRL("decode"), &service); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, parse) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *token_param = NULL, claims, encodedClaims, encodedHeaders, encodedSignature, headers, results, signature; + zval token; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&token); + ZVAL_UNDEF(&claims); + ZVAL_UNDEF(&encodedClaims); + ZVAL_UNDEF(&encodedHeaders); + ZVAL_UNDEF(&encodedSignature); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&results); + ZVAL_UNDEF(&signature); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(token) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &token_param); + if (UNEXPECTED(Z_TYPE_P(token_param) != IS_STRING && Z_TYPE_P(token_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'token' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(token_param) == IS_STRING)) { + zephir_get_strval(&token, token_param); + } else { + ZEPHIR_INIT_VAR(&token); + } + + + ZEPHIR_CALL_METHOD(&results, this_ptr, "parsetoken", NULL, 260, &token); + zephir_check_call_status(); + ZEPHIR_OBS_VAR(&encodedHeaders); + zephir_array_fetch_long(&encodedHeaders, &results, 0, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 55); + ZEPHIR_OBS_VAR(&encodedClaims); + zephir_array_fetch_long(&encodedClaims, &results, 1, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 56); + ZEPHIR_OBS_VAR(&encodedSignature); + zephir_array_fetch_long(&encodedSignature, &results, 2, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 57); + ZEPHIR_CALL_METHOD(&headers, this_ptr, "decodeheaders", NULL, 261, &encodedHeaders); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&claims, this_ptr, "decodeclaims", NULL, 262, &encodedClaims); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&signature, this_ptr, "decodesignature", NULL, 263, &headers, &encodedSignature); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_token_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 258, &headers, &claims, &signature); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeClaims) +{ + zval _5$$4; + zend_bool _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *claims_param = NULL, decoded, _0, _1, _2, _4, _6$$4; + zval claims; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&claims); + ZVAL_UNDEF(&decoded); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_5$$4); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(claims) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &claims_param); + zephir_get_strval(&claims, claims_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "decodeurl", NULL, 264, &claims); + zephir_check_call_status(); + ZVAL_BOOL(&_2, 1); + ZEPHIR_CALL_METHOD(&decoded, &_0, "__invoke", NULL, 0, &_1, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&decoded) != IS_ARRAY) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Claims (not an array)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 81); + return; + } + _3 = zephir_array_isset_string(&decoded, SL("aud")); + if (_3) { + ZEPHIR_OBS_VAR(&_4); + zephir_array_fetch_string(&_4, &decoded, SL("aud"), PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 87); + _3 = Z_TYPE_P(&_4) != IS_ARRAY; + } + if (_3) { + ZEPHIR_INIT_VAR(&_5$$4); + zephir_create_array(&_5$$4, 1, 0); + ZEPHIR_OBS_VAR(&_6$$4); + zephir_array_fetch_string(&_6$$4, &decoded, SL("aud"), PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 88); + zephir_array_fast_append(&_5$$4, &_6$$4); + zephir_array_update_string(&decoded, SL("aud"), &_5$$4, PH_COPY | PH_SEPARATE); + } + object_init_ex(return_value, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 256, &decoded, &claims); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeHeaders) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *headers_param = NULL, decoded, _0, _1, _2; + zval headers; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&decoded); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(headers) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &headers_param); + zephir_get_strval(&headers, headers_param); + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "decodeurl", NULL, 264, &headers); + zephir_check_call_status(); + ZVAL_BOOL(&_2, 1); + ZEPHIR_CALL_METHOD(&decoded, &_0, "__invoke", NULL, 0, &_1, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&decoded) != IS_ARRAY) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Header (not an array)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 110); + return; + } + if (!(zephir_array_isset_string(&decoded, SL("typ")))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Header (missing 'typ' element)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 116); + return; + } + object_init_ex(return_value, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 256, &decoded, &headers); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeSignature) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval signature; + zval *headers, headers_sub, *signature_param = NULL, algo, decoded, _0, _1, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&headers_sub); + ZVAL_UNDEF(&algo); + ZVAL_UNDEF(&decoded); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&signature); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_encryption_security_jwt_token_item_ce) + Z_PARAM_STR(signature) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &headers, &signature_param); + zephir_get_strval(&signature, signature_param); + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "alg"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "none"); + ZEPHIR_CALL_METHOD(&algo, headers, "get", NULL, 0, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "none"); + if (ZEPHIR_IS_IDENTICAL(&_2, &algo)) { + ZEPHIR_INIT_VAR(&decoded); + ZVAL_STRING(&decoded, ""); + ZEPHIR_INIT_NVAR(&signature); + } else { + ZEPHIR_CALL_METHOD(&decoded, this_ptr, "decodeurl", NULL, 264, &signature); + zephir_check_call_status(); + } + object_init_ex(return_value, phalcon_encryption_security_jwt_token_signature_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 257, &decoded, &signature); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, parseToken) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *token_param = NULL, parts; + zval token; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&token); + ZVAL_UNDEF(&parts); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(token) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &token_param); + if (UNEXPECTED(Z_TYPE_P(token_param) != IS_STRING && Z_TYPE_P(token_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'token' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(token_param) == IS_STRING)) { + zephir_get_strval(&token, token_param); + } else { + ZEPHIR_INIT_VAR(&token); + } + + + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL("."), &token, LONG_MAX); + if (zephir_fast_count_int(&parts) != 3) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid JWT string (dots misalignment)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 162); + return; + } + RETURN_CCTOR(&parts); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeUrl) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, remainder = 0; + zval *input_param = NULL, data, _3, _4, _5, _0$$3, _1$$3, _2$$3; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + + + remainder = (long) (zephir_safe_mod_long_long(zephir_fast_strlen_ev(&input), 4)); + if (remainder) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "="); + ZVAL_LONG(&_1$$3, (4 - remainder)); + ZEPHIR_CALL_FUNCTION(&_2$$3, "str_repeat", NULL, 1, &_0$$3, &_1$$3); + zephir_check_call_status(); + zephir_concat_self(&input, &_2$$3); + } + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "-_"); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "+/"); + ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 5, &input, &_3, &_4); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&data, "base64_decode", NULL, 229, &_5); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&data)) { + ZEPHIR_INIT_NVAR(&data); + ZVAL_STRING(&data, ""); + } + RETURN_CCTOR(&data); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Signature) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Token, Signature, phalcon, encryption_security_jwt_token_signature, phalcon_encryption_security_jwt_token_abstractitem_ce, phalcon_encryption_security_jwt_token_signature_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *hash_param = NULL, *encoded_param = NULL, _0, _1; + zval hash, encoded; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&hash); + ZVAL_UNDEF(&encoded); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_STR(hash) + Z_PARAM_STR(encoded) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 2, &hash_param, &encoded_param); + if (!hash_param) { + ZEPHIR_INIT_VAR(&hash); + ZVAL_STRING(&hash, ""); + } else { + if (UNEXPECTED(Z_TYPE_P(hash_param) != IS_STRING && Z_TYPE_P(hash_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hash' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(hash_param) == IS_STRING)) { + zephir_get_strval(&hash, hash_param); + } else { + ZEPHIR_INIT_VAR(&hash); + } + } + if (!encoded_param) { + ZEPHIR_INIT_VAR(&encoded); + ZVAL_STRING(&encoded, ""); + } else { + if (UNEXPECTED(Z_TYPE_P(encoded_param) != IS_STRING && Z_TYPE_P(encoded_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoded' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(encoded_param) == IS_STRING)) { + zephir_get_strval(&encoded, encoded_param); + } else { + ZEPHIR_INIT_VAR(&encoded); + } + } + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "encoded"); + zephir_update_property_array(this_ptr, SL("data"), &_0, &encoded); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "hash"); + zephir_update_property_array(this_ptr, SL("data"), &_1, &hash); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, getHash) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + + + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("hash"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Signature.zep", 35); + RETURN_CTORW(&_1); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Token) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Token, phalcon, encryption_security_jwt_token_token, phalcon_encryption_security_jwt_token_token_method_entry, 0); + + zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("claims"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("headers"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("signature"), ZEND_ACC_PRIVATE); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, __construct) +{ + zval *headers, headers_sub, *claims, claims_sub, *signature, signature_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&headers_sub); + ZVAL_UNDEF(&claims_sub); + ZVAL_UNDEF(&signature_sub); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_encryption_security_jwt_token_item_ce) + Z_PARAM_OBJECT_OF_CLASS(claims, phalcon_encryption_security_jwt_token_item_ce) + Z_PARAM_OBJECT_OF_CLASS(signature, phalcon_encryption_security_jwt_token_signature_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + zephir_fetch_params_without_memory_grow(3, 0, &headers, &claims, &signature); + + + zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), headers); + zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), claims); + zephir_update_property_zval(this_ptr, ZEND_STRL("signature"), signature); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getClaims) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "claims"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getHeaders) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "headers"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getPayload) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getencoded", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getencoded", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &_1, ".", &_3); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getSignature) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "signature"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getToken) +{ + zval _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getpayload", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getsignature", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &_1, "getencoded", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &_0, ".", &_2); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, validate) +{ + zend_string *_5; + zend_ulong _4; + zval methods; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validator, validator_sub, claimId, method, _0, _1, *_2, _3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&validator_sub); + ZVAL_UNDEF(&claimId); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&methods); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_encryption_security_jwt_validator_ce) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &validator); + + + ZEPHIR_INIT_VAR(&methods); + zephir_create_array(&methods, 6, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "aud"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateAudience"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "exp"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateExpiration"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "jti"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateId"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "iat"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateIssuedAt"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "iss"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateIssuer"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "nbf"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateNotBefore"), &_0, PH_COPY | PH_SEPARATE); + zephir_is_iterable(&methods, 0, "phalcon/Encryption/Security/JWT/Token/Token.zep", 131); + if (Z_TYPE_P(&methods) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methods), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&method); + if (_5 != NULL) { + ZVAL_STR_COPY(&method, _5); } else { - int i, alpha = 0; - for (i = 0; i < token->len; i++) { - unsigned char ch = token->value[i]; - if (!((ch >= '0') && (ch <= '9'))) { - alpha = 1; - break; - } - } - if (alpha) { - token->opcode = PHQL_T_IDENTIFIER; - } else { - token->opcode = PHQL_T_INTEGER; - } - } - q = PPCURSOR; - return 0; - } -pp48: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp120; - case 'Y': - case 'y': goto pp121; - default: goto pp74; - } -pp49: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp123; - case 'O': - case 'o': goto pp124; - case 'R': - case 'r': goto pp125; - default: goto pp74; - } -pp50: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp126; - case 'I': - case 'i': goto pp127; - default: goto pp74; - } -pp51: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp128; - case 'N': - case 'n': goto pp129; - case 'X': goto pp130; - case 'x': goto pp131; - default: goto pp74; - } -pp52: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp132; - case 'O': - case 'o': goto pp133; - case 'R': - case 'r': goto pp134; - case 'U': - case 'u': goto pp135; - default: goto pp74; - } -pp53: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp136; - default: goto pp59; + ZVAL_LONG(&method, _4); } -pp54: - { - token->opcode = PHQL_T_IDENTIFIER; - if ((PPCURSOR - q) > 1) { - if (q[0] == '\\') { - token->value = estrndup(q + 1, PPCURSOR - q - 1); - token->len = PPCURSOR - q - 1; - } else { - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - } - } else { - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; + ZEPHIR_INIT_NVAR(&claimId); + ZVAL_COPY(&claimId, _2); + ZEPHIR_CALL_METHOD_ZVAL(NULL, validator, &method, NULL, 0, &claimId); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &methods, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; } - q = PPCURSOR; - return 0; - } -pp55: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp137; - default: goto pp59; + ZEPHIR_CALL_METHOD(&method, &methods, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&claimId, &methods, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD_ZVAL(NULL, validator, &method, NULL, 0, &claimId); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&claimId); + ZEPHIR_INIT_NVAR(&method); + ZEPHIR_RETURN_CALL_METHOD(validator, "geterrors", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, verify) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval key; + zval *signer, signer_sub, *key_param = NULL, _0, _1, _2, _3, _4, _5, _6; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&key); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &signer, &key_param); + zephir_get_strval(&key, key_param); + + + ZEPHIR_CALL_METHOD(&_0, signer, "getalgheader", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "alg"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_0, &_2)) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("signature"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "gethash", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "getpayload", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(signer, "verify", NULL, 0, &_5, &_6, &key); + zephir_check_call_status(); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_AbstractSigner) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Signer, AbstractSigner, phalcon, encryption_security_jwt_signer_abstractsigner, phalcon_encryption_security_jwt_signer_abstractsigner_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_string(phalcon_encryption_security_jwt_signer_abstractsigner_ce, SL("algorithm"), "", ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_encryption_security_jwt_signer_abstractsigner_ce, 1, phalcon_encryption_security_jwt_signer_signerinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_AbstractSigner, getAlgorithm) +{ + zval *this_ptr = getThis(); + + + + RETURN_MEMBER(getThis(), "algorithm"); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_Hmac) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Signer, Hmac, phalcon, encryption_security_jwt_signer_hmac, phalcon_encryption_security_jwt_signer_abstractsigner_ce, phalcon_encryption_security_jwt_signer_hmac_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, __construct) +{ + zval supported; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *algo_param = NULL; + zval algo; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&algo); + ZVAL_UNDEF(&supported); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR(algo) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &algo_param); + if (!algo_param) { + ZEPHIR_INIT_VAR(&algo); + ZVAL_STRING(&algo, "sha512"); + } else { + if (UNEXPECTED(Z_TYPE_P(algo_param) != IS_STRING && Z_TYPE_P(algo_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'algo' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(algo_param) == IS_STRING)) { + zephir_get_strval(&algo, algo_param); + } else { + ZEPHIR_INIT_VAR(&algo); + } + } + + + ZEPHIR_INIT_VAR(&supported); + zephir_create_array(&supported, 3, 0); + add_assoc_long_ex(&supported, SL("sha512"), 1); + add_assoc_long_ex(&supported, SL("sha384"), 1); + add_assoc_long_ex(&supported, SL("sha256"), 1); + if (!(zephir_array_isset(&supported, &algo))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_unsupportedalgorithmexception_ce, "Unsupported HMAC algorithm", "phalcon/Encryption/Security/JWT/Signer/Hmac.zep", 40); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("algorithm"), &algo); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, getAlgHeader) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("algorithm"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sha"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, ""); + zephir_fast_str_replace(&_0, &_2, &_3, &_1); + ZEPHIR_CONCAT_SV(return_value, "HS", &_0); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, sign) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *payload_param = NULL, *passphrase_param = NULL; + zval payload, passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); + if (UNEXPECTED(Z_TYPE_P(payload_param) != IS_STRING && Z_TYPE_P(payload_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'payload' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(payload_param) == IS_STRING)) { + zephir_get_strval(&payload, payload_param); + } else { + ZEPHIR_INIT_VAR(&payload); + } + if (UNEXPECTED(Z_TYPE_P(passphrase_param) != IS_STRING && Z_TYPE_P(passphrase_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'passphrase' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(passphrase_param) == IS_STRING)) { + zephir_get_strval(&passphrase, passphrase_param); + } else { + ZEPHIR_INIT_VAR(&passphrase); + } + + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethash", NULL, 259, &payload, &passphrase); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, verify) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *source_param = NULL, *payload_param = NULL, *passphrase_param = NULL, _0; + zval source, payload, passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(source) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &source_param, &payload_param, &passphrase_param); + zephir_get_strval(&source, source_param); + zephir_get_strval(&payload, payload_param); + zephir_get_strval(&passphrase, passphrase_param); + + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethash", NULL, 259, &payload, &passphrase); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_hash_equals(&source, &_0)); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, getHash) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *payload_param = NULL, *passphrase_param = NULL, __$true, _0; + zval payload, passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); + zephir_get_strval(&payload, payload_param); + zephir_get_strval(&passphrase, passphrase_param); + + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getalgorithm", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, 228, &_0, &payload, &passphrase, &__$true); + zephir_check_call_status(); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_None) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Signer, None, phalcon, encryption_security_jwt_signer_none, phalcon_encryption_security_jwt_signer_none_method_entry, 0); + + zend_class_implements(phalcon_encryption_security_jwt_signer_none_ce, 1, phalcon_encryption_security_jwt_signer_signerinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, getAlgHeader) +{ + zval *this_ptr = getThis(); + + + + RETURN_STRING("none"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, getAlgorithm) +{ + zval *this_ptr = getThis(); + + + + RETURN_STRING("None"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, sign) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *payload_param = NULL, *passphrase_param = NULL; + zval payload, passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); + if (UNEXPECTED(Z_TYPE_P(payload_param) != IS_STRING && Z_TYPE_P(payload_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'payload' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(payload_param) == IS_STRING)) { + zephir_get_strval(&payload, payload_param); + } else { + ZEPHIR_INIT_VAR(&payload); + } + zephir_get_strval(&passphrase, passphrase_param); + + + RETURN_MM_STRING(""); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, verify) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *source_param = NULL, *payload_param = NULL, *passphrase_param = NULL, _0; + zval source, payload, passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&_0); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(source) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &source_param, &payload_param, &passphrase_param); + zephir_get_strval(&source, source_param); + zephir_get_strval(&payload, payload_param); + zephir_get_strval(&passphrase, passphrase_param); + + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, ""); + RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_0, &source)); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_SignerInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Security\\JWT\\Signer, SignerInterface, phalcon, encryption_security_jwt_signer_signerinterface, phalcon_encryption_security_jwt_signer_signerinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, getAlgHeader); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, getAlgorithm); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, sign); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, verify); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Tag_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Tag, Exception, phalcon, tag_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Tag_Select) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Tag, Select, phalcon, tag_select, phalcon_tag_select_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Tag_Select, selectField) +{ + zend_bool _2$$19; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_1 = NULL, *_4 = NULL, *_9 = NULL, *_13 = NULL; + zval *parameters, parameters_sub, *data = NULL, data_sub, __$null, params, name, id, value, useEmpty, code, emptyValue, emptyText, options, using, _3, _5, _0$$5, _6$$22, _7$$22, _8$$23, _10$$23, _11$$23, _12$$25, _14$$25, _15$$25; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&id); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&useEmpty); + ZVAL_UNDEF(&code); + ZVAL_UNDEF(&emptyValue); + ZVAL_UNDEF(&emptyText); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&using); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_6$$22); + ZVAL_UNDEF(&_7$$22); + ZVAL_UNDEF(&_8$$23); + ZVAL_UNDEF(&_10$$23); + ZVAL_UNDEF(&_11$$23); + ZVAL_UNDEF(&_12$$25); + ZVAL_UNDEF(&_14$$25); + ZVAL_UNDEF(&_15$$25); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(parameters) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(data) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, ¶meters, &data); + if (!data) { + data = &data_sub; + data = &__$null; + } + + + if (Z_TYPE_P(parameters) != IS_ARRAY) { + ZEPHIR_INIT_VAR(¶ms); + zephir_create_array(¶ms, 2, 0); + zephir_array_fast_append(¶ms, parameters); + zephir_array_fast_append(¶ms, data); + } else { + ZEPHIR_CPY_WRT(¶ms, parameters); + } + ZEPHIR_OBS_VAR(&id); + if (!(zephir_array_isset_long_fetch(&id, ¶ms, 0, 0))) { + zephir_array_fetch_string(&_0$$5, ¶ms, SL("id"), PH_NOISY | PH_READONLY, "phalcon/Tag/Select.zep", 50); + zephir_array_update_long(¶ms, 0, &_0$$5, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } + if (!(zephir_memnstr_str(&id, SL("["), "phalcon/Tag/Select.zep", 56))) { + if (!(zephir_array_isset_string(¶ms, SL("id")))) { + zephir_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_OBS_VAR(&name); + if (!(zephir_array_isset_string_fetch(&name, ¶ms, SL("name"), 0))) { + zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); + } else { + if (!(zephir_is_true(&name))) { + zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_OBS_VAR(&value); + if (!(zephir_array_isset_string_fetch(&value, ¶ms, SL("value"), 0))) { + ZEPHIR_CALL_CE_STATIC(&value, phalcon_tag_ce, "getvalue", &_1, 0, &id, ¶ms); + zephir_check_call_status(); + } else { + zephir_array_unset_string(¶ms, SL("value"), PH_SEPARATE); + } + ZEPHIR_OBS_VAR(&useEmpty); + if (zephir_array_isset_string_fetch(&useEmpty, ¶ms, SL("useEmpty"), 0)) { + ZEPHIR_OBS_VAR(&emptyValue); + if (!(zephir_array_isset_string_fetch(&emptyValue, ¶ms, SL("emptyValue"), 0))) { + ZEPHIR_INIT_NVAR(&emptyValue); + ZVAL_STRING(&emptyValue, ""); + } else { + zephir_array_unset_string(¶ms, SL("emptyValue"), PH_SEPARATE); + } + ZEPHIR_OBS_VAR(&emptyText); + if (!(zephir_array_isset_string_fetch(&emptyText, ¶ms, SL("emptyText"), 0))) { + ZEPHIR_INIT_NVAR(&emptyText); + ZVAL_STRING(&emptyText, "Choose..."); + } else { + zephir_array_unset_string(¶ms, SL("emptyText"), PH_SEPARATE); + } + zephir_array_unset_string(¶ms, SL("useEmpty"), PH_SEPARATE); + } + ZEPHIR_OBS_VAR(&options); + if (!(zephir_array_isset_long_fetch(&options, ¶ms, 1, 0))) { + ZEPHIR_CPY_WRT(&options, data); + } + if (Z_TYPE_P(&options) == IS_OBJECT) { + ZEPHIR_OBS_VAR(&using); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&using, ¶ms, SL("using"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "The 'using' parameter is required", "phalcon/Tag/Select.zep", 101); + return; + } + _2$$19 = Z_TYPE_P(&using) != IS_ARRAY; + if (_2$$19) { + _2$$19 = Z_TYPE_P(&using) != IS_OBJECT; + } + if (UNEXPECTED(_2$$19)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "The 'using' parameter should be an array", "phalcon/Tag/Select.zep", 107); + return; + } + } + zephir_array_unset_string(¶ms, SL("using"), PH_SEPARATE); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "", &_5); + if (zephir_is_true(&useEmpty)) { + ZEPHIR_INIT_VAR(&_6$$22); + ZEPHIR_GET_CONSTANT(&_6$$22, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_7$$22); + ZEPHIR_CONCAT_SVSVSV(&_7$$22, "\t", &_6$$22); + zephir_concat_self(&code, &_7$$22); + } + if (Z_TYPE_P(&options) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_10$$23); + ZEPHIR_GET_CONSTANT(&_10$$23, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_11$$23); + ZEPHIR_CONCAT_SV(&_11$$23, "", &_10$$23); + ZEPHIR_CALL_SELF(&_8$$23, "optionsfromresultset", &_9, 0, &options, &using, &value, &_11$$23); + zephir_check_call_status(); + zephir_concat_self(&code, &_8$$23); + } else { + if (Z_TYPE_P(&options) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_14$$25); + ZEPHIR_GET_CONSTANT(&_14$$25, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_15$$25); + ZEPHIR_CONCAT_SV(&_15$$25, "", &_14$$25); + ZEPHIR_CALL_SELF(&_12$$25, "optionsfromarray", &_13, 0, &options, &value, &_15$$25); + zephir_check_call_status(); + zephir_concat_self(&code, &_12$$25); + } + } + zephir_concat_self_str(&code, SL("")); + RETURN_CCTOR(&code); +} + +static PHP_METHOD(Phalcon_Tag_Select, optionsFromArray) +{ + zend_string *_3; + zend_ulong _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval closeOption, _12$$8, _13$$8, _22$$16, _23$$16; + zval *data_param = NULL, *value, value_sub, *closeOption_param = NULL, strValue, strOptionValue, code, optionValue, optionText, escaped, *_0, _1, _5$$4, _6$$4, _8$$4, _9$$4, _10$$6, _11$$7, _14$$9, _15$$10, _16$$12, _17$$12, _18$$12, _19$$12, _20$$14, _21$$15, _24$$17, _25$$18; + zval data; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&strValue); + ZVAL_UNDEF(&strOptionValue); + ZVAL_UNDEF(&code); + ZVAL_UNDEF(&optionValue); + ZVAL_UNDEF(&optionText); + ZVAL_UNDEF(&escaped); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_17$$12); + ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_19$$12); + ZVAL_UNDEF(&_20$$14); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_24$$17); + ZVAL_UNDEF(&_25$$18); + ZVAL_UNDEF(&closeOption); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_13$$8); + ZVAL_UNDEF(&_22$$16); + ZVAL_UNDEF(&_23$$16); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(value) + Z_PARAM_STR(closeOption) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &data_param, &value, &closeOption_param); + zephir_get_arrval(&data, data_param); + zephir_get_strval(&closeOption, closeOption_param); + + + ZEPHIR_INIT_VAR(&code); + ZVAL_STRING(&code, ""); + zephir_is_iterable(&data, 0, "phalcon/Tag/Select.zep", 186); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&optionValue); + if (_3 != NULL) { + ZVAL_STR_COPY(&optionValue, _3); + } else { + ZVAL_LONG(&optionValue, _2); } -pp56: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp138; - case 'N': - case 'n': goto pp139; - case 'S': - case 's': goto pp141; - default: goto pp59; + ZEPHIR_INIT_NVAR(&optionText); + ZVAL_COPY(&optionText, _0); + ZEPHIR_CALL_FUNCTION(&escaped, "htmlspecialchars", &_4, 285, &optionValue); + zephir_check_call_status(); + if (Z_TYPE_P(&optionText) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_5$$4); + ZEPHIR_GET_CONSTANT(&_5$$4, "PHP_EOL"); + ZEPHIR_CALL_SELF(&_6$$4, "optionsfromarray", &_7, 0, &optionText, value, &closeOption); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$4); + ZEPHIR_GET_CONSTANT(&_8$$4, "PHP_EOL"); + ZEPHIR_INIT_NVAR(&_9$$4); + ZEPHIR_CONCAT_SVSVVSV(&_9$$4, "\t", &_5$$4, &_6$$4, "\t", &_8$$4); + zephir_concat_self(&code, &_9$$4); + continue; } -pp57: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp143; - default: goto pp59; + if (Z_TYPE_P(value) == IS_ARRAY) { + if (zephir_fast_in_array(&optionValue, value)) { + ZEPHIR_INIT_NVAR(&_10$$6); + ZEPHIR_CONCAT_SVSVV(&_10$$6, "\t", &_16$$12, &_17$$12, "\t", &_18$$12); + zephir_concat_self(&code, &_19$$12); + continue; + } + if (Z_TYPE_P(value) == IS_ARRAY) { + if (zephir_fast_in_array(&optionValue, value)) { + ZEPHIR_INIT_NVAR(&_20$$14); + ZEPHIR_CONCAT_SVSVV(&_20$$14, "\t