0
我想使用datamapper選擇空列。CodeIgniter數據映射器選擇空列
下面是我的嘗試:
$u = new test();
$u->where("id",1);
$u->select('name');
$u->get();
$u->result_count();
我試圖找出名字列是否爲空。
如果名稱存在於數據庫中,它將插入名稱或將其爲空。
感謝
我想使用datamapper選擇空列。CodeIgniter數據映射器選擇空列
下面是我的嘗試:
$u = new test();
$u->where("id",1);
$u->select('name');
$u->get();
$u->result_count();
我試圖找出名字列是否爲空。
如果名稱存在於數據庫中,它將插入名稱或將其爲空。
感謝
我建議使用存在方法。
$u = new text();
$u->where("id",1);
$u->select('name');
$u->get();
if($u->exists()){
//Code if TRUE
}else{
//Code if FALSE
}
你可以找到更多關於DataMapper的事業在這裏:http://datamapper.wanwizard.eu/pages/utility.html#exists
希望這有助於!
我不確定你想在哪裏測試空名稱。你的意思是在SQL中,在哪裏,或在php的土地?你的例子中的'result_count()'表明在sql中,但爲什麼不是'$ u-> where('name','')'? – complex857 2013-04-24 09:52:04