Changeset 887078
- Timestamp:
- 04/03/2014 10:00:01 PM (11 years ago)
- Location:
- wp-fjqgrid/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-fjqgrid/trunk/inc/wpf-jqgrid-dbmodel.php
r878671 r887078 1 1 <?php 2 2 if ( !class_exists( 'FjqGridDbModel' ) ) { 3 define( 'NOT_NULL_FLAG', '1' ); /* Field can't be NULL */ 4 define( 'PRI_KEY_FLAG', '2' ); /* Field is part of a primary key */ 5 define( 'UNIQUE_KEY_FLAG', '4' ); /* Field is part of a unique key */ 6 define( 'MULTIPLE_KEY_FLAG', '8' ); /* Field is part of a key */ 7 define( 'BLOB_FLAG', '16' ); /* Field is a blob */ 8 define( 'UNSIGNED_FLAG', '32' ); /* Field is unsigned */ 9 define( 'ZEROFILL_FLAG', '64' ); /* Field is zerofill */ 10 define( 'BINARY_FLAG', '128' ); /* Field is binary */ 11 define( 'ENUM_FLAG', '256' ); /* Field is an enum */ 12 define( 'AUTO_INCREMENT_FLAG', '512' ); /* Field is a autoincrement field */ 13 define( 'TIMESTAMP_FLAG', '1024' ); /* Field is a timestamp */ 3 14 4 15 class FjqGridDbModel … … 35 46 } 36 47 48 $mysqli = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ); 49 if ( $mysqli->connect_errno ) { 50 printf( "Connect failed: %s\n", $mysqli->connect_error ); 51 exit(); 52 } 37 53 $query_cmd = "SELECT * FROM `{$this->tablename}` LIMIT 1 OFFSET 0"; 38 $fetch_recordset = mysql_query( $query_cmd ); 39 if ( $fetch_recordset == null ) { 54 $result = $mysqli->query( $query_cmd ); 55 $fields_cnt = $mysqli->field_count; 56 if ( $fields_cnt == 0 ) { 40 57 $wpfjqg->fplugin_log( "Query non valida", mysql_error(), 1 ); 41 58 return; 42 59 } 43 $fields_cnt = mysql_num_fields( $fetch_recordset );44 60 for ( $cnt = 0; $cnt < $fields_cnt; $cnt++ ) { 45 $name = mysql_field_name( $fetch_recordset, $cnt ); 46 $type = mysql_field_type( $fetch_recordset, $cnt ); 47 $size = mysql_field_len( $fetch_recordset, $cnt ); 48 $flag = mysql_field_flags( $fetch_recordset, $cnt ); 61 $finfo = $result->fetch_field_direct( $cnt ); 62 $name = $finfo->name; 63 $type = $finfo->type; 64 $size = $finfo->max_length; 65 $flag = $finfo->flags; 49 66 $column["name"] = $name; 50 67 $column["type"] = $type; … … 55 72 $column["searchoptions"] = "{sopt:['bw','cn','eq','ne','ew','nu','nn']}"; 56 73 $column["editable"] = "true"; 57 $reqrd = ( strpos( $flag, 'not_null' ) !== false) ? 'required: true,' : '';74 $reqrd = ( ( $flag & NOT_NULL_FLAG ) == NOT_NULL_FLAG ) ? 'required: true,' : ''; 58 75 if ( !isset( $frm[$name] ) ) { 59 76 $column["formatter"] = $this->fjqg_format( $type, $size, $reqrd ); … … 63 80 $columns[] = $column; 64 81 } 82 /* free result set */ 83 $result->close(); 65 84 $this->columns = $columns; 66 85 if ( $printinfo ) { … … 78 97 $keyfield = $this->fieldsnames[0]; 79 98 // search for primary_key 80 //$wpfjqg->fplugin_log('flags',$this->fieldsflags);81 99 $keyword = 'primary_key'; 82 100 $i = 0; 83 101 foreach ( $this->fieldsflags as $key => $flg ) { 84 if ( preg_match( "/{$keyword}/i", $flg )) {102 if ( ( $flg & PRI_KEY_FLAG ) == PRI_KEY_FLAG ) { 85 103 $keyfield = $this->fieldsnames[$key]; 86 104 $i++; … … 148 166 ENUM 149 167 SET 168 * 169 1=>'tinyint', 170 2=>'smallint', 171 3=>'int', 172 4=>'float', 173 5=>'double', 174 7=>'timestamp', 175 8=>'bigint', 176 9=>'mediumint', 177 10=>'date', 178 11=>'time', 179 12=>'datetime', 180 13=>'year', 181 16=>'bit', 182 //252 is currently mapped to all text and blob types (MySQL 5.0.51a) 183 253=>'varchar', 184 254=>'char', 185 246=>'decimal' 150 186 */ 151 switch ( strtoupper( $type ) ) { 152 case 'TINYINT': 153 case 'SMALLINT': 154 case 'MEDIUMINT': 155 case 'INT': 156 case 'INTEGER': 157 case 'BIGINT': 187 switch ( $type ) { 188 case 1: 189 case 2: 190 case 3: 191 case 8: 192 case 9: 158 193 if ( $lung == 1 ) { 159 194 $frm = "align:'center', formatter: 'checkbox', formatoptions: { disabled: true}, editoptions: { value: '1:0' }"; … … 164 199 } 165 200 break; 166 case 'FLOAT': 167 case 'DOUBLE': 168 case 'DOUBLE PRECISION': 169 case 'REAL': 170 case 'DECIMAL': 171 case 'NUMERIC': 201 case 16: 202 $frm = "align:'center', formatter: 'checkbox', formatoptions: { disabled: true}, editoptions: { value: '1:0' }"; 203 $frm .= ", edittype: 'checkbox', editrules: {required: false}, searchoptions: { sopt: ['eq','ne','nu','nn']}, searchrules:{integer:true, minValue:0, maxValue:1}"; 204 break; 205 case 4: 206 case 5: 207 case 246: 172 208 $frm = "align:'right', formatter:'number', formatoptions: {decimalSeparator:',', thousandsSeparator: '.', decimalPlaces: 2, defaulValue: 0}"; 173 209 $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}"; 174 210 break; 175 case 'DATE':211 case 10: 176 212 $frm = "align:'right', formatter:'date', formatoptions: {srcformat:'Y-m-d',newformat:'d/m/Y'}"; 177 213 $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}"; 178 214 break; 179 case 'DATETIME':215 case 12: 180 216 $frm = "align:'right', formatter:'date', formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'d/m/Y H:i'}"; 181 217 $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}"; 182 218 break; 183 case 'TIME':219 case 11: 184 220 $frm = "align:'right', formatter:'date', formatoptions: {srcformat:'H:i:s',newformat:'H:i:s'}"; 185 221 $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}"; 186 222 break; 187 case 'CHAR': 188 case 'VARCHAR': 189 case 'STRING': 223 case 253: 224 case 254: 190 225 $frm = "align:'left'"; 191 226 $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}"; -
wp-fjqgrid/trunk/index.php
r878671 r887078 4 4 Plugin URI: http://wordpress.org/extend/plugins/wpf-jqgrid/ 5 5 Description: jqGrid porting to wordpress 6 Version: 0.1 06 Version: 0.11 7 7 Author: faina09 8 8 Author URI: http://profiles.wordpress.org/faina09 9 9 License: GPLv2 or later 10 10 */ 11 $VER = '0.1 0';11 $VER = '0.11'; 12 12 defined( 'ABSPATH' ) OR exit; 13 13 -
wp-fjqgrid/trunk/readme.txt
r878671 r887078 4 4 Donate link: http://goo.gl/QzIZZ 5 5 Requires at least: 3.5 6 Tested up to: 3. 86 Tested up to: 3.9 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 74 74 75 75 == Changelog == 76 = 0.11 = 77 * deprecated mysql_ calls removed, use mysqli 78 * wp 3.9 compatible 79 76 80 = 0.10 = 77 81 * sortby=field,asc|desc into shortcode
Note: See TracChangeset
for help on using the changeset viewer.