Ben dizi olarak sadece bir satır döndüren bir işlevi var.
Ben tam olarak yalnızca bir satır veren bir parametre olarak bir sorgu verir.
function getFields($query)
{
$t =& get_instance();
$ret = $t->db->query($query);
if(!$ret)return false;
else if(!$ret->num_rows()) return array();
else return $ret->row_array();
}
$ret = getFields('query string');
Ne düşündüm oldu ...
- if there is an error then i can check it like if(!$res)/ /echo error
- if it is empty i can check it like if(!count($res))/ / no rows
- başka orada bir satır ve işlemine devam varsayalım ...
ANCAK
- olduğunda yanlış bir hata döndürdü. If (count ($ ret)) 1 verir.
- ($ Ret) koşullar başarısız olursa ben gibi boş bir dizi döndürür if (false verir).
/ /
$ret = getFields('query string');
if(!$fes)jerror('status,0,msg,dberror');
if(!count($fes))jerror('status,1,msg,no rows');
/ / continue execution when there atleast one row.
Bu kod ajax kullanarak denir. i bir json yanıt dönmek.
niye sayısı 1 verir ve boş dizi yanlış olarak verir.
i just wanted to code with logical conditions instead of giving more relations conditions. just to reduce code.
I yukarıdaki gibi mantıksal hataları yapma sona olmamalıdır emin olun, böylece nereye php tüm bu adamcağız şeyler alabilirsiniz.
BUGGING - in the above sentence bugging i referred as not a bug but things bugs us. things which makes us logical errors.
I edited this following code to include the following meanwhile i got this as the reply by http:/ /stackoverflow.com/users/451672/andrew-dunn
Ben bunu şöyle yapabiliriz ama yine de ben bilmek istiyorum neden yukarıdaki açıklama için
if($fes===false)jerror();
if(!$fes)jsuccess('status,4');