當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBQuery::return_values_from_sql方法代碼示例

本文整理匯總了PHP中DBQuery::return_values_from_sql方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBQuery::return_values_from_sql方法的具體用法?PHP DBQuery::return_values_from_sql怎麽用?PHP DBQuery::return_values_from_sql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBQuery的用法示例。


在下文中一共展示了DBQuery::return_values_from_sql方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: preg_split

 $catd = preg_split('/\\|/', $category);
 $parent = trim($catd[0]);
 $catname = trim($catd[1]);
 $cat = mysql_real_escape_string($catname);
 $par = mysql_real_escape_string($parent);
 $sql = "SELECT id FROM category WHERE category_title LIKE '{$cat}'; ";
 $ids = DBQuery::return_values_from_sql($sql);
 if (count($ids) == 1) {
     $cat_id = $ids[0];
     $sql = "INSERT INTO incident_category (category_id, incident_id) VALUES ('{$cat_id}', '{$id}'); ";
     mysql_query($sql);
 } elseif (count($ids) > 1) {
     #ambiguous name - get parent's
     $sql = "SELECT category.id FROM category WHERE category.category_title LIKE '{$cat}' ";
     $sql .= "AND category.parent_id IN (SELECT par.id FROM category AS par WHERE par.category_title LIKE '{$par}');";
     $pids = DBQuery::return_values_from_sql($sql);
     if (count($ids) == 1) {
         $cat_id = $pids[0];
         $sql = "INSERT INTO incident_category (category_id, incident_id) VALUES ('{$cat_id}', '{$id}'); ";
         mysql_query($sql);
     }
 } else {
     /**
     # This code will automatically add a new category with that name - commented out for now
     
     $sql = "INSERT INTO category (category_title) VALUES ('$cat'); ";
     $res = mysql_query($sql);
     $cat_id = DBQuery::get_last_id();
     $sql = "INSERT INTO incident_category (category_id, incident_id) VALUES ('$cat_id', '$id'); ";
     */
 }
開發者ID:unthinkingly,項目名稱:ushahidi-crowdflower-plugin,代碼行數:31,代碼來源:index.php

示例2: return_values

 /**
  * returns the list of values of $ret_field if a record with $field = $value exists in the given $table
  * return an empty array otherwise
  */
 public static function return_values($field, $value, $table, $ret_field)
 {
     $sql = "SELECT {$ret_field} FROM {$table} WHERE {$field} = '{$value}';";
     return DBQuery::return_values_from_sql($sql);
 }
開發者ID:unthinkingly,項目名稱:ushahidi-crowdflower-plugin,代碼行數:9,代碼來源:includes.php


注:本文中的DBQuery::return_values_from_sql方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。