From 425e8c0351eb022a197065bee23781af88952c65 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Mon, 1 Jul 2019 21:30:27 -0400 Subject: [PATCH] [#14213] - Changed Pdo to Abstract --- ext/phalcon/db/adapter/pdo.zep.c | 1590 ----------------- ext/phalcon/db/adapter/pdo.zep.h | 212 --- phalcon/Db/AbstractDb.zep | 4 +- .../Adapter/{Pdo.zep => Pdo/AbstractPdo.zep} | 4 +- phalcon/Db/Adapter/Pdo/Mysql.zep | 2 +- phalcon/Db/Adapter/Pdo/Postgresql.zep | 2 +- phalcon/Db/Adapter/Pdo/Sqlite.zep | 2 +- phalcon/Tag.zep | 2 +- 8 files changed, 8 insertions(+), 1810 deletions(-) delete mode 100644 ext/phalcon/db/adapter/pdo.zep.c delete mode 100644 ext/phalcon/db/adapter/pdo.zep.h rename phalcon/Db/Adapter/{Pdo.zep => Pdo/AbstractPdo.zep} (99%) diff --git a/ext/phalcon/db/adapter/pdo.zep.c b/ext/phalcon/db/adapter/pdo.zep.c deleted file mode 100644 index 018fa4a529b..00000000000 --- a/ext/phalcon/db/adapter/pdo.zep.c +++ /dev/null @@ -1,1590 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/fcall.h" -#include "ext/spl/spl_exceptions.h" -#include "kernel/exception.h" -#include "kernel/memory.h" -#include "kernel/object.h" -#include "kernel/operators.h" -#include "kernel/array.h" -#include "kernel/concat.h" -#include "kernel/string.h" -#include "ext/pdo/php_pdo_driver.h" - - -/** - * This file is part of the Phalcon. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -/** - * Phalcon\Db\Adapter\Pdo - * - * Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect - * to a database - * - * - * use Phalcon\Db\Adapter\Pdo\Mysql; - * - * $config = [ - * "host" => "localhost", - * "dbname" => "blog", - * "port" => 3306, - * "username" => "sigma", - * "password" => "secret", - * ]; - * - * $connection = new Mysql($config); - * - */ -ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo) { - - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter, Pdo, phalcon, db_adapter_pdo, phalcon_db_adapter_ce, phalcon_db_adapter_pdo_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - /** - * Last affected rows - */ - zend_declare_property_null(phalcon_db_adapter_pdo_ce, SL("affectedRows"), ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * PDO Handler - * - * @var \Pdo - */ - zend_declare_property_null(phalcon_db_adapter_pdo_ce, SL("pdo"), ZEND_ACC_PROTECTED TSRMLS_CC); - - return SUCCESS; - -} - -/** - * Constructor for Phalcon\Db\Adapter\Pdo - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, __construct) { - - zephir_fcall_cache_entry *_0 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *descriptor_param = NULL; - zval descriptor; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&descriptor); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &descriptor_param); - - ZEPHIR_OBS_COPY_OR_DUP(&descriptor, descriptor_param); - - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0, &descriptor); - zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_ce, getThis(), "__construct", &_0, 0, &descriptor); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE - * executed in the database system - * - * - * $connection->execute( - * "DELETE FROM robots" - * ); - * - * echo $connection->affectedRows(), " were deleted"; - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, affectedRows) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "affectedRows"); - -} - -/** - * Starts a transaction in the connection - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, begin) { - - zend_long ZEPHIR_LAST_CALL_STATUS, transactionLevel = 0; - zval *nesting_param = NULL, pdo, eventsManager, savepointName, _0, _1, _6, _2$$4, _3$$5, _7$$7; - zend_bool nesting, _4, _5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&savepointName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_7$$7); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &nesting_param); - - if (!nesting_param) { - nesting = 1; - } else { - nesting = zephir_get_boolval(nesting_param); - } - - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_0); - if (Z_TYPE_P(&pdo) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - ZEPHIR_OBS_VAR(&_1); - zephir_read_property(&_1, this_ptr, SL("transactionLevel"), PH_NOISY_CC); - transactionLevel = zephir_get_intval(&_1); - if (transactionLevel == 1) { - zephir_read_property(&_2$$4, this_ptr, SL("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:beginTransaction"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_3$$5, this_ptr); - zephir_check_call_status(); - } - ZEPHIR_RETURN_CALL_METHOD(&pdo, "begintransaction", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - _4 = !transactionLevel; - 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(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_STRING(&_7$$7, "db:createSavepoint"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_7$$7, this_ptr, &savepointName); - zephir_check_call_status(); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "createsavepoint", NULL, 0, &savepointName); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Commits the active transaction in the connection - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, commit) { - - zend_long ZEPHIR_LAST_CALL_STATUS, transactionLevel = 0; - zval *nesting_param = NULL, pdo, eventsManager, savepointName, _0, _1, _6, _2$$5, _3$$6, _7$$9; - zend_bool nesting, _4, _5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&savepointName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_7$$9); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &nesting_param); - - if (!nesting_param) { - nesting = 1; - } else { - nesting = zephir_get_boolval(nesting_param); - } - - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_0); - if (Z_TYPE_P(&pdo) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - ZEPHIR_OBS_VAR(&_1); - zephir_read_property(&_1, this_ptr, SL("transactionLevel"), PH_NOISY_CC); - transactionLevel = zephir_get_intval(&_1); - if (UNEXPECTED(!transactionLevel)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "There is no active transaction", "phalcon/Db/Adapter/Pdo.zep", 152); - return; - } - if (transactionLevel == 1) { - zephir_read_property(&_2$$5, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_2$$5); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_3$$6); - ZVAL_STRING(&_3$$6, "db:commitTransaction"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_3$$6, this_ptr); - zephir_check_call_status(); - } - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - ZEPHIR_RETURN_CALL_METHOD(&pdo, "commit", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - _4 = !transactionLevel; - 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) { - if (transactionLevel > 0) { - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - } - RETURN_MM_BOOL(0); - } - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_7$$9); - ZVAL_STRING(&_7$$9, "db:releaseSavepoint"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_7$$9, this_ptr, &savepointName); - zephir_check_call_status(); - } - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "releasesavepoint", NULL, 0, &savepointName); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Closes the active connection returning success. Phalcon automatically - * closes and destroys active connections when the request ends - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, close) { - - zval __$null; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - - - zephir_update_property_zval(this_ptr, SL("pdo"), &__$null); - RETURN_BOOL(1); - -} - -/** - * This method is automatically called in \Phalcon\Db\Adapter\Pdo - * constructor. - * - * Call it when you need to restore a database connection. - * - * - * use Phalcon\Db\Adapter\Pdo\Mysql; - * - * // Make a connection - * $connection = new Mysql( - * [ - * "host" => "localhost", - * "username" => "sigma", - * "password" => "secret", - * "dbname" => "blog", - * "port" => 3306, - * ] - * ); - * - * // Reconnect - * $connection->connect(); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect) { - - zend_string *_7; - zend_ulong _6; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *descriptor_param = NULL, username, password, dsnParts, dsnAttributes, dsnAttributesCustomRaw, dsnAttributesMap, options, key, value, _2, _3, *_4, _5, _10, _11, _12, _0$$3, _8$$10, _9$$11; - zval descriptor, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&descriptor); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&username); - ZVAL_UNDEF(&password); - ZVAL_UNDEF(&dsnParts); - ZVAL_UNDEF(&dsnAttributes); - ZVAL_UNDEF(&dsnAttributesCustomRaw); - ZVAL_UNDEF(&dsnAttributesMap); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$11); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &descriptor_param); - - if (!descriptor_param) { - ZEPHIR_INIT_VAR(&descriptor); - array_init(&descriptor); - } else { - zephir_get_arrval(&descriptor, descriptor_param); - } - - - if (ZEPHIR_IS_EMPTY(&descriptor)) { - ZEPHIR_OBS_VAR(&_0$$3); - zephir_read_property(&_0$$3, this_ptr, SL("descriptor"), PH_NOISY_CC); - zephir_get_arrval(&_1$$3, &_0$$3); - ZEPHIR_CPY_WRT(&descriptor, &_1$$3); - } - 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(&password); - if (zephir_array_isset_string_fetch(&password, &descriptor, SL("password"), 0)) { - zephir_array_unset_string(&descriptor, SL("password"), PH_SEPARATE); - } - if (zephir_array_isset_string(&descriptor, SL("dialectClass"))) { - zephir_array_unset_string(&descriptor, SL("dialectClass"), PH_SEPARATE); - } - ZEPHIR_OBS_VAR(&options); - if (zephir_array_isset_string_fetch(&options, &descriptor, SL("options"), 0)) { - zephir_array_unset_string(&descriptor, SL("options"), PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&options); - array_init(&options); - } - ZEPHIR_INIT_VAR(&_2); - ZVAL_LONG(&_2, 2); - zephir_array_update_long(&options, 3, &_2, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - ZEPHIR_INIT_VAR(&dsnParts); - array_init(&dsnParts); - 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.zep", 281); - zephir_array_unset_string(&descriptor, SL("dsn"), PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getdsndefaults", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&dsnAttributesMap); - zephir_fast_array_merge(&dsnAttributesMap, &_3, &descriptor TSRMLS_CC); - zephir_is_iterable(&dsnAttributesMap, 0, "phalcon/Db/Adapter/Pdo.zep", 301); - if (Z_TYPE_P(&dsnAttributesMap) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&dsnAttributesMap), _6, _7, _4) - { - ZEPHIR_INIT_NVAR(&key); - if (_7 != NULL) { - ZVAL_STR_COPY(&key, _7); - } else { - ZVAL_LONG(&key, _6); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _4); - ZEPHIR_INIT_LNVAR(_8$$10); - ZEPHIR_CONCAT_VSV(&_8$$10, &key, "=", &value); - zephir_array_append(&dsnParts, &_8$$10, PH_SEPARATE, "phalcon/Db/Adapter/Pdo.zep", 297); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &dsnAttributesMap, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &dsnAttributesMap, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &dsnAttributesMap, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &dsnAttributesMap, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_LNVAR(_9$$11); - ZEPHIR_CONCAT_VSV(&_9$$11, &key, "=", &value); - zephir_array_append(&dsnParts, &_9$$11, PH_SEPARATE, "phalcon/Db/Adapter/Pdo.zep", 297); - ZEPHIR_CALL_METHOD(NULL, &dsnAttributesMap, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_INIT_VAR(&dsnAttributes); - zephir_fast_join_str(&dsnAttributes, SL(";"), &dsnParts TSRMLS_CC); - ZEPHIR_INIT_VAR(&_10); - object_init_ex(&_10, php_pdo_get_dbh_ce()); - zephir_read_property(&_11, this_ptr, SL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_12); - ZEPHIR_CONCAT_VSV(&_12, &_11, ":", &dsnAttributes); - ZEPHIR_CALL_METHOD(NULL, &_10, "__construct", NULL, 0, &_12, &username, &password, &options); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("pdo"), &_10); - RETURN_MM_BOOL(1); - -} - -/** - * Converts bound parameters such as :name: or ?1 into PDO bind params ? - * - * - * print_r( - * $connection->convertBoundParams( - * "SELECT * FROM robots WHERE name = :name:", - * [ - * "Bender", - * ] - * ) - * ); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, convertBoundParams) { - - 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(&sql); - ZVAL_UNDEF(&boundSql); - ZVAL_UNDEF(&placeHolders); - ZVAL_UNDEF(&bindPattern); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&placeMatch); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(¶ms); - - ZEPHIR_MM_GROW(); - 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") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(sql_param) == IS_STRING)) { - zephir_get_strval(&sql, sql_param); - } else { - ZEPHIR_INIT_VAR(&sql); - ZVAL_EMPTY_STRING(&sql); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - - - 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 TSRMLS_CC); - if (zephir_is_true(&_1)) { - zephir_is_iterable(&matches, 0, "phalcon/Db/Adapter/Pdo.zep", 357); - 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.zep", 340 TSRMLS_CC); - if (!(zephir_array_isset_fetch(&value, ¶ms, &_5$$4, 0 TSRMLS_CC))) { - if (UNEXPECTED(!(zephir_array_isset_long(&placeMatch, 2)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/Db/Adapter/Pdo.zep", 344); - return; - } - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch_long(&_6$$5, &placeMatch, 2, PH_READONLY, "phalcon/Db/Adapter/Pdo.zep", 347 TSRMLS_CC); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, ¶ms, &_6$$5, 0 TSRMLS_CC)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/Db/Adapter/Pdo.zep", 350); - return; - } - } - zephir_array_append(&placeHolders, &value, PH_SEPARATE, "phalcon/Db/Adapter/Pdo.zep", 354); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &matches, "rewind", NULL, 0); - zephir_check_call_status(); - 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(&placeMatch, &matches, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch_long(&_7$$8, &placeMatch, 1, PH_READONLY, "phalcon/Db/Adapter/Pdo.zep", 340 TSRMLS_CC); - if (!(zephir_array_isset_fetch(&value, ¶ms, &_7$$8, 0 TSRMLS_CC))) { - if (UNEXPECTED(!(zephir_array_isset_long(&placeMatch, 2)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/Db/Adapter/Pdo.zep", 344); - return; - } - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch_long(&_8$$9, &placeMatch, 2, PH_READONLY, "phalcon/Db/Adapter/Pdo.zep", 347 TSRMLS_CC); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, ¶ms, &_8$$9, 0 TSRMLS_CC)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/Db/Adapter/Pdo.zep", 350); - return; - } - } - zephir_array_append(&placeHolders, &value, PH_SEPARATE, "phalcon/Db/Adapter/Pdo.zep", 354); - 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, 38, &bindPattern, &_9$$3, &sql); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&boundSql, &sql); - } - zephir_create_array(return_value, 2, 0 TSRMLS_CC); - 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(); - -} - -/** - * Escapes a value to avoid SQL injections according to the active charset - * in the connection - * - * - * $escapedStr = $connection->escapeString("some dangerous value"); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, escapeString) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *str_param = NULL, _0; - zval str; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&str); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &str_param); - - zephir_get_strval(&str, str_param); - - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "quote", NULL, 0, &str); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server doesn't - * return any rows - * - * - * // Inserting data - * $success = $connection->execute( - * "INSERT INTO robots VALUES (1, 'Astro Boy')" - * ); - * - * $success = $connection->execute( - * "INSERT INTO robots VALUES (?, ?)", - * [ - * 1, - * "Astro Boy", - * ] - * ); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, execute) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *sqlStatement_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, eventsManager, affectedRows, pdo, newStatement, statement, _0, _1$$3, _2$$3, _3$$9; - zval sqlStatement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&sqlStatement); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&affectedRows); - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&newStatement); - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$9); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams, &bindTypes); - - 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") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { - zephir_get_strval(&sqlStatement, sqlStatement_param); - } else { - ZEPHIR_INIT_VAR(&sqlStatement); - ZVAL_EMPTY_STRING(&sqlStatement); - } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; - } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; - } - - - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - zephir_update_property_zval(this_ptr, SL("sqlStatement"), &sqlStatement); - zephir_update_property_zval(this_ptr, SL("sqlVariables"), bindParams); - zephir_update_property_zval(this_ptr, SL("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(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_BOOL(0); - } - } - ZEPHIR_INIT_VAR(&affectedRows); - ZVAL_LONG(&affectedRows, 0); - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_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_CALL_METHOD(&newStatement, this_ptr, "executeprepared", NULL, 0, &statement, bindParams, bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&affectedRows, &newStatement, "rowcount", NULL, 0); - zephir_check_call_status(); - } - } else { - ZEPHIR_CALL_METHOD(&affectedRows, &pdo, "exec", NULL, 0, &sqlStatement); - zephir_check_call_status(); - } - if (Z_TYPE_P(&affectedRows) == IS_LONG) { - zephir_update_property_zval(this_ptr, SL("affectedRows"), &affectedRows); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_3$$9); - ZVAL_STRING(&_3$$9, "db:afterQuery"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_3$$9, this_ptr); - zephir_check_call_status(); - } - } - RETURN_MM_BOOL(1); - -} - -/** - * Executes a prepared statement binding. This function uses integer indexes - * starting from zero - * - * - * use Phalcon\Db\Column; - * - * $statement = $db->prepare( - * "SELECT * FROM robots WHERE name = :name" - * ); - * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] - * ); - * - * - * @param array dataTypes - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, 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_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); - - 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.zep", 570); - if (Z_TYPE_P(&placeholders) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&placeholders), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&wildcard); - if (_3 != NULL) { - ZVAL_STR_COPY(&wildcard, _3); - } else { - ZVAL_LONG(&wildcard, _2); - } - 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.zep", 490); - 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 TSRMLS_CC); - } - if (_4$$3) { - if (ZEPHIR_IS_LONG(&type, 32)) { - zephir_get_strval(&_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, 39, &value, &_6$$12); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 2)) { - zephir_get_strval(&_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); - } - } - 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_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &castValue, &type); - zephir_check_call_status(); - } - } else { - zephir_is_iterable(&castValue, 0, "phalcon/Db/Adapter/Pdo.zep", 558); - 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(&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_LNVAR(_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_LNVAR(_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, &castValue, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11$$22, &castValue, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11$$22)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &castValue, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&itemValue, &castValue, "current", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&type, 1024)) { - ZEPHIR_INIT_LNVAR(_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_LNVAR(_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(&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(); - } else { - zephir_is_iterable(&value, 0, "phalcon/Db/Adapter/Pdo.zep", 566); - 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(&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_LNVAR(_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, &value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_19$$31, &value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_19$$31)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &value, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&itemValue, &value, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_LNVAR(_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(&itemValue); - ZEPHIR_INIT_NVAR(&position); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &placeholders, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &placeholders, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&wildcard, &placeholders, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &placeholders, "current", NULL, 0); - zephir_check_call_status(); - 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.zep", 490); - 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 TSRMLS_CC); - } - if (_24$$34) { - if (ZEPHIR_IS_LONG(&type, 32)) { - zephir_get_strval(&_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, 39, &value, &_26$$43); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 2)) { - zephir_get_strval(&_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); - } - } - 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_CALL_METHOD(NULL, statement, "bindvalue", &_9, 0, ¶meter, &castValue, &type); - zephir_check_call_status(); - } - } else { - zephir_is_iterable(&castValue, 0, "phalcon/Db/Adapter/Pdo.zep", 558); - 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(&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_LNVAR(_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_LNVAR(_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, &castValue, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_29$$53, &castValue, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_29$$53)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &castValue, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&itemValue, &castValue, "current", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&type, 1024)) { - ZEPHIR_INIT_LNVAR(_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_LNVAR(_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(&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(); - } else { - zephir_is_iterable(&value, 0, "phalcon/Db/Adapter/Pdo.zep", 566); - 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(&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_LNVAR(_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, &value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_37$$62, &value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_37$$62)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &value, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&itemValue, &value, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_LNVAR(_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(&itemValue); - ZEPHIR_INIT_NVAR(&position); - } - } - ZEPHIR_CALL_METHOD(NULL, &placeholders, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&wildcard); - ZEPHIR_CALL_METHOD(NULL, statement, "execute", NULL, 0); - zephir_check_call_status(); - RETVAL_ZVAL(statement, 1, 0); - RETURN_MM(); - -} - -/** - * Return the error info, if any - * - * @return array - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getErrorInfo) { - - zval _0; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "errorinfo", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Return internal PDO handler - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getInternalHandler) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "pdo"); - -} - -/** - * Returns the current transaction nesting level - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getTransactionLevel) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "transactionLevel"); - -} - -/** - * Checks whether the connection is under a transaction - * - * - * $connection->begin(); - * - * // true - * var_dump( - * $connection->isUnderTransaction() - * ); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, isUnderTransaction) { - - zval pdo, _0; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_0); - if (Z_TYPE_P(&pdo) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - ZEPHIR_RETURN_CALL_METHOD(&pdo, "intransaction", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Returns the insert id for the auto_increment/serial column inserted in - * the latest executed SQL statement - * - * - * // Inserting a new robot - * $success = $connection->insert( - * "robots", - * [ - * "Astro Boy", - * 1952, - * ], - * [ - * "name", - * "year", - * ] - * ); - * - * // Getting the generated id - * $id = $connection->lastInsertId(); - * - * - * @param string sequenceName - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, lastInsertId) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *sequenceName = NULL, sequenceName_sub, __$null, pdo, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&sequenceName_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &sequenceName); - - if (!sequenceName) { - sequenceName = &sequenceName_sub; - sequenceName = &__$null; - } - - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_0); - if (Z_TYPE_P(&pdo) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - ZEPHIR_RETURN_CALL_METHOD(&pdo, "lastinsertid", NULL, 0, sequenceName); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Returns a PDO prepared statement to be executed with 'executePrepared' - * - * - * use Phalcon\Db\Column; - * - * $statement = $db->prepare( - * "SELECT * FROM robots WHERE name = :name" - * ); - * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] - * ); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, prepare) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *sqlStatement_param = NULL, _0; - zval sqlStatement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&sqlStatement); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - 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") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { - zephir_get_strval(&sqlStatement, sqlStatement_param); - } else { - ZEPHIR_INIT_VAR(&sqlStatement); - ZVAL_EMPTY_STRING(&sqlStatement); - } - - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "prepare", NULL, 0, &sqlStatement); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server is - * returning rows - * - * - * // Querying data - * $resultset = $connection->query( - * "SELECT * FROM robots WHERE type = 'mechanical'" - * ); - * - * $resultset = $connection->query( - * "SELECT * FROM robots WHERE type = ?", - * [ - * "mechanical", - * ] - * ); - * - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, query) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *sqlStatement_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, eventsManager, pdo, statement, params, types, _0, _3, _1$$3, _2$$3, _4$$9; - zval sqlStatement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&sqlStatement); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&types); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$9); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams, &bindTypes); - - 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") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { - zephir_get_strval(&sqlStatement, sqlStatement_param); - } else { - ZEPHIR_INIT_VAR(&sqlStatement); - ZVAL_EMPTY_STRING(&sqlStatement); - } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; - } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; - } - - - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - zephir_update_property_zval(this_ptr, SL("sqlStatement"), &sqlStatement); - zephir_update_property_zval(this_ptr, SL("sqlVariables"), bindParams); - zephir_update_property_zval(this_ptr, SL("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(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_BOOL(0); - } - } - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_0); - if (Z_TYPE_P(bindParams) == IS_ARRAY) { - 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_CALL_METHOD(&statement, &pdo, "prepare", NULL, 0, &sqlStatement); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&statement) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Cannot prepare statement", "phalcon/Db/Adapter/Pdo.zep", 737); - return; - } - 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_pdo_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 40, this_ptr, &statement, &sqlStatement, bindParams, bindTypes); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_CCTOR(&statement); - -} - -/** - * Rollbacks the active transaction in the connection - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, rollback) { - - zend_long ZEPHIR_LAST_CALL_STATUS, transactionLevel = 0; - zval *nesting_param = NULL, pdo, eventsManager, savepointName, _0, _1, _6, _2$$5, _3$$6, _7$$9; - zend_bool nesting, _4, _5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&pdo); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&savepointName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_7$$9); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &nesting_param); - - if (!nesting_param) { - nesting = 1; - } else { - nesting = zephir_get_boolval(nesting_param); - } - - - zephir_read_property(&_0, this_ptr, SL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pdo, &_0); - if (Z_TYPE_P(&pdo) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - ZEPHIR_OBS_VAR(&_1); - zephir_read_property(&_1, this_ptr, SL("transactionLevel"), PH_NOISY_CC); - transactionLevel = zephir_get_intval(&_1); - if (UNEXPECTED(!transactionLevel)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "There is no active transaction", "phalcon/Db/Adapter/Pdo.zep", 779); - return; - } - if (transactionLevel == 1) { - zephir_read_property(&_2$$5, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_2$$5); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_3$$6); - ZVAL_STRING(&_3$$6, "db:rollbackTransaction"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_3$$6, this_ptr); - zephir_check_call_status(); - } - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - ZEPHIR_RETURN_CALL_METHOD(&pdo, "rollback", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - _4 = !transactionLevel; - 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) { - if (transactionLevel > 0) { - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - } - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_7$$9); - ZVAL_STRING(&_7$$9, "db:rollbackSavepoint"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_7$$9, this_ptr, &savepointName); - zephir_check_call_status(); - } - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC)); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rollbacksavepoint", NULL, 0, &savepointName); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Returns PDO adapter DSN defaults as a key-value map. - */ -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getDsnDefaults) { - -} - diff --git a/ext/phalcon/db/adapter/pdo.zep.h b/ext/phalcon/db/adapter/pdo.zep.h deleted file mode 100644 index cb09d6143ce..00000000000 --- a/ext/phalcon/db/adapter/pdo.zep.h +++ /dev/null @@ -1,212 +0,0 @@ - -extern zend_class_entry *phalcon_db_adapter_pdo_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo); - -PHP_METHOD(Phalcon_Db_Adapter_Pdo, __construct); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, affectedRows); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, begin); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, commit); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, close); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, convertBoundParams); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, escapeString); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, execute); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, executePrepared); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getErrorInfo); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getInternalHandler); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getTransactionLevel); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, isUnderTransaction); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, lastInsertId); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, prepare); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, query); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, rollback); -PHP_METHOD(Phalcon_Db_Adapter_Pdo, getDsnDefaults); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_db_adapter_pdo___construct, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, descriptor, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_affectedrows, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_affectedrows, 0, 0, IS_LONG, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_begin, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_begin, 0, 0, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, nesting, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, nesting) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_commit, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_commit, 0, 0, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, nesting, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, nesting) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_close, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_close, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_connect, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_connect, 0, 0, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, descriptor, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_convertboundparams, 0, 1, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_convertboundparams, 0, 1, IS_ARRAY, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, sql, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, sql) -#endif - ZEND_ARG_ARRAY_INFO(0, params, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_escapestring, 0, 1, IS_STRING, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_escapestring, 0, 1, IS_STRING, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, str) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_execute, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_execute, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, sqlStatement, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, sqlStatement) -#endif - ZEND_ARG_INFO(0, bindParams) - ZEND_ARG_INFO(0, bindTypes) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_db_adapter_pdo_executeprepared, 0, 3, PDOStatement, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_executeprepared, 0, 3, IS_OBJECT, "PDOStatement", 0) -#endif - ZEND_ARG_OBJ_INFO(0, statement, PDOStatement, 0) - ZEND_ARG_ARRAY_INFO(0, placeholders, 0) - ZEND_ARG_INFO(0, dataTypes) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_db_adapter_pdo_getinternalhandler, 0, 0, Pdo, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_getinternalhandler, 0, 0, IS_OBJECT, "Pdo", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_gettransactionlevel, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_gettransactionlevel, 0, 0, IS_LONG, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_isundertransaction, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_isundertransaction, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_db_adapter_pdo_lastinsertid, 0, 0, 0) - ZEND_ARG_INFO(0, sequenceName) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_db_adapter_pdo_prepare, 0, 1, PDOStatement, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_prepare, 0, 1, IS_OBJECT, "PDOStatement", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, sqlStatement, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, sqlStatement) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_db_adapter_pdo_query, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, sqlStatement, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, sqlStatement) -#endif - ZEND_ARG_INFO(0, bindParams) - ZEND_ARG_INFO(0, bindTypes) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_rollback, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_rollback, 0, 0, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, nesting, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, nesting) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_getdsndefaults, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_db_adapter_pdo_getdsndefaults, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_db_adapter_pdo_method_entry) { - PHP_ME(Phalcon_Db_Adapter_Pdo, __construct, arginfo_phalcon_db_adapter_pdo___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_ME(Phalcon_Db_Adapter_Pdo, affectedRows, arginfo_phalcon_db_adapter_pdo_affectedrows, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, begin, arginfo_phalcon_db_adapter_pdo_begin, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, commit, arginfo_phalcon_db_adapter_pdo_commit, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, close, arginfo_phalcon_db_adapter_pdo_close, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, connect, arginfo_phalcon_db_adapter_pdo_connect, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, convertBoundParams, arginfo_phalcon_db_adapter_pdo_convertboundparams, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, escapeString, arginfo_phalcon_db_adapter_pdo_escapestring, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, execute, arginfo_phalcon_db_adapter_pdo_execute, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, executePrepared, arginfo_phalcon_db_adapter_pdo_executeprepared, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, getErrorInfo, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, getInternalHandler, arginfo_phalcon_db_adapter_pdo_getinternalhandler, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, getTransactionLevel, arginfo_phalcon_db_adapter_pdo_gettransactionlevel, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, isUnderTransaction, arginfo_phalcon_db_adapter_pdo_isundertransaction, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, lastInsertId, arginfo_phalcon_db_adapter_pdo_lastinsertid, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, prepare, arginfo_phalcon_db_adapter_pdo_prepare, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, query, arginfo_phalcon_db_adapter_pdo_query, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, rollback, arginfo_phalcon_db_adapter_pdo_rollback, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Db_Adapter_Pdo, getDsnDefaults, arginfo_phalcon_db_adapter_pdo_getdsndefaults, ZEND_ACC_ABSTRACT|ZEND_ACC_PROTECTED) - PHP_FE_END -}; diff --git a/phalcon/Db/AbstractDb.zep b/phalcon/Db/AbstractDb.zep index e358ac36c9b..a1eb8ac3bb6 100644 --- a/phalcon/Db/AbstractDb.zep +++ b/phalcon/Db/AbstractDb.zep @@ -22,8 +22,8 @@ use \PDO as Pdo; * interact with databases using higher level of abstraction use * Phalcon\Mvc\Model. * - * Phalcon\Db is an abstract class. You only can use it with a database adapter - * like Phalcon\Db\Adapter\Pdo + * Phalcon\Db\AbstractDb is an abstract class. You only can use it with a + * database adapter like Phalcon\Db\Adapter\Pdo * *```php * use Phalcon\Db; diff --git a/phalcon/Db/Adapter/Pdo.zep b/phalcon/Db/Adapter/Pdo/AbstractPdo.zep similarity index 99% rename from phalcon/Db/Adapter/Pdo.zep rename to phalcon/Db/Adapter/Pdo/AbstractPdo.zep index 78817f2101f..668621fcb1d 100644 --- a/phalcon/Db/Adapter/Pdo.zep +++ b/phalcon/Db/Adapter/Pdo/AbstractPdo.zep @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Phalcon\Db\Adapter; +namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\Adapter\AbstractAdapter; use Phalcon\Db\Column; @@ -35,7 +35,7 @@ use Phalcon\Events\ManagerInterface; * $connection = new Mysql($config); *``` */ -abstract class Pdo extends AbstractAdapter +abstract class AbstractPdo extends AbstractAdapter { /** * Last affected rows diff --git a/phalcon/Db/Adapter/Pdo/Mysql.zep b/phalcon/Db/Adapter/Pdo/Mysql.zep index 21bf9ba608f..ffecae8a9af 100644 --- a/phalcon/Db/Adapter/Pdo/Mysql.zep +++ b/phalcon/Db/Adapter/Pdo/Mysql.zep @@ -10,7 +10,7 @@ namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo as PdoAdapter; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; use Phalcon\Db\Column; use Phalcon\Db\ColumnInterface; use Phalcon\Db\Enum; diff --git a/phalcon/Db/Adapter/Pdo/Postgresql.zep b/phalcon/Db/Adapter/Pdo/Postgresql.zep index 6510ce48982..1eeb731a918 100644 --- a/phalcon/Db/Adapter/Pdo/Postgresql.zep +++ b/phalcon/Db/Adapter/Pdo/Postgresql.zep @@ -10,7 +10,7 @@ namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo as PdoAdapter; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; use Phalcon\Db\Column; use Phalcon\Db\ColumnInterface; use Phalcon\Db\Enum; diff --git a/phalcon/Db/Adapter/Pdo/Sqlite.zep b/phalcon/Db/Adapter/Pdo/Sqlite.zep index ff92fd7c56a..b00ac84748c 100644 --- a/phalcon/Db/Adapter/Pdo/Sqlite.zep +++ b/phalcon/Db/Adapter/Pdo/Sqlite.zep @@ -10,7 +10,7 @@ namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo as PdoAdapter; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; use Phalcon\Db\Column; use Phalcon\Db\ColumnInterface; use Phalcon\Db\Enum; diff --git a/phalcon/Tag.zep b/phalcon/Tag.zep index f950392c9e1..2249dbf50e9 100644 --- a/phalcon/Tag.zep +++ b/phalcon/Tag.zep @@ -18,7 +18,7 @@ use Phalcon\UrlInterface; /** * Phalcon\Tag is designed to simplify building of HTML tags. * It provides a set of helpers to generate HTML in a dynamic way. - * This component is an abstract class that you can extend to add more helpers. + * This component is a class that you can extend to add more helpers. */ class Tag {