DBValue.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU Lesser General Public License as        *
00006  *   published by the Free Software Foundation; either version 3 of the    *
00007  *   License, or (at your option) any later version.                       *
00008  *                                                                         *
00009  ***************************************************************************/
00010 /* $Id: DBValue.c 4687 2007-12-09 18:57:18Z voxus $ */
00011 
00012 #include "onphp_core.h"
00013 
00014 #include "zend_interfaces.h"
00015 #include "zend_globals.h"
00016 
00017 #include "core/DB/Dialect.h"
00018 #include "core/OSQL/DBValue.h"
00019 
00020 ONPHP_METHOD(DBValue, create)
00021 {
00022     zval *object, *value;
00023 
00024     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
00025         WRONG_PARAM_COUNT;
00026     }
00027 
00028     MAKE_STD_ZVAL(object);
00029 
00030     object->value.obj = onphp_empty_object_new(onphp_ce_DBValue TSRMLS_CC);
00031     Z_TYPE_P(object) = IS_OBJECT;
00032     
00033     ONPHP_UPDATE_PROPERTY(object, "value", value);
00034 
00035     RETURN_ZVAL(object, 1, 1);
00036 }
00037 
00038 ONPHP_METHOD(DBValue, __construct)
00039 {
00040     zval *value;
00041 
00042     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
00043         WRONG_PARAM_COUNT;
00044     }
00045 
00046     ONPHP_UPDATE_PROPERTY(getThis(), "value", value);
00047 }
00048 
00049 ONPHP_METHOD(DBValue, getValue)
00050 {
00051     zval *value = ONPHP_READ_PROPERTY(getThis(), "value");
00052 
00053     RETURN_ZVAL(value, 1, 0);
00054 }
00055 
00056 ONPHP_METHOD(DBValue, toDialectString)
00057 {
00058     zval *dialect, *cast, *value, *out;
00059     
00060     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &dialect) == FAILURE) {
00061         WRONG_PARAM_COUNT;
00062     }
00063     
00064     value = ONPHP_READ_PROPERTY(getThis(), "value");
00065     
00066     zend_call_method_with_1_params(
00067         &dialect,
00068         Z_OBJCE_P(dialect),
00069         NULL,
00070         "quotevalue",
00071         &out,
00072         value
00073     );
00074     
00075     if (EG(exception)) {
00076         return;
00077     }
00078     
00079     cast = ONPHP_READ_PROPERTY(getThis(), "cast");
00080     
00081     if (Z_STRLEN_P(cast)) {
00082         zval *casted;
00083         
00084         zend_call_method_with_2_params(
00085             &dialect,
00086             Z_OBJCE_P(dialect),
00087             NULL,
00088             "tocasted",
00089             &casted,
00090             out,
00091             cast
00092         );
00093         
00094         ZVAL_FREE(out);
00095         
00096         if (EG(exception)) {
00097             return;
00098         }
00099         
00100         RETURN_ZVAL(casted, 1, 1);
00101     } else {
00102         // nothing
00103     }
00104     
00105     RETURN_ZVAL(out, 1, 1);
00106 }
00107 
00108 static ONPHP_ARGINFO_ONE;
00109 static ONPHP_ARGINFO_DIALECT;
00110 
00111 zend_function_entry onphp_funcs_DBValue[] = {
00112     ONPHP_ME(DBValue, create, arginfo_one, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
00113     ONPHP_ME(DBValue, __construct, arginfo_one, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
00114     ONPHP_ME(DBValue, getValue, NULL, ZEND_ACC_PUBLIC)
00115     ONPHP_ME(DBValue, toDialectString, arginfo_dialect, ZEND_ACC_PUBLIC)
00116     {NULL, NULL, NULL}
00117 };

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4