我有一个非常小的脚本来从数据库表中获取所有记录,代码在
下面$query = $this->db->get($this->table_name);
return $query->result();
使用这种语法,我将如何命名'name'?
每次我坚持按顺序排列时,我都会收到错误。
干杯,
答案 0 :(得分:119)
我相信get()函数会立即运行选择查询,并且不接受ORDER BY条件作为参数。我想你需要单独声明条件,然后运行查询。试一试。
$this->db->from($this->table_name);
$this->db->order_by("name", "asc");
$query = $this->db->get();
return $query->result();
答案 1 :(得分:12)
在单个查询中将此代码用于多个订单。
$this->db->from($this->table_name);
$this->db->order_by("column1 asc,column2 desc");
$query = $this->db->get();
return $query->result();
答案 2 :(得分:2)
简单易行:
$this->db->order_by("name", "asc");
$query = $this->db->get($this->table_name);
return $query->result();
答案 3 :(得分:1)
只需在代码中添加“order_by”子句并将其修改为如下所示。
$this->db->order_by('name', 'asc');
$this->db->where('table_name');
你去。
答案 4 :(得分:1)
两个表联接和按名称排序- 100%有效。
$this->db->from('user_login');
$this->db->join('role','user_login.Roleid=role.Roleid');
return $this->db->order_by('Uname ASC')->get('')->result();
答案 5 :(得分:0)
试试这个:
$this->db->select('main.*');
$this->db->from("ci_table main");
$this->db->order_by("main.id", "DESC");
return $this->db->get()->result();
答案 6 :(得分:0)
100%正常工作!!!!
cnt=0
for i in range(len(dframe)):
if (pd.isnull(dframe['Description'][i])):
cnt+=1
答案 7 :(得分:0)
$query = $this->db->from("table_name")->order_by("table_name.column_name desc")->get();
return $query->result();
答案 8 :(得分:0)
您也可以这样安排。
return $this->db->order_by('name', 'DESC')->get($this -> table_name)->result();
答案 9 :(得分:0)
简单方法:
status Status not available at the moment
transaction hash 0x1e484dfa3afbbeadbcd1db20c38ef0427f8cf4ab04344045c0f10d24f1055a02
from 0x18244fbf3b47175cd6b4a1183a476c9e70cb7368
to WoTResourceACL.UserRegister(string,uint256) 0x3944fb3e4f97b149689dbf9b1e83d8bd361f02ef
gas 900000 gas
hash 0x1e484dfa3afbbeadbcd1db20c38ef0427f8cf4ab04344045c0f10d24f1055a02
input 0x39c...00000
decoded input {
"string userName": "LYQ",
"uint256 feiyong": {
"_hex": "0x64"
}
}
decoded output -
logs [
{
"from": "0x3944fb3e4f97b149689dbf9b1e83d8bd361f02ef",
"topic": "0x27948276c58d5b63b61d92a95fe3cf7e2d6cf9c00ecdddac43cbe4a492a011e2",
"event": "UserRegisterEVENT",
"args": {
"0": "0x18244fBF3B47175cD6b4a1183A476c9e70cB7368",
"1": "registered",
"myaddr": "0x18244fBF3B47175cD6b4a1183A476c9e70cB7368",
"result": "registered",
"length": 2
}
}
]
value 0 wei
答案 10 :(得分:0)
function getProductionGroupItems($itemId){
$this->db->select("*");
$this->db->where("id",$itemId);
$this->db->or_where("parent_item_id",$itemId);
/*********** order by *********** */
$this->db->order_by("id", "asc");
$q=$this->db->get("recipe_products");
if($q->num_rows()>0){
foreach($q->result() as $row){
$data[]=$row;
}
return $data;
}
return false;
}
答案 11 :(得分:-1)
使用order_by
:
$this->db->order_by("coloumn_name", "desc");
$query = $this->db->get('table_name');
return $query->result();