Changeset 214 for trunk/trax/vendor
- Timestamp:
- 05/31/06 21:33:29 (6 years ago)
- Location:
- trunk/trax/vendor/trax
- Files:
-
- 2 modified
-
action_view/helpers/active_record_helper.php (modified) (2 diffs)
-
active_record.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/action_view/helpers/active_record_helper.php
r213 r214 619 619 } 620 620 621 function pagination_range_text($object_name_or_object, $ showing_text = "Showing", $showing_type = "items") {621 function pagination_range_text($object_name_or_object, $range_text = "Showing", $range_type = "items") { 622 622 if(is_object($object_name_or_object)) { 623 623 $object = $object_name_or_object; … … 635 635 } 636 636 637 return "{$ showing_text} {$start} - {$end} of {$object->pagination_count} {$showing_type}.";637 return "{$range_text} {$start} - {$end} of {$object->pagination_count} {$range_type}."; 638 638 } 639 639 -
trunk/trax/vendor/trax/active_record.php
r213 r214 564 564 565 565 if(@array_key_exists("order", $parameters)) 566 $order ings= $parameters['order'];566 $order = $parameters['order']; 567 567 elseif($parameters[1] != "") 568 $order ings= $parameters[1];568 $order = $parameters[1]; 569 569 570 570 if(@array_key_exists("limit", $parameters)) … … 606 606 # Set up the SQL segments 607 607 $conditions = "{$join_table}.{$this_foreign_key}=".intval($this->id); 608 $order ings= null;608 $order = null; 609 609 $limit = null; 610 610 $joins .= "LEFT JOIN {$join_table} ON {$other_table_name}.id = {$other_foreign_key}"; 611 611 612 612 # Get the list of other_class_name objects 613 return $object->find_all($conditions, $order ings, $limit, $joins);613 return $object->find_all($conditions, $order, $limit, $joins); 614 614 } 615 615 … … 633 633 634 634 if(@array_key_exists("order", $parameters)) 635 $order ings= $parameters['order'];635 $order = $parameters['order']; 636 636 elseif($parameters[1] != "") 637 $order ings= $parameters[1];637 $order = $parameters[1]; 638 638 639 639 if(@array_key_exists("limit", $parameters)) … … 684 684 685 685 # Get the list of other_class_name objects 686 return $other_class_object->find_all($conditions, $order ings, $limit, $joins);686 return $other_class_object->find_all($conditions, $order, $limit, $joins); 687 687 } 688 688 … … 723 723 724 724 # Get the list of other_class_name objects 725 $result = $other_class_object->find_first($conditions, $order ings);725 $result = $other_class_object->find_first($conditions, $order); 726 726 # There should only be one result, an object, if so return it 727 727 if(is_object($result)) { … … 769 769 770 770 # Get the list of other_class_name objects 771 $result = $other_class_object->find_first($conditions, $order ings);771 $result = $other_class_object->find_first($conditions, $order); 772 772 # There should only be one result, an object, if so return it 773 773 if(is_object($result)) { … … 998 998 $method_params .= implode("_",$field)."='".$parameters[$param_cnt++]."'"; 999 999 if($parameters[$param_cnt]) { 1000 $order ings= $parameters[$param_cnt];1000 $order = $parameters[$param_cnt]; 1001 1001 } 1002 1002 } … … 1006 1006 1007 1007 if($find_all) { 1008 return $this->find_all($method_params, $order ings);1008 return $this->find_all($method_params, $order); 1009 1009 } else { 1010 return $this->find_first($method_params, $order ings);1010 return $this->find_first($method_params, $order); 1011 1011 } 1012 1012 } … … 1018 1018 * If no rows match, an empty array is returned. 1019 1019 * @param string SQL to use in the query. If 1020 * $conditions contains "SELECT", then $order ings, $limit and1020 * $conditions contains "SELECT", then $order, $limit and 1021 1021 * $joins are ignored and the query is completely specified by 1022 1022 * $conditions. If $conditions is omitted or does not contain … … 1027 1027 * @param string Argument to "ORDER BY" in query. 1028 1028 * If specified, the query will include 1029 * "ORDER BY $order ings". If omitted, no ordering will be1029 * "ORDER BY $order". If omitted, no ordering will be 1030 1030 * applied. 1031 1031 * @param integer[] Page, rows per page??? … … 1045 1045 * @throws {@link ActiveRecordError} 1046 1046 */ 1047 function find_all($conditions = null, $order ings= null,1047 function find_all($conditions = null, $order = null, 1048 1048 $limit = null, $joins = null) { 1049 1049 //error_log("find_all(".(is_null($conditions)?'null':$conditions) 1050 // .', ' . (is_null($order ings)?'null':$orderings)1050 // .', ' . (is_null($order)?'null':$order) 1051 1051 // .', ' . (is_null($limit)?'null':var_export($limit,true)) 1052 1052 // .', ' . (is_null($joins)?'null':$joins).')'); … … 1063 1063 # named parameters. 1064 1064 if(is_array($conditions)) { 1065 extract($conditions); 1065 if(@array_key_exists("per_page", $conditions) && !is_numeric($conditions['per_page'])) { 1066 extract($conditions); 1067 $per_page = 0; 1068 } else { 1069 extract($conditions); 1070 } 1071 # If conditions wasn't in the array set it to null 1066 1072 if(is_array($conditions)) { 1067 1073 $conditions = null; … … 1081 1087 1082 1088 # If ordering specified, include it 1083 if(!is_null($orderings)) { 1084 $sql .= "ORDER BY $orderings "; 1085 } 1086 1087 # If limit specified, divide into pages 1088 if(!is_null($limit) || !is_null($offset) || !is_null($per_page)) { 1089 1090 # Is output to be generated in pages? 1091 if(is_array($limit)) { 1092 # Yes, get next page number and rows per page from argument 1093 list($this->page, $this->rows_per_page) = $limit; 1094 } else { 1089 if(!is_null($order)) { 1090 $sql .= "ORDER BY $order "; 1091 } 1092 1093 # Is output to be generated in pages? 1094 if(is_numeric($limit) || is_numeric($offset) || is_numeric($per_page)) { 1095 1096 if(is_numeric($limit)) { 1095 1097 $this->rows_per_page = $limit; 1096 1098 } 1097 if( !is_null($per_page)) {1099 if(is_numeric($per_page)) { 1098 1100 $this->rows_per_page = $per_page; 1099 1101 } … … 1116 1118 # $sql .= "LIMIT $offset, $this->rows_per_page"; 1117 1119 1118 # Send query to database 1119 # Set number of total pages in result set 1120 # without the LIMIT 1120 # Set number of total pages in result set 1121 1121 if($count = $this->count_all("*", $conditions, $joins)) { 1122 1122 $this->pagination_count = $count; … … 1129 1129 } 1130 1130 1131 #echo "ActiveRecord::find_all() - sql: $sql\n<br>";1131 echo "ActiveRecord::find_all() - sql: $sql\n<br>"; 1132 1132 # echo "query: $sql\n"; 1133 1133 if($this->is_error($rs = $this->query($sql))) { … … 1169 1169 * select based on some column other than "id", you must pass a 1170 1170 * string argument ready to insert in the SQL SELECT. 1171 * @param string $order ingsArgument to "ORDER BY" in query.1171 * @param string $order Argument to "ORDER BY" in query. 1172 1172 * If specified, the query will include "ORDER BY 1173 * $order ings". If omitted, no ordering will be applied.1173 * $order". If omitted, no ordering will be applied. 1174 1174 * @param integer[] $limit Page, rows per page??? 1175 1175 * @param string $joins ??? … … 1188 1188 * @throws {@link ActiveRecordError} 1189 1189 */ 1190 function find($id, $order ings= null, $limit = null, $joins = null) {1190 function find($id, $order = null, $limit = null, $joins = null) { 1191 1191 if(is_array($id)) { 1192 1192 $conditions = "id IN(".implode(",",$id).")"; … … 1198 1198 1199 1199 if(is_array($id)) { 1200 return $this->find_all($conditions, $order ings, $limit, $joins);1201 } else { 1202 return $this->find_first($conditions, $order ings, $limit, $joins);1200 return $this->find_all($conditions, $order, $limit, $joins); 1201 } else { 1202 return $this->find_first($conditions, $order, $limit, $joins); 1203 1203 } 1204 1204 } … … 1209 1209 * If no rows match, null is returned. 1210 1210 * @param string $conditions SQL to use in the query. If 1211 * $conditions contains "SELECT", then $order ings, $limit and1211 * $conditions contains "SELECT", then $order, $limit and 1212 1212 * $joins are ignored and the query is completely specified by 1213 1213 * $conditions. If $conditions is omitted or does not contain … … 1216 1216 * include "WHERE $conditions". If $conditions is null, the 1217 1217 * entire table is returned. 1218 * @param string $order ingsArgument to "ORDER BY" in query.1218 * @param string $order Argument to "ORDER BY" in query. 1219 1219 * If specified, the query will include 1220 * "ORDER BY $order ings". If omitted, no ordering will be1220 * "ORDER BY $order". If omitted, no ordering will be 1221 1221 * applied. 1222 1222 * FIXME This parameter doesn't seem to make sense … … 1229 1229 * @throws {@link ActiveRecordError} 1230 1230 */ 1231 function find_first($conditions, $order ings= null, $limit = null, $joins = null) {1232 $result = $this->find_all($conditions, $order ings, $limit, $joins);1231 function find_first($conditions, $order = null, $limit = null, $joins = null) { 1232 $result = $this->find_all($conditions, $order, $limit, $joins); 1233 1233 return @current($result); 1234 1234 }
