|
@@ -495,66 +495,7 @@ class Entity {
|
|
|
return $instance->customQuery($sql, $values, true, $joins);
|
|
|
}
|
|
|
|
|
|
- public static function get($options=array()) {
|
|
|
- $class = get_called_class();
|
|
|
- $instance = new $class();
|
|
|
- $connector = $instance->connector;
|
|
|
-
|
|
|
- $values = array();
|
|
|
- $i=0;
|
|
|
- $filters = array();
|
|
|
-
|
|
|
-
|
|
|
- if(!empty($options['where'])){
|
|
|
- foreach($options['where'] as $key=>$value){
|
|
|
- $filter = array(
|
|
|
- 'operator' => '=',
|
|
|
- 'field' => $key,
|
|
|
- 'postoperator' => ''
|
|
|
- );
|
|
|
- if(strpos($key,':')!==false){
|
|
|
- $infos = explode(':',$key);
|
|
|
- $filter['operator'] = $infos[1];
|
|
|
- $filter['field'] = $infos[0];
|
|
|
- }
|
|
|
|
|
|
- $fieldInfos = $instance->fieldMapping[$filter['field']];
|
|
|
- $filter['type'] = $fieldInfos['type'];
|
|
|
- $filter['column'] = $fieldInfos['column'];
|
|
|
-
|
|
|
- $connector::processField($filter,$value,$values,$i);
|
|
|
- $filters[] = $filter;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!empty($order)){
|
|
|
- foreach ($order as $key=>$clause) {
|
|
|
- foreach ($instance->fieldMapping as $attribute => $infos) {
|
|
|
- $order[$key] = str_replace( $attribute,$infos['column'],$order[$key]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $tableName = $class::tableName(false,$instance);
|
|
|
- $data = array(
|
|
|
- 'table' => $tableName,
|
|
|
- 'selected' => $selColumn,
|
|
|
- 'limit' => !isset($limit) || count($limit) == 0 ? null: $limit,
|
|
|
- 'orderby' => !isset($order) || count($order) == 0 ? null: $order,
|
|
|
- 'filter' => !isset($filters) || count($filters) == 0 ? null: $filters,
|
|
|
- 'fieldMapping' => $instance->fieldMapping
|
|
|
- );
|
|
|
- $data['joins'] = array();
|
|
|
- if($joins!=0){
|
|
|
- foreach ($data['selected'] as $k=>$column)
|
|
|
- $data['selected'][$k] = $tableName.'.'.$column;
|
|
|
-
|
|
|
- $data = self::recursiveJoining($instance,$data,$joins);
|
|
|
- }
|
|
|
- $sql = $connector::select();
|
|
|
- $sql = Entity::render($sql,$data);
|
|
|
-
|
|
|
- return $instance->customQuery($sql, $values, true, $joins,$alterator);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* Méthode privée de gestion du join récursif sur les objets liés
|