本文整理汇总了C++中PHALCON_MM_GROW函数的典型用法代码示例。如果您正苦于以下问题:C++ PHALCON_MM_GROW函数的具体用法?C++ PHALCON_MM_GROW怎么用?C++ PHALCON_MM_GROW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHALCON_MM_GROW函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Returns the string meaning of a logger constant
*
* @param integer $type
* @return string
*/
PHP_METHOD(Phalcon_Logger_Adapter_File, getTypeString){
zval *type = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &type) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_SEPARATE_PARAM(type);
if (phalcon_compare_strict_long(type, 7 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "DEBUG", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 3 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "ERROR", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 4 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "WARNING", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 1 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "CRITICAL", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 8 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "CUSTOM", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 2 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "ALERT", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 5 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "NOTICE", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 6 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "INFO", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 0 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "EMERGENCE", 1);
goto se_654f_0;
}
if (phalcon_compare_strict_long(type, 9 TSRMLS_CC)) {
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "SPECIAL", 1);
goto se_654f_0;
}
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "CUSTOM", 1);
se_654f_0:
RETURN_CCTOR(type);
}
开发者ID:codeanu,项目名称:cphalcon,代码行数:75,代码来源:file.c
示例2: PHP_METHOD
PHP_METHOD(Phalcon_Http_Client_Header, parse){
zval *content, *content_parts = NULL, *key = NULL, *header = NULL, *header_parts = NULL, *name = NULL, *value = NULL, *trimmed = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &content);
if (PHALCON_IS_EMPTY(content)) {
RETURN_MM_FALSE;
}
if (Z_TYPE_P(content) == IS_STRING) {
PHALCON_INIT_VAR(content_parts);
phalcon_fast_explode_str(content_parts, SL("\r\n"), content);
} else if (Z_TYPE_P(content) == IS_ARRAY) {
PHALCON_CPY_WRT_CTOR(content_parts, content);
} else {
RETURN_MM_FALSE;
}
phalcon_is_iterable(content_parts, &ah0, &hp0, 0, 0);
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_HKEY(key, ah0, hp0);
PHALCON_GET_HVALUE(header);
if (Z_TYPE_P(header) == IS_STRING) {
PHALCON_INIT_NVAR(header_parts);
if (phalcon_memnstr_str(header , SL(":"))) {
phalcon_fast_explode_str(header_parts, SL(":"), header);
} else {
if (phalcon_start_with_str(header , SL("HTTP/"))) {
phalcon_fast_explode_str(header_parts, SL(" "), header);
if (Z_TYPE_P(header_parts) == IS_ARRAY && phalcon_array_isset_long(header_parts, 1) && phalcon_array_isset_long(header_parts, 2)) {
PHALCON_OBS_NVAR(value);
phalcon_array_fetch_long(&value, header_parts, 1, PH_NOISY);
phalcon_update_property_this(this_ptr, SL("_status_code"), value TSRMLS_CC);
PHALCON_OBS_NVAR(value);
phalcon_array_fetch_long(&value, header_parts, 2, PH_NOISY);
phalcon_update_property_this(this_ptr, SL("_status_message"), value TSRMLS_CC);
}
}
zend_hash_move_forward_ex(ah0, &hp0);
continue;
}
} else {
PHALCON_CPY_WRT_CTOR(header_parts, header);
}
if (Z_TYPE_P(header_parts) == IS_ARRAY && phalcon_array_isset_long(header_parts, 0) && phalcon_array_isset_long(header_parts, 1)) {
PHALCON_OBS_NVAR(name);
phalcon_array_fetch_long(&name, header_parts, 0, PH_NOISY);
PHALCON_OBS_NVAR(value);
phalcon_array_fetch_long(&value, header_parts, 1, PH_NOISY);
PHALCON_INIT_NVAR(trimmed);
phalcon_fast_trim(trimmed, value, NULL, PHALCON_TRIM_BOTH TSRMLS_CC);
PHALCON_CALL_METHOD(NULL, this_ptr, "set", name, trimmed);
}
zend_hash_move_forward_ex(ah0, &hp0);
}
PHALCON_MM_RESTORE();
}
开发者ID:Myleft,项目名称:cphalcon,代码行数:73,代码来源:header.c
示例3: PHP_METHOD
/**
* Initialize the metadata for certain table
*
* @param Phalcon\Mvc\Model $model
* @param string $table
* @param string $schema
*/
PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initializeMetaData){
zval *model = NULL, *table = NULL, *schema = NULL, *key = NULL, *connection = NULL, *exists = NULL;
zval *complete_table = NULL, *attributes = NULL, *primary_keys = NULL;
zval *non_primary_keys = NULL, *numeric_typed = NULL, *not_null = NULL;
zval *field_types = NULL, *identity_field = NULL, *columns = NULL;
zval *column = NULL, *field_name = NULL, *table_metadata = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL;
zval *i0 = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL;
zval *a0 = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
int eval_int;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &model, &table, &schema) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_INIT_VAR(key);
PHALCON_CONCAT_VV(key, schema, table);
PHALCON_ALLOC_ZVAL_MM(t0);
phalcon_read_property(&t0, this_ptr, SL("_metaData"), PH_NOISY_CC);
eval_int = phalcon_array_isset(t0, key);
if (!eval_int) {
PHALCON_INIT_VAR(connection);
PHALCON_CALL_METHOD(connection, model, "getconnection", PH_NO_CHECK);
PHALCON_INIT_VAR(exists);
PHALCON_CALL_METHOD_PARAMS_2(exists, connection, "tableexists", table, schema, PH_NO_CHECK);
if (!zend_is_true(exists)) {
if (zend_is_true(schema)) {
PHALCON_INIT_VAR(complete_table);
PHALCON_CONCAT_VSV(complete_table, schema, "\".\"", table);
} else {
PHALCON_CPY_WRT(complete_table, table);
}
PHALCON_ALLOC_ZVAL_MM(i0);
object_init_ex(i0, phalcon_mvc_model_exception_ce);
PHALCON_ALLOC_ZVAL_MM(r0);
phalcon_get_class(r0, model TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r1);
PHALCON_CONCAT_SVSV(r1, "Table \"", complete_table, "\" doesn't exist on database when dumping meta-data for ", r0);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r1, PH_CHECK);
phalcon_throw_exception(i0 TSRMLS_CC);
return;
}
PHALCON_INIT_VAR(attributes);
array_init(attributes);
PHALCON_INIT_VAR(primary_keys);
array_init(primary_keys);
PHALCON_INIT_VAR(non_primary_keys);
array_init(non_primary_keys);
PHALCON_INIT_VAR(numeric_typed);
array_init(numeric_typed);
PHALCON_INIT_VAR(not_null);
array_init(not_null);
PHALCON_INIT_VAR(field_types);
array_init(field_types);
PHALCON_INIT_VAR(identity_field);
ZVAL_BOOL(identity_field, 0);
PHALCON_INIT_VAR(columns);
PHALCON_CALL_METHOD_PARAMS_2(columns, connection, "describecolumns", table, schema, PH_NO_CHECK);
if (!phalcon_valid_foreach(columns TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(columns);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_c40c_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_c40c_0;
}
PHALCON_INIT_VAR(column);
ZVAL_ZVAL(column, *hd, 1, 0);
PHALCON_INIT_VAR(field_name);
//.........这里部分代码省略.........
开发者ID:fatihzkaratana,项目名称:cphalcon,代码行数:101,代码来源:metadata.c
示例4: PHP_METHOD
/**
* Moves internal resulset cursor to another position letting us to fetch a certain row
*
*<code>
* $result = $connection->query("SELECT * FROM robots ORDER BY name");
* $result->dataSeek(2); // Move to third row on result
* $row = $result->fetch(); // Fetch third row
*</code>
*
* @param int $number
*/
PHP_METHOD(Phalcon_Db_Result_Pdo, dataSeek){
long number = 0, n;
zval *connection, *pdo = NULL, *sql_statement;
zval *bind_params, *bind_types, *statement = NULL;
zval *temp_statement = NULL;
pdo_stmt_t *stmt;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &number) == FAILURE) {
RETURN_MM_NULL();
}
PHALCON_OBS_VAR(connection);
phalcon_read_property(&connection, this_ptr, SL("_connection"), PH_NOISY TSRMLS_CC);
PHALCON_CALL_METHOD(&pdo, connection, "getinternalhandler");
PHALCON_OBS_VAR(sql_statement);
phalcon_read_property(&sql_statement, this_ptr, SL("_sqlStatement"), PH_NOISY TSRMLS_CC);
PHALCON_OBS_VAR(bind_params);
phalcon_read_property(&bind_params, this_ptr, SL("_bindParams"), PH_NOISY TSRMLS_CC);
/**
* PDO doesn't support scrollable cursors, so we need to re-execute the statement again
*/
if (Z_TYPE_P(bind_params) == IS_ARRAY) {
PHALCON_OBS_VAR(bind_types);
phalcon_read_property(&bind_types, this_ptr, SL("_bindTypes"), PH_NOISY TSRMLS_CC);
PHALCON_CALL_METHOD(&statement, pdo, "prepare", sql_statement);
if (Z_TYPE_P(statement) == IS_OBJECT) {
PHALCON_CALL_METHOD(&temp_statement, connection, "executeprepared", statement, bind_params, bind_types);
PHALCON_CPY_WRT(statement, temp_statement);
}
} else {
PHALCON_CALL_METHOD(&statement, pdo, "query", sql_statement);
}
phalcon_update_property_zval(this_ptr, SL("_pdoStatement"), statement TSRMLS_CC);
/**
* This a fetch scroll to reach the desired position, however with a big number of records
* maybe it may be very slow
*/
stmt = (pdo_stmt_t*) zend_object_store_get_object(statement TSRMLS_CC);
if (!stmt->dbh) {
PHALCON_MM_RESTORE();
RETURN_FALSE;
}
n = -1;
number--;
while (n != number) {
if(!stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
n++;
}
PHALCON_MM_RESTORE();
}
开发者ID:100851766,项目名称:cphalcon,代码行数:81,代码来源:pdo.c
示例5: PHP_METHOD
/**
* Stores cached content into the Memcached backend and stops the frontend
*
* @param int|string $keyName
* @param string $content
* @param long $lifetime
* @param boolean $stopBuffer
*/
PHP_METHOD(Phalcon_Cache_Backend_Memcache, save){
zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;
zval *cached_content = NULL, *prepared_content = NULL, *ttl = NULL, *flags, *success = NULL;
zval *keys = NULL, *is_buffering = NULL;
zval *last_key, *frontend, *memcache, *options, *special_key;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer);
if (!key_name || Z_TYPE_P(key_name) == IS_NULL) {
last_key = phalcon_fetch_nproperty_this(this_ptr, SL("_lastKey"), PH_NOISY TSRMLS_CC);
} else {
zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC);
PHALCON_INIT_VAR(last_key);
PHALCON_CONCAT_VV(last_key, prefix, key_name);
}
if (!zend_is_true(last_key)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");
return;
}
frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC);
/**
* Check if a connection is created or make a new one
*/
memcache = phalcon_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY TSRMLS_CC);
if (Z_TYPE_P(memcache) != IS_OBJECT) {
memcache = NULL;
PHALCON_CALL_METHOD(&memcache, this_ptr, "_connect");
}
if (!content || Z_TYPE_P(content) == IS_NULL) {
PHALCON_CALL_METHOD(&cached_content, frontend, "getcontent");
} else {
cached_content = content;
}
/**
* Prepare the content in the frontend
*/
PHALCON_CALL_METHOD(&prepared_content, frontend, "beforestore", cached_content);
if (!lifetime || Z_TYPE_P(lifetime) == IS_NULL) {
zval *tmp = phalcon_fetch_nproperty_this(this_ptr, SL("_lastLifetime"), PH_NOISY TSRMLS_CC);
if (Z_TYPE_P(tmp) == IS_NULL) {
PHALCON_CALL_METHOD(&ttl, frontend, "getlifetime");
}
else {
ttl = tmp;
}
} else {
ttl = lifetime;
}
PHALCON_INIT_VAR(flags);
ZVAL_LONG(flags, 0);
/**
* We store without flags
*/
if (phalcon_is_numeric(cached_content)) {
PHALCON_CALL_METHOD(&success, memcache, "set", last_key, cached_content, flags, ttl);
} else {
PHALCON_CALL_METHOD(&success, memcache, "set", last_key, prepared_content, flags, ttl);
}
if (!zend_is_true(success)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Failed to store data in memcached");
return;
}
options = phalcon_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY TSRMLS_CC);
if (unlikely(!phalcon_array_isset_string_fetch(&special_key, options, SS("statsKey")))) {
PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options");
return;
}
if (Z_TYPE_P(special_key) != IS_NULL) {
/* Update the stats key */
PHALCON_CALL_METHOD(&keys, memcache, "get", special_key);
if (Z_TYPE_P(keys) != IS_ARRAY) {
PHALCON_INIT_NVAR(keys);
array_init(keys);
}
//.........这里部分代码省略.........
开发者ID:Myleft,项目名称:cphalcon,代码行数:101,代码来源:memcache.c
示例6: PHP_METHOD
/**
* Initialize the metadata for certain table
*
* @param Phalcon\Mvc\ModelInterface $model
* @param string $key
* @param string $table
* @param string $schema
*/
PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) {
zval *model, *key, *table, *schema, *strategy = NULL, *class_name;
zval *meta_data = NULL, *prefix_key = NULL, *data = NULL, *model_metadata = NULL;
zval *exception_message, *dependency_injector = NULL;
zval *key_name, *column_map = NULL, *model_column_map;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 4, 0, &model, &key, &table, &schema);
PHALCON_INIT_VAR(strategy);
PHALCON_INIT_VAR(class_name);
phalcon_get_class(class_name, model, 0 TSRMLS_CC);
if (Z_TYPE_P(key) != IS_NULL) {
PHALCON_OBS_VAR(meta_data);
phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC);
if (!phalcon_array_isset(meta_data, key)) {
PHALCON_INIT_VAR(prefix_key);
PHALCON_CONCAT_SV(prefix_key, "meta-", key);
/**
* The meta-data is read from the adapter always
*/
PHALCON_INIT_VAR(data);
phalcon_call_method_p1(data, this_ptr, "read", prefix_key);
if (Z_TYPE_P(data) != IS_NULL) {
if (Z_TYPE_P(meta_data) != IS_ARRAY) {
PHALCON_INIT_NVAR(meta_data);
array_init(meta_data);
}
phalcon_array_update_zval(&meta_data, key, &data, PH_COPY | PH_SEPARATE);
phalcon_update_property_this(this_ptr, SL("_metaData"), meta_data TSRMLS_CC);
} else {
/**
* Check if there is a method 'metaData' in the model to retrieve meta-data from it
*/
if (phalcon_method_exists_ex(model, SS("metadata") TSRMLS_CC) == SUCCESS) {
PHALCON_INIT_VAR(model_metadata);
phalcon_call_method(model_metadata, model, "metadata");
if (Z_TYPE_P(model_metadata) != IS_ARRAY) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SV(exception_message, "Invalid meta-data for model ", class_name);
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);
return;
}
} else {
PHALCON_OBS_VAR(dependency_injector);
phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
/**
* Get the meta-data extraction strategy
*/
phalcon_call_method(strategy, this_ptr, "getstrategy");
/**
* Get the meta-data
*/
PHALCON_INIT_NVAR(model_metadata);
phalcon_call_method_p2(model_metadata, strategy, "getmetadata", model, dependency_injector);
}
/**
* Store the meta-data locally
*/
phalcon_update_property_array(this_ptr, SL("_metaData"), key, model_metadata TSRMLS_CC);
/**
* Store the meta-data in the adapter
*/
phalcon_call_method_p2_noret(this_ptr, "write", prefix_key, model_metadata);
}
}
}
/**
* Check for a column map, store in _columnMap in order and reversed order
*/
if (!PHALCON_GLOBAL(orm).column_renaming) {
RETURN_MM_NULL();
}
PHALCON_INIT_VAR(key_name);
phalcon_fast_strtolower(key_name, class_name);
PHALCON_OBS_VAR(column_map);
phalcon_read_property_this(&column_map, this_ptr, SL("_columnMap"), PH_NOISY_CC);
if (phalcon_array_isset(column_map, key_name)) {
//.........这里部分代码省略.........
开发者ID:rakeshbitling,项目名称:cphalcon,代码行数:101,代码来源:metadata.c
示例7: PHP_METHOD
PHP_METHOD(Phalcon_Flash, _showMessage){
zval *v0 = NULL, *v1 = NULL, *v2 = NULL, *v3 = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL;
zval *c0 = NULL;
zval *t0 = NULL, *t1 = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &v0, &v1) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (Z_TYPE_P(v1) == IS_ARRAY) {
PHALCON_ALLOC_ZVAL_MM(r0);
PHALCON_INIT_VAR(c0);
ZVAL_STRING(c0, " ", 1);
PHALCON_CALL_FUNC_PARAMS_2(r0, "join", c0, v1, 0x00F);
PHALCON_CPY_WRT(v2, r0);
} else {
PHALCON_CPY_WRT(v2, v1);
}
if (Z_TYPE_P(v0) == IS_ARRAY) {
if (Z_TYPE_P(v0) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument supplied for foreach()");
} else {
ah0 = Z_ARRVAL_P(v0);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_3b3c_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_3b3c_0;
}
PHALCON_INIT_VAR(v3);
ZVAL_ZVAL(v3, *hd, 1, 0);
PHALCON_INIT_VAR(r3);
PHALCON_CONCAT_LEFT(r3, "<div class=\"", v2);
PHALCON_INIT_VAR(r2);
PHALCON_CONCAT_VBOTH(r2, r3, "\">", v3);
PHALCON_INIT_VAR(t0);
zend_get_constant("PHP_EOL", strlen("PHP_EOL"), t0 TSRMLS_CC);
PHALCON_INIT_VAR(r1);
PHALCON_CONCAT_VBOTH(r1, r2, "</div>", t0);
zend_print_zval(r1, 0);
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_3b3c_0;
fee_3b3c_0:
if(0){ };
}
} else {
PHALCON_ALLOC_ZVAL_MM(r6);
PHALCON_CONCAT_LEFT(r6, "<div class=\"", v2);
PHALCON_ALLOC_ZVAL_MM(r5);
PHALCON_CONCAT_VBOTH(r5, r6, "\">", v0);
PHALCON_ALLOC_ZVAL_MM(t1);
zend_get_constant("PHP_EOL", strlen("PHP_EOL"), t1 TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r4);
PHALCON_CONCAT_VBOTH(r4, r5, "</div>", t1);
zend_print_zval(r4, 0);
}
PHALCON_MM_RESTORE();
RETURN_NULL();
}
开发者ID:xingskycn,项目名称:cphalcon,代码行数:67,代码来源:flash.c
示例8: PHP_METHOD
/**
* Generates a URL
*
* @param string|array $uri
* @return string
*/
PHP_METHOD(Phalcon_Mvc_Url, get){
zval *uri = NULL, *base_uri, *dependency_injector, *service;
zval *router, *route_name, *route, *exception_message;
zval *pattern, *paths, *processed_uri, *final_uri = NULL;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 1, &uri);
if (!uri) {
PHALCON_INIT_VAR(uri);
}
PHALCON_INIT_VAR(base_uri);
PHALCON_CALL_METHOD(base_uri, this_ptr, "getbaseuri");
if (Z_TYPE_P(uri) == IS_ARRAY) {
if (!phalcon_array_isset_string(uri, SS("for"))) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter \"for\"");
return;
}
PHALCON_OBS_VAR(dependency_injector);
phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
if (!zend_is_true(dependency_injector)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the \"url\" service");
return;
}
PHALCON_INIT_VAR(service);
ZVAL_STRING(service, "router", 1);
PHALCON_INIT_VAR(router);
PHALCON_CALL_METHOD_PARAMS_1(router, dependency_injector, "getshared", service);
PHALCON_OBS_VAR(route_name);
phalcon_array_fetch_string(&route_name, uri, SL("for"), PH_NOISY_CC);
/**
* Every route is uniquely differenced by a name
*/
PHALCON_INIT_VAR(route);
PHALCON_CALL_METHOD_PARAMS_1(route, router, "getroutebyname", route_name);
if (Z_TYPE_P(route) != IS_OBJECT) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Cannot obtain a route using the name \"", route_name, "\"");
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_url_exception_ce, exception_message);
return;
}
PHALCON_INIT_VAR(pattern);
PHALCON_CALL_METHOD(pattern, route, "getpattern");
/**
* Return the reversed paths
*/
PHALCON_INIT_VAR(paths);
PHALCON_CALL_METHOD(paths, route, "getreversedpaths");
/**
* Replace the patterns by its variables
*/
PHALCON_INIT_VAR(processed_uri);
phalcon_replace_paths(processed_uri, pattern, paths, uri TSRMLS_CC);
PHALCON_INIT_VAR(final_uri);
PHALCON_CONCAT_VV(final_uri, base_uri, processed_uri);
RETURN_CTOR(final_uri);
}
PHALCON_INIT_NVAR(final_uri);
PHALCON_CONCAT_VV(final_uri, base_uri, uri);
RETURN_CTOR(final_uri);
}
开发者ID:angkatan21,项目名称:cphalcon,代码行数:82,代码来源:url.c
示例9: PHP_METHOD
/**
* Gets information about schema, host and port used by the request
*
* @return string
*/
PHP_METHOD(Phalcon_Http_Request, getHttpHost){
zval *scheme, *server_name, *name, *server_port;
zval *port, *http, *standard_port, *is_std_name;
zval *is_std_port, *is_std_http, *https, *secure_port;
zval *is_secure_scheme, *is_secure_port, *is_secure_http;
zval *name_port;
PHALCON_MM_GROW();
PHALCON_INIT_VAR(scheme);
PHALCON_CALL_METHOD(scheme, this_ptr, "getscheme");
/**
* Get the server name from _SERVER['SERVER_NAME']
*/
PHALCON_INIT_VAR(server_name);
ZVAL_STRING(server_name, "SERVER_NAME", 1);
PHALCON_INIT_VAR(name);
PHALCON_CALL_METHOD_PARAMS_1(name, this_ptr, "getserver", server_name);
/**
* Get the server port from _SERVER['SERVER_PORT']
*/
PHALCON_INIT_VAR(server_port);
ZVAL_STRING(server_port, "SERVER_PORT", 1);
PHALCON_INIT_VAR(port);
PHALCON_CALL_METHOD_PARAMS_1(port, this_ptr, "getserver", server_port);
PHALCON_INIT_VAR(http);
ZVAL_STRING(http, "http", 1);
PHALCON_INIT_VAR(standard_port);
ZVAL_LONG(standard_port, 80);
/**
* Check if the request is a standard http
*/
PHALCON_INIT_VAR(is_std_name);
is_equal_function(is_std_name, scheme, http TSRMLS_CC);
PHALCON_INIT_VAR(is_std_port);
is_equal_function(is_std_port, port, standard_port TSRMLS_CC);
PHALCON_INIT_VAR(is_std_http);
phalcon_and_function(is_std_http, is_std_name, is_std_port);
PHALCON_INIT_VAR(https);
ZVAL_STRING(https, "https", 1);
PHALCON_INIT_VAR(secure_port);
ZVAL_LONG(secure_port, 443);
/**
* Check if the request is a secure http request
*/
PHALCON_INIT_VAR(is_secure_scheme);
is_equal_function(is_secure_scheme, scheme, https TSRMLS_CC);
PHALCON_INIT_VAR(is_secure_port);
is_equal_function(is_secure_port, port, secure_port TSRMLS_CC);
PHALCON_INIT_VAR(is_secure_http);
phalcon_and_function(is_secure_http, is_secure_scheme, is_secure_port);
/**
* If is standard http we return the server name only
*/
if (PHALCON_IS_TRUE(is_std_http)) {
RETURN_CCTOR(name);
}
/**
* If is standard secure http we return the server name only
*/
if (PHALCON_IS_TRUE(is_secure_http)) {
RETURN_CCTOR(name);
}
PHALCON_INIT_VAR(name_port);
PHALCON_CONCAT_VSV(name_port, name, ":", port);
RETURN_CTOR(name_port);
}
开发者ID:BlueShark,项目名称:cphalcon,代码行数:91,代码来源:request.c
示例10: PHP_METHOD
/**
* Appends an IN condition to the current conditions
*
*<code>
* $builder->inWhere('id', [1, 2, 3]);
*</code>
*
* @param string $expr
* @param array $values
* @return Phalcon\Mvc\Model\Query\Builder
*/
PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inWhere){
zval *expr, *values, *hidden_param, *bind_params;
zval *bind_keys, *value = NULL, *key = NULL, *query_key = NULL, *joined_keys;
zval *conditions;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &expr, &values);
if (Z_TYPE_P(values) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Values must be an array");
return;
}
PHALCON_OBS_VAR(hidden_param);
phalcon_read_property_this(&hidden_param, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC);
SEPARATE_ZVAL(&hidden_param);
PHALCON_INIT_VAR(bind_params);
array_init(bind_params);
PHALCON_INIT_VAR(bind_keys);
array_init(bind_keys);
phalcon_is_iterable(values, &ah0, &hp0, 0, 0);
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_HVALUE(value);
/**
* Key with auto bind-params
*/
PHALCON_INIT_NVAR(key);
PHALCON_CONCAT_SV(key, "phi", hidden_param);
PHALCON_INIT_NVAR(query_key);
PHALCON_CONCAT_SVS(query_key, ":", key, ":");
phalcon_array_append(&bind_keys, query_key, PH_SEPARATE);
phalcon_array_update_zval(&bind_params, key, &value, PH_COPY | PH_SEPARATE);
phalcon_increment(hidden_param);
zend_hash_move_forward_ex(ah0, &hp0);
}
PHALCON_INIT_VAR(joined_keys);
phalcon_fast_join_str(joined_keys, SL(", "), bind_keys TSRMLS_CC);
/**
* Create a standard IN condition with bind params
*/
PHALCON_INIT_VAR(conditions);
PHALCON_CONCAT_VSVS(conditions, expr, " IN (", joined_keys, ")");
/**
* Append the IN to the current conditions using and 'and'
*/
phalcon_call_method_p2_noret(this_ptr, "andwhere", conditions, bind_params);
phalcon_update_property_this(this_ptr, SL("_hiddenParamNumber"), hidden_param TSRMLS_CC);
RETURN_THIS();
}
开发者ID:CreativeOutbreak,项目名称:cphalcon,代码行数:77,代码来源:builder.c
示例11: PHP_METHOD
/**
* Executes validator
*
* @return boolean
*/
PHP_METHOD(Phalcon_Mvc_Model_Validator_Exclusionin, validate){
zval *record = NULL, *field_name = NULL, *domain = NULL, *value = NULL;
zval *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL, *c4 = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &record) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_INIT_VAR(c0);
ZVAL_STRING(c0, "field", 1);
PHALCON_INIT_VAR(field_name);
PHALCON_CALL_METHOD_PARAMS_1(field_name, this_ptr, "getoption", c0, PH_NO_CHECK);
if (Z_TYPE_P(field_name) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Field name must be a string");
return;
}
PHALCON_INIT_VAR(c1);
ZVAL_STRING(c1, "domain", 1);
PHALCON_ALLOC_ZVAL_MM(r0);
PHALCON_CALL_METHOD_PARAMS_1(r0, this_ptr, "issetoption", c1, PH_NO_CHECK);
if (!zend_is_true(r0)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The option 'domain' is required for this validator");
return;
}
PHALCON_INIT_VAR(c2);
ZVAL_STRING(c2, "domain", 1);
PHALCON_INIT_VAR(domain);
PHALCON_CALL_METHOD_PARAMS_1(domain, this_ptr, "getoption", c2, PH_NO_CHECK);
if (Z_TYPE_P(domain) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Option 'domain' must be an array");
return;
}
PHALCON_INIT_VAR(value);
PHALCON_CALL_METHOD_PARAMS_1(value, record, "readattribute", field_name, PH_NO_CHECK);
PHALCON_ALLOC_ZVAL_MM(r1);
PHALCON_CALL_FUNC_PARAMS_2(r1, "in_array", value, domain);
if (zend_is_true(r1)) {
PHALCON_INIT_VAR(c3);
ZVAL_STRING(c3, ", ", 1);
PHALCON_ALLOC_ZVAL_MM(r2);
phalcon_fast_join(r2, c3, domain TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r3);
PHALCON_CONCAT_SVSV(r3, "Value of field '", field_name, "' must not be part of list: ", r2);
PHALCON_INIT_VAR(c4);
ZVAL_STRING(c4, "exclusion", 1);
PHALCON_CALL_METHOD_PARAMS_3_NORETURN(this_ptr, "appendmessage", r3, field_name, c4, PH_NO_CHECK);
PHALCON_MM_RESTORE();
RETURN_FALSE;
}
PHALCON_MM_RESTORE();
RETURN_TRUE;
}
开发者ID:fatihzkaratana,项目名称:cphalcon,代码行数:69,代码来源:exclusionin.c
示例12: PHP_METHOD
/**
* Returns a cached content
*
* @param string $keyName
* @return mixed
*/
PHP_METHOD(Phalcon_Cache_Backend_File, get){
zval *key_name = NULL, *backend = NULL, *front_end = NULL, *sanitize_key = NULL;
zval *cache_file = NULL, *time = NULL, *lifetime = NULL, *cached_content = NULL;
zval *t0 = NULL, *t1 = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL;
zval *r7 = NULL, *r8 = NULL, *r9 = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &key_name) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_ALLOC_ZVAL_MM(t0);
phalcon_read_property(&t0, this_ptr, "_backendOptions", sizeof("_backendOptions")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(backend, t0);
PHALCON_ALLOC_ZVAL_MM(t1);
phalcon_read_property(&t1, this_ptr, "_frontendObject", sizeof("_frontendObject")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(front_end, t1);
PHALCON_ALLOC_ZVAL_MM(r0);
phalcon_filter_alphanum(r0, key_name);
PHALCON_CPY_WRT(sanitize_key, r0);
phalcon_update_property_zval(this_ptr, "_lastKey", strlen("_lastKey"), sanitize_key TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r1);
phalcon_array_fetch_string(&r1, backend, "cacheDir", strlen("cacheDir"), PHALCON_NOISY TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r2);
concat_function(r2, r1, sanitize_key TSRMLS_CC);
PHALCON_CPY_WRT(cache_file, r2);
if (phalcon_file_exists(cache_file TSRMLS_CC) == SUCCESS) {
PHALCON_ALLOC_ZVAL_MM(r3);
PHALCON_CALL_FUNC(r3, "time", 0x018);
PHALCON_CPY_WRT(time, r3);
PHALCON_ALLOC_ZVAL_MM(r4);
PHALCON_CALL_METHOD(r4, front_end, "getlifetime", PHALCON_NO_CHECK);
PHALCON_CPY_WRT(lifetime, r4);
PHALCON_ALLOC_ZVAL_MM(r5);
sub_function(r5, time, lifetime TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r6);
PHALCON_CALL_FUNC_PARAMS_1(r6, "filemtime", cache_file, 0x019);
PHALCON_INIT_VAR(r7);
is_smaller_function(r7, r5, r6 TSRMLS_CC);
if (zend_is_true(r7)) {
PHALCON_ALLOC_ZVAL_MM(r8);
PHALCON_CALL_FUNC_PARAMS_1(r8, "file_get_contents", cache_file, 0x01A);
PHALCON_CPY_WRT(cached_content, r8);
PHALCON_ALLOC_ZVAL_MM(r9);
PHALCON_CALL_METHOD_PARAMS_1(r9, front_end, "afterretrieve", cached_content, PHALCON_NO_CHECK);
PHALCON_RETURN_DZVAL(r9);
}
}
PHALCON_MM_RESTORE();
RETURN_NULL();
}
开发者ID:loudertech,项目名称:cphalcon,代码行数:71,代码来源:file.c
示例13: PHP_METHOD
/**
* Fires a event in the events manager causing that the acive listeners will be notified about it
*
* @param string $eventType
* @param object $source
* @param mixed $data
* @return mixed
*/
PHP_METHOD(Phalcon_Events_Manager, fire){
zval *event_type, *source, *data = NULL, *events, *exception_message;
zval *colon, *event_parts, *type, *event_name, *status = NULL;
zval *fire_events = NULL, *handler = NULL, *event = NULL, *arguments = NULL;
HashTable *ah0, *ah1;
HashPosition hp0, hp1;
zval **hd;
int eval_int;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &event_type, &source, &data) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!data) {
PHALCON_INIT_NVAR(data);
}
if (Z_TYPE_P(event_type) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STR(phalcon_events_exception_ce, "Event type must be a string");
return;
}
PHALCON_INIT_VAR(events);
phalcon_read_property(&events, this_ptr, SL("_events"), PH_NOISY_CC);
if (Z_TYPE_P(events) != IS_ARRAY) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!phalcon_memnstr_str(event_type, SL(":") TSRMLS_CC)) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SV(exception_message, "Invalid event type ", event_type);
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_events_exception_ce, exception_message);
return;
}
PHALCON_INIT_VAR(colon);
ZVAL_STRING(colon, ":", 1);
PHALCON_INIT_VAR(event_parts);
phalcon_fast_explode(event_parts, colon, event_type TSRMLS_CC);
PHALCON_INIT_VAR(type);
phalcon_array_fetch_long(&type, event_parts, 0, PH_NOISY_CC);
PHALCON_INIT_VAR(event_name);
phalcon_array_fetch_long(&event_name, event_parts, 1, PH_NOISY_CC);
PHALCON_INIT_VAR(status);
eval_int = phalcon_array_isset(events, type);
if (eval_int) {
PHALCON_INIT_VAR(fire_events);
phalcon_array_fetch(&fire_events, events, type, PH_NOISY_CC);
if (Z_TYPE_P(fire_events) == IS_ARRAY) {
if (!phalcon_valid_foreach(fire_events TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(fire_events);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
ph_cycle_start_0:
if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) {
goto ph_cycle_end_0;
}
PHALCON_GET_FOREACH_VALUE(handler);
if (Z_TYPE_P(handler) == IS_OBJECT) {
if (phalcon_is_instance_of(handler, SL("Closure") TSRMLS_CC)) {
PHALCON_INIT_NVAR(event);
object_init_ex(event, phalcon_events_event_ce);
PHALCON_CALL_METHOD_PARAMS_3_NORETURN(event, "__construct", event_name, source, data, PH_CHECK);
PHALCON_INIT_NVAR(arguments);
array_init(arguments);
phalcon_array_append(&arguments, event, PH_SEPARATE TSRMLS_CC);
phalcon_array_append(&arguments, source, PH_SEPARATE TSRMLS_CC);
phalcon_array_append(&arguments, data, PH_SEPARATE TSRMLS_CC);
PHALCON_INIT_NVAR(status);
PHALCON_CALL_USER_FUNC_ARRAY(status, handler, arguments);
} else {
if (phalcon_method_exists(handler, event_name TSRMLS_CC) == SUCCESS) {
PHALCON_INIT_NVAR(event);
object_init_ex(event, phalcon_events_event_ce);
//.........这里部分代码省略.........
开发者ID:alantonilopez,项目名称:cphalcon,代码行数:101,代码来源:manager.c
示例14: PHP_METHOD
/**
* Restores the internal state of a Phalcon\Db\Column object
*
* @param array $data
* @return \Phalcon\Db\Column
*/
PHP_METHOD(Phalcon_Db_Column, __set_state){
zval *data, *definition, *column_name, *column_type = NULL;
zval *not_null, *primary, *size, *scale, *dunsigned, *after;
zval *is_numeric, *first, *bind_type, *default_value;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &data);
if (Z_TYPE_P(data) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column state must be an array");
return;
}
if (!phalcon_array_isset_string_fetch(&column_name, data, SS("_columnName"))) {
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required");
return;
}
PHALCON_INIT_VAR(definition);
array_init(definition);
if (phalcon_array_isset_string_fetch(&column_type, data, SS("_type"))) {
phalcon_array_update_string(&definition, SL("type"), column_type, PH_COPY);
}
if (phalcon_array_isset_string_fetch(¬_null, data, SS("_notNull"))) {
phalcon_array_update_string(&definition, SL("notNull"), not_null, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&primary, data, SS("_primary"))) {
phalcon_array_update_string(&definition, SL("primary"), primary, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&size, data, SS("_size"))) {
phalcon_array_update_string(&definition, SL("size"), size, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&scale, data, SS("_scale"))) {
phalcon_array_update_string(&definition, SL("scale"), scale, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&dunsigned, data, SS("_unsigned"))) {
phalcon_array_update_string(&definition, SL("unsigned"), dunsigned, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&after, data, SS("_after"))) {
phalcon_array_update_string(&definition, SL("after"), after, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&is_numeric, data, SS("_isNumeric"))) {
phalcon_array_update_string(&definition, SL("isNumeric"), is_numeric, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&first, data, SS("_first"))) {
phalcon_array_update_string(&definition, SL("first"), first, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&bind_type, data, SS("_bindType"))) {
phalcon_array_update_string(&definition, SL("bindType"), bind_type, PH_COPY);
}
if (phalcon_array_isset_string_fetch(&default_value, data, SS("_default"))) {
phalcon_array_update_string(&definition, SL("default"), default_value, PH_COPY);
}
object_init_ex(return_value, phalcon_db_column_ce);
PHALCON_CALL_METHOD(NULL, return_value, "__construct", column_name, definition);
RETURN_MM();
}
开发者ID:MyleftStudio,项目名称:cphalcon,代码行数:78,代码来源:column.c
示例15: PHP_METHOD
/**
* Inserts data into a table using custom RBDM SQL syntax
*
* <code>
* //Inserting a new robot
* $success = $connection->insert(
* "robots",
* array("Astro Boy", 1952),
* array("name", "year")
* );
*
* //Next SQL sentence is sent to the database system
* INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
* </code>
*
* @param string $table
* @param array $values
* @param array $fields
* @param array $dataTypes
* @return boolean
*/
PHP_METHOD(Phalcon_Db, insert){
zval *table = NULL, *values = NULL, *fields = NULL, *data_types = NULL, *number_values = NULL;
zval *exception_message = NULL, *exception = NULL, *placeholders = NULL;
zval *insert_values = NULL, *bind_data_types = NULL, *value = NULL;
zval *position = NULL, *str_value = NULL, *bind_type = NULL, *comma = NULL;
zval *joined_values = NULL, *joined_fields = NULL, *insert_sql = NULL;
zval *success = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
char *hash_index;
uint hash_index_len;
ulong hash_num;
int hash_type;
int eval_int;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|zz", &table, &values, &fields, &data_types) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!fields) {
PHALCON_ALLOC_ZVAL_MM(fields);
ZVAL_NULL(fields);
}
if (!data_types) {
PHALCON_ALLOC_ZVAL_MM(data_types);
ZVAL_NULL(data_types);
}
if (Z_TYPE_P(values) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The second parameter for insert isn't an Array");
return;
}
PHALCON_INIT_VAR(number_values);
phalcon_fast_count(number_values, values TSRMLS_CC);
if (phalcon_compare_strict_long(number_values, 0 TSRMLS_CC)) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Unable to insert into ", table, " without data");
PHALCON_INIT_VAR(exception);
object_init_ex(exception, phalcon_db_exception_ce);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(exception, "__construct", exception_message, PH_CHECK);
phalcon_throw_exception(exception TSRMLS_CC);
return;
}
PHALCON_INIT_VAR(placeholders);
array_init(placeholders);
PHALCON_INIT_VAR(insert_values);
array_init(insert_values);
if (Z_TYPE_P(data_types) == IS_ARRAY) {
PHALCON_INIT_VAR(bind_data_types);
array_init(bind_data_types);
} else {
PHALCON_CPY_WRT(bind_data_types, data_types);
}
if (!phalcon_valid_foreach(values TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(values);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
ph_cycle_start_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto ph_cycle_end_0;
}
PHALCON_INIT_VAR(position);
//.........这里部分代码省略.........
开发者ID:croustibat,项目名称:cphalcon,代码行数:101,代码来源:db.c
示例16: PHP_METHOD
/**
* Rollbacks the transaction
*
* @param string $rollbackMessage
* @param Phalcon\Mvc\Model $rollbackRecord
* @return boolean
*/
PHP_METHOD(Phalcon_Mvc_Model_Transaction, rollback){
zval *rollback_message = NULL, *rollback_record = NULL;
zval *manager = NULL, *connection = NULL, *success = NULL;
zval *a0 = NULL, *a1 = NULL;
zval *i0 = NULL;
zval *t0 = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zz", &rollback_message, &rollback_record) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!rollback_message) {
PHALCON_ALLOC_ZVAL_MM(rollback_message);
ZVAL_NULL(rollback_message);
} else {
PHALCON_SEPARATE_PARAM(rollback_message);
}
if (!rollback_record) {
PHALCON_ALLOC_ZVAL_MM(rollback_record);
ZVAL_NULL(rollback_record);
}
PHALCON_INIT_VAR(manager);
phalcon_read_property(&manager, this_ptr, SL("_manager"), PH_NOISY_CC);
if (zend_is_true(manager)) {
PHALCON_ALLOC_ZVAL_MM(a0);
array_init(a0);
phalcon_array_append(&a0, manager, PH_SEPARATE TSRMLS_CC);
add_next_index_stringl(a0, SL("notifyRollback"), 1);
PHALCON_ALLOC_ZVAL_MM(a1);
array_init(a1);
phalcon_array_append(&a1, this_ptr, PH_SEPARATE TSRMLS_CC);
PHALCON_CALL_FUNC_PARAMS_2_NORETURN("call_user_func_array", a0, a1);
}
PHALCON_INIT_VAR(connection);
phalcon_read_property(&connection, this_ptr
|
请发表评论