本文整理汇总了C++中PHALCON_CONCAT_SVS函数的典型用法代码示例。如果您正苦于以下问题:C++ PHALCON_CONCAT_SVS函数的具体用法?C++ PHALCON_CONCAT_SVS怎么用?C++ PHALCON_CONCAT_SVS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHALCON_CONCAT_SVS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Returns the label
*
* @param string $name
* @return string
*/
PHP_METHOD(Phalcon_Forms_Form, getLabel){
zval *name, *elements, *exception_message, *element;
zval *label;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) {
RETURN_MM_NULL();
}
PHALCON_OBS_VAR(elements);
phalcon_read_property(&elements, this_ptr, SL("_elements"), PH_NOISY_CC);
if (!phalcon_array_isset(elements, name)) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Element with ID=", name, " is not part of the form");
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_forms_exception_ce, exception_message);
return;
}
PHALCON_OBS_VAR(element);
phalcon_array_fetch(&element, elements, name, PH_NOISY_CC);
PHALCON_INIT_VAR(label);
PHALCON_CALL_METHOD(label, element, "getlabel");
RETURN_CCTOR(label);
}
示例2: PHP_METHOD
/**
* Generates a SQL describing a table
*
* <code>print_r($dialect->describeColumns("posts") ?></code>
*
* @param string $table
* @param string $schema
* @return string
*/
PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeColumns){
zval *table = NULL, *schema = NULL, *sql = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!schema) {
PHALCON_ALLOC_ZVAL_MM(schema);
ZVAL_NULL(schema);
}
if (zend_is_true(schema)) {
PHALCON_INIT_VAR(sql);
PHALCON_CONCAT_SVSVS(sql, "SELECT DISTINCT c.column_name AS Field, c.data_type AS Type, c.character_maximum_length AS Size, c.numeric_precision AS NumericSize, c.is_nullable AS Null, CASE WHEN pkc.column_name NOTNULL THEN 'PRI' ELSE '' END AS Key, CASE WHEN c.data_type LIKE '%int%' AND c.column_default LIKE '%nextval%' THEN 'auto_increment' ELSE '' END AS Extra, c.ordinal_position AS Position FROM information_schema.columns c LEFT JOIN ( SELECT kcu.column_name, kcu.table_name, kcu.table_schema FROM information_schema.table_constraints tc INNER JOIN information_schema.key_column_usage kcu on (kcu.constraint_name = tc.constraint_name and kcu.table_name=tc.table_name and kcu.table_schema=tc.table_schema) WHERE tc.constraint_type='PRIMARY KEY') pkc ON (c.column_name=pkc.column_name AND c.table_schema = pkc.table_schema AND c.table_name=pkc.table_name) WHERE c.table_schema='", schema, "' AND c.table_name='", table, "' ORDER BY c.ordinal_position");
} else {
PHALCON_INIT_VAR(sql);
PHALCON_CONCAT_SVS(sql, "SELECT DISTINCT c.column_name AS Field, c.data_type AS Type, c.character_maximum_length AS Size, c.numeric_precision AS NumericSize, c.is_nullable AS Null, CASE WHEN pkc.column_name NOTNULL THEN 'PRI' ELSE '' END AS Key, CASE WHEN c.data_type LIKE '%int%' AND c.column_default LIKE '%nextval%' THEN 'auto_increment' ELSE '' END AS Extra, c.ordinal_position AS Position FROM information_schema.columns c LEFT JOIN ( SELECT kcu.column_name, kcu.table_name, kcu.table_schema FROM information_schema.table_constraints tc INNER JOIN information_schema.key_column_usage kcu on (kcu.constraint_name = tc.constraint_name and kcu.table_name=tc.table_name and kcu.table_schema=tc.table_schema) WHERE tc.constraint_type='PRIMARY KEY') pkc ON (c.column_name=pkc.column_name AND c.table_schema = pkc.table_schema AND c.table_name=pkc.table_name) WHERE c.table_schema='public' AND c.table_name='", table, "' ORDER BY c.ordinal_position");
}
RETURN_CTOR(sql);
}
示例3: PHP_METHOD
/**
* Generates SQL checking for the existence of a schema.table
*
* @param string $tableName
* @param string $schemaName
* @return string
*/
PHP_METHOD(Phalcon_Db_Dialect_Mysql, tableExists){
zval *table_name = NULL, *schema_name = NULL, *flag = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table_name, &schema_name) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!schema_name) {
PHALCON_ALLOC_ZVAL_MM(schema_name);
ZVAL_NULL(schema_name);
}
if (zend_is_true(schema_name)) {
PHALCON_INIT_VAR(flag);
PHALCON_CONCAT_SVSVS(flag, "SELECT IF( COUNT(*) > 0 , 1 , 0 ) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME`= '", table_name, "' AND `TABLE_SCHEMA`='", schema_name, "'");
} else {
PHALCON_INIT_VAR(flag);
PHALCON_CONCAT_SVS(flag, "SELECT IF( COUNT(*) > 0 , 1 , 0 ) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME`='", table_name, "'");
}
RETURN_CTOR(flag);
}
示例4: PHP_METHOD
/**
* Returns a Phalcon\DI\Service instance
*
* @param string $name
* @return Phalcon\DI\ServiceInterface
*/
PHP_METHOD(Phalcon_DI, getService){
zval *name, *services, *service, *exception_message;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &name);
if (Z_TYPE_P(name) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STR(phalcon_di_exception_ce, "The service name must be a string");
return;
}
PHALCON_OBS_VAR(services);
phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC);
if (phalcon_array_isset(services, name)) {
PHALCON_OBS_VAR(service);
phalcon_array_fetch(&service, services, name, PH_NOISY_CC);
RETURN_CCTOR(service);
}
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Service '", name, "' wasn't found in the dependency injection container");
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_di_exception_ce, exception_message);
return;
}
示例5: PHP_METHOD
/**
* Generates SQL describing a table
*
*
*
* @param string $table
* @param string $schema
* @return string
*/
PHP_METHOD(Phalcon_Db_Dialect_Mysql, describeTable){
zval *table = NULL, *schema = NULL, *sql = NULL;
zval *r0 = NULL, *r1 = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!schema) {
PHALCON_INIT_VAR(schema);
ZVAL_NULL(schema);
}
if (zend_is_true(schema)) {
PHALCON_ALLOC_ZVAL_MM(r0);
PHALCON_CONCAT_SVSVS(r0, "DESCRIBE `", schema, "`.`", table, "`");
PHALCON_CPY_WRT(sql, r0);
} else {
PHALCON_ALLOC_ZVAL_MM(r1);
PHALCON_CONCAT_SVS(r1, "DESCRIBE `", table, "`");
PHALCON_CPY_WRT(sql, r1);
}
PHALCON_RETURN_CTOR(sql);
}
示例6: PHP_METHOD
PHP_METHOD(Phalcon_Mvc_Model_Manager, load){
zval *model_name = NULL, *model_exists = NULL, *exception_message = NULL;
zval *exception = NULL;
zval *i0 = NULL;
zend_class_entry *ce0;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &model_name) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_INIT_VAR(model_exists);
PHALCON_CALL_FUNC_PARAMS_1(model_exists, "class_exists", model_name);
if (zend_is_true(model_exists)) {
ce0 = phalcon_fetch_class(model_name TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(i0);
object_init_ex(i0, ce0);
PHALCON_CALL_METHOD_NORETURN(i0, "__construct", PH_CHECK);
RETURN_CTOR(i0);
}
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "The model '", model_name, "' could not be loaded");
PHALCON_INIT_VAR(exception);
object_init_ex(exception, phalcon_mvc_model_exception_ce);
PHALCON_CALL_METHOD_PARAMS_1_NORETURN(exception, "__construct", exception_message, PH_CHECK);
phalcon_throw_exception(exception TSRMLS_CC);
return;
}
示例7: PHP_METHOD
/**
* Escapes a column/table/schema name
*
* @param string $identifier
* @return string
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, escapeIdentifier){
zval *identifier, *domain, *name;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &identifier);
if (Z_TYPE_P(identifier) == IS_ARRAY) {
PHALCON_OBS_VAR(domain);
phalcon_array_fetch_long(&domain, identifier, 0, PH_NOISY);
PHALCON_OBS_VAR(name);
phalcon_array_fetch_long(&name, identifier, 1, PH_NOISY);
if (PHALCON_GLOBAL(db).escape_identifiers) {
PHALCON_CONCAT_SVSVS(return_value, "`", domain, "`.`", name, "`");
RETURN_MM();
}
PHALCON_CONCAT_VSV(return_value, domain, ".", name);
RETURN_MM();
}
if (PHALCON_GLOBAL(db).escape_identifiers) {
PHALCON_CONCAT_SVS(return_value, "`", identifier, "`");
RETURN_MM();
}
RETURN_CTOR(identifier);
}
示例8: PHP_METHOD
/**
* Escapes a column/table/schema name
*
* @param string $identifier
* @return string
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, escapeIdentifier){
zval *identifier, *domain, *name, *escaped = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &identifier) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (Z_TYPE_P(identifier) == IS_ARRAY) {
PHALCON_INIT_VAR(domain);
phalcon_array_fetch_long(&domain, identifier, 0, PH_NOISY_CC);
PHALCON_INIT_VAR(name);
phalcon_array_fetch_long(&name, identifier, 1, PH_NOISY_CC);
PHALCON_INIT_VAR(escaped);
PHALCON_CONCAT_SVSVS(escaped, "`", domain, "`.`", name, "`");
RETURN_CTOR(escaped);
}
PHALCON_INIT_NVAR(escaped);
PHALCON_CONCAT_SVS(escaped, "`", identifier, "`");
RETURN_CTOR(escaped);
}
示例9: PHP_METHOD
/**
* Returns the insert id for the auto_increment/serial column inserted in the lastest executed SQL statement
*
*<code>
* //Inserting a new robot
* $success = $connection->insert(
* "robots",
* array("Astro Boy", 1952),
* array("name", "year")
* );
*
* //Getting the generated id
* $id = $connection->lastInsertId();
*</code>
*
* @param string $sequenceName
* @return int
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, lastInsertId){
zval *sequence_name = NULL, *sql, *fetch_num, *ret, *insert_id;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 1, &sequence_name);
if (!sequence_name) {
PHALCON_INIT_VAR(sequence_name);
}
PHALCON_INIT_VAR(sql);
PHALCON_CONCAT_SVS(sql, "SELECT ", sequence_name, ".CURRVAL FROM dual");
PHALCON_INIT_VAR(fetch_num);
ZVAL_LONG(fetch_num, 3);
PHALCON_INIT_VAR(ret);
phalcon_call_method_p2(ret, this_ptr, "fetchall", sql, fetch_num);
PHALCON_OBS_VAR(insert_id);
phalcon_array_fetch_long(&insert_id, ret, 0, PH_NOISY);
RETURN_CCTOR(insert_id);
}
示例10: PHP_METHOD
/**
* Get the document type declaration of content
*
* @return string
*/
PHP_METHOD(Phalcon_Tag, getDocType){
zval *doctype = NULL, *declaration, *eol, *doctype_html;
PHALCON_MM_GROW();
PHALCON_OBSERVE_VAR(doctype);
phalcon_read_static_property(&doctype, SL("phalcon\\tag"), SL("_documentType") TSRMLS_CC);
PHALCON_INIT_VAR(eol);
ZVAL_STRING(eol, PHP_EOL, 1);
PHALCON_INIT_VAR(declaration);
if (phalcon_compare_strict_long(doctype, 1 TSRMLS_CC)) {
ZVAL_STRING(declaration, " PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\"", 1);
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 2 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD HTML 4.01//EN\"", eol, "\t\"http://www.w3.org/TR/html4/strict.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 3 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"", eol, "\t\"http://www.w3.org/TR/html4/loose.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 4 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"", eol, "\t\"http://www.w3.org/TR/html4/frameset.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 6 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"", eol, "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 7 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"", eol, "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 8 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"", eol, "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 9 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"", eol, "\t\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"");
goto ph_end_0;
}
if (phalcon_compare_strict_long(doctype, 10 TSRMLS_CC)) {
PHALCON_CONCAT_SVS(declaration, " PUBLIC \"-//W3C//DTD XHTML 2.0//EN\"", eol, "\t\"http://www.w3.org/MarkUp/DTD/xhtml2.dtd\"");
goto ph_end_0;
}
ph_end_0:
PHALCON_INIT_VAR(doctype_html);
PHALCON_CONCAT_SVSV(doctype_html, "<!DOCTYPE html", declaration, ">", eol);
RETURN_CTOR(doctype_html);
}
示例11: PHP_METHOD
/**
* Generates SQL checking for the existence of a schema.view
*
* @param string $viewName
* @param string $schemaName
* @return string
*/
PHP_METHOD(Phalcon_Db_Dialect_Sqlite, viewExists){
zval *view_name, *schema_name = NULL;
phalcon_fetch_params(0, 1, 1, &view_name, &schema_name);
PHALCON_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM sqlite_master WHERE type='view' AND tbl_name='", view_name, "'");
}
示例12: PHP_METHOD
/**
* This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
* Call it when you need to restore a database connection.
*
* Support set search_path after connectted if schema is specified in config.
*
* @param array $descriptor
* @return boolean
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, connect){
zval *descriptor = NULL, *schema = NULL, *sql, *password;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 1, &descriptor);
if (!descriptor) {
PHALCON_INIT_VAR(descriptor);
} else {
PHALCON_SEPARATE_PARAM(descriptor);
}
if (!zend_is_true(descriptor)) {
PHALCON_OBS_NVAR(descriptor);
phalcon_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY TSRMLS_CC);
}
if (phalcon_array_isset_string(descriptor, SS("schema"))) {
PHALCON_OBS_VAR(schema);
phalcon_array_fetch_string(&schema, descriptor, SL("schema"), PH_NOISY);
phalcon_array_unset_string(&descriptor, SS("schema"), PH_COPY);
phalcon_update_property_this(this_ptr, SL("_schema"), schema TSRMLS_CC);
}
else {
PHALCON_INIT_VAR(schema);
}
if (phalcon_array_isset_string_fetch(&password, descriptor, SS("password"))) {
/* There is a bug in pdo_pgsql driver when the password is empty,
* the driver tries to access invalid memory:
*
* if (dbh->password[0] != '\'' && dbh->password[strlen(dbh->password) - 1] != '\'')
*
* To avoid this we set the password to null
*/
if (Z_TYPE_P(password) == IS_STRING && Z_STRLEN_P(password) == 0) {
phalcon_array_update_string(&descriptor, SL("password"), PHALCON_GLOBAL(z_null), PH_COPY);
}
}
PHALCON_CALL_PARENT(NULL, phalcon_db_adapter_pdo_postgresql_ce, this_ptr, "connect", descriptor);
/**
* Execute the search path in the after connect
*/
if (Z_TYPE_P(schema) == IS_STRING) {
PHALCON_INIT_VAR(sql);
PHALCON_CONCAT_SVS(sql, "SET search_path TO '", schema, "'");
PHALCON_CALL_METHOD(NULL, this_ptr, "execute", sql);
}
PHALCON_MM_RESTORE();
}
示例13: PHP_METHOD
/**
* Gets external uri where app is executed
*
* @return string
*/
PHP_METHOD(Phalcon_Controller_Front, getBaseUri){
zval *uri = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL;
zval *g0 = NULL;
zval *c0 = NULL, *c1 = NULL, *c2 = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL;
int eval_int;
PHALCON_MM_GROW();
PHALCON_ALLOC_ZVAL_MM(t0);
phalcon_read_property(&t0, this_ptr, "_baseUri", sizeof("_baseUri")-1, PHALCON_NOISY TSRMLS_CC);
if (!zend_is_true(t0)) {
phalcon_get_global(&g0, "_SERVER", sizeof("_SERVER") TSRMLS_CC);
eval_int = phalcon_array_isset_string(g0, "PHP_SELF", strlen("PHP_SELF")+1);
if (eval_int) {
PHALCON_INIT_VAR(c0);
ZVAL_STRING(c0, "/", 1);
PHALCON_ALLOC_ZVAL_MM(r0);
PHALCON_INIT_VAR(c1);
ZVAL_STRING(c1, "/", 1);
PHALCON_ALLOC_ZVAL_MM(r1);
PHALCON_ALLOC_ZVAL_MM(r2);
phalcon_array_fetch_string(&r2, g0, "PHP_SELF", strlen("PHP_SELF"), PHALCON_NOISY TSRMLS_CC);
PHALCON_CALL_FUNC_PARAMS_1(r1, "dirname", r2, 0x049);
PHALCON_ALLOC_ZVAL_MM(r3);
phalcon_fast_explode(r3, c1, r1 TSRMLS_CC);
PHALCON_INIT_VAR(c2);
ZVAL_LONG(c2, 1);
PHALCON_INIT_VAR(t2);
ZVAL_LONG(t2, 1);
PHALCON_INIT_VAR(t1);
ZVAL_LONG(t1, -1);
PHALCON_ALLOC_ZVAL_MM(r4);
mul_function(r4, t1, t2 TSRMLS_CC);
PHALCON_CALL_FUNC_PARAMS_3(r0, "array_slice", r3, c2, r4, 0x01F);
PHALCON_ALLOC_ZVAL_MM(r5);
phalcon_fast_join(r5, c0, r0 TSRMLS_CC);
PHALCON_CPY_WRT(uri, r5);
} else {
PHALCON_INIT_VAR(uri);
ZVAL_STRING(uri, "", 1);
}
if (!zend_is_true(uri)) {
phalcon_update_property_string(this_ptr, "_baseUri", strlen("_baseUri"), "/" TSRMLS_CC);
} else {
PHALCON_ALLOC_ZVAL_MM(r6);
PHALCON_CONCAT_SVS(r6, "/", uri, "/");
phalcon_update_property_zval(this_ptr, "_baseUri", strlen("_baseUri"), r6 TSRMLS_CC);
}
}
PHALCON_ALLOC_ZVAL_MM(t3);
phalcon_read_property(&t3, this_ptr, "_baseUri", sizeof("_baseUri")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_RETURN_CHECK_CTOR(t3);
}
示例14: PHP_METHOD
/**
* Adds access to resources
*
* @param string $resourceName
* @param mixed $accessList
*/
PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess){
zval *resource_name, *access_list, *resources_names;
zval *exception_message, *exists, *internal_access_list;
zval *access_name = NULL, *access_key = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &resource_name, &access_list);
PHALCON_OBS_VAR(resources_names);
phalcon_read_property_this(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC);
if (!phalcon_array_isset(resources_names, resource_name)) {
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Resource '", resource_name, "' does not exist in ACL");
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message);
return;
}
PHALCON_INIT_VAR(exists);
ZVAL_BOOL(exists, 1);
PHALCON_OBS_VAR(internal_access_list);
phalcon_read_property_this(&internal_access_list, this_ptr, SL("_accessList"), PH_NOISY_CC);
if (Z_TYPE_P(access_list) == IS_ARRAY) {
phalcon_is_iterable(access_list, &ah0, &hp0, 0, 0);
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_HVALUE(access_name);
PHALCON_INIT_NVAR(access_key);
PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_name);
if (!phalcon_array_isset(internal_access_list, access_key)) {
phalcon_update_property_array(this_ptr, SL("_accessList"), access_key, exists TSRMLS_CC);
}
zend_hash_move_forward_ex(ah0, &hp0);
}
} else {
if (Z_TYPE_P(access_list) == IS_STRING) {
PHALCON_INIT_NVAR(access_key);
PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_list);
if (!phalcon_array_isset(internal_access_list, access_key)) {
phalcon_update_property_array(this_ptr, SL("_accessList"), access_key, exists TSRMLS_CC);
}
}
}
RETURN_MM_TRUE;
}
示例15: PHP_METHOD
/**
* Executes the validator
*
* @param Phalcon\Mvc\ModelInterface $record
* @return boolean
*/
PHP_METHOD(Phalcon_Mvc_Model_Validator_Numericality, validate){
zval *record, *option = NULL, *field, *value, *is_numeric;
zval *message = NULL, *type;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &record) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_INIT_VAR(option);
ZVAL_STRING(option, "field", 1);
PHALCON_INIT_VAR(field);
PHALCON_CALL_METHOD_PARAMS_1(field, this_ptr, "getoption", option, PH_NO_CHECK);
if (Z_TYPE_P(field) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Field name must be a string");
return;
}
PHALCON_INIT_VAR(value);
PHALCON_CALL_METHOD_PARAMS_1(value, record, "readattribute", field, PH_NO_CHECK);
/**
* Check if the value is numeric using is_numeric in the PHP userland
*/
PHALCON_INIT_VAR(is_numeric);
PHALCON_CALL_FUNC_PARAMS_1(is_numeric, "is_numeric", value);
if (!zend_is_true(is_numeric)) {
/**
* Check if the developer has defined a custom message
*/
PHALCON_INIT_NVAR(option);
ZVAL_STRING(option, "message", 1);
PHALCON_INIT_VAR(message);
PHALCON_CALL_METHOD_PARAMS_1(message, this_ptr, "getoption", option, PH_NO_CHECK);
if (!zend_is_true(message)) {
PHALCON_INIT_NVAR(message);
PHALCON_CONCAT_SVS(message, "Value of field '", field, "' must be numeric");
}
PHALCON_INIT_VAR(type);
ZVAL_STRING(type, "Numericality", 1);
PHALCON_CALL_METHOD_PARAMS_3_NORETURN(this_ptr, "appendmessage", message, field, type, PH_NO_CHECK);
PHALCON_MM_RESTORE();
RETURN_FALSE;
}
PHALCON_MM_RESTORE();
RETURN_TRUE;
}