FieldTable.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: FieldTable.c 4687 2007-12-09 18:57:18Z voxus $ */
00011 
00012 #include "onphp.h"
00013 #include "onphp_core.h"
00014 
00015 #include "zend_globals.h"
00016 #include "zend_interfaces.h"
00017 
00018 #include "core/DB/Dialect.h"
00019 #include "core/OSQL/FieldTable.h"
00020 
00021 ONPHP_METHOD(FieldTable, __construct)
00022 {
00023     zval *field;
00024 
00025     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &field) == FAILURE) {
00026         WRONG_PARAM_COUNT;
00027     }
00028 
00029     ONPHP_UPDATE_PROPERTY(getThis(), "field", field);
00030 }
00031 
00032 ONPHP_METHOD(FieldTable, getField)
00033 {
00034     zval *field = ONPHP_READ_PROPERTY(getThis(), "field");
00035 
00036     RETURN_ZVAL(field, 1, 0);
00037 }
00038 
00039 ONPHP_METHOD(FieldTable, toDialectString)
00040 {
00041     zval *dialect, *cast, *field, *out;
00042     
00043     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &dialect) == FAILURE) {
00044         WRONG_PARAM_COUNT;
00045     }
00046     
00047     field = ONPHP_READ_PROPERTY(getThis(), "field");
00048     
00049     zend_call_method_with_1_params(
00050         &dialect,
00051         Z_OBJCE_P(dialect),
00052         NULL,
00053         "fieldtostring",
00054         &out,
00055         field
00056     );
00057     
00058     if (EG(exception)) {
00059         return;
00060     }
00061     
00062     cast = ONPHP_READ_PROPERTY(getThis(), "cast");
00063     
00064     if (Z_STRLEN_P(cast)) {
00065         zend_call_method_with_2_params(
00066             &dialect,
00067             Z_OBJCE_P(dialect),
00068             NULL,
00069             "tocasted",
00070             &out,
00071             out,
00072             cast
00073         );
00074         
00075         if (EG(exception)) {
00076             return;
00077         }
00078     } else {
00079         // nothing
00080     }
00081     
00082     RETURN_ZVAL(out, 1, 1);
00083 }
00084 
00085 static ONPHP_ARGINFO_ONE;
00086 static ONPHP_ARGINFO_DIALECT;
00087 
00088 zend_function_entry onphp_funcs_FieldTable[] = {
00089     ONPHP_ME(FieldTable, __construct, arginfo_one, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
00090     ONPHP_ME(FieldTable, getField, NULL, ZEND_ACC_PUBLIC)
00091     ONPHP_ME(FieldTable, toDialectString, arginfo_dialect, ZEND_ACC_PUBLIC)
00092     {NULL, NULL, NULL}
00093 };

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