当前位置: 首页>>代码示例>>PHP>>正文


PHP DAO::fetch_all_part方法代码示例

本文整理汇总了PHP中DAO::fetch_all_part方法的典型用法代码示例。如果您正苦于以下问题:PHP DAO::fetch_all_part方法的具体用法?PHP DAO::fetch_all_part怎么用?PHP DAO::fetch_all_part使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DAO的用法示例。


在下文中一共展示了DAO::fetch_all_part方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DataObject

 /**
  * Select all objects from the database where the WHERE clause is entirely true.
  * Every argument will match a value in a column in the database.
  * @param DAO $dao a reference to a instance of DAO
  * @param string $table the name of the table of the objects
  * @param array $keys the associative array naming the properties of these objects for selection
  * @param array $where the associative array describing the properties of these objects (used in the WHERE clause)
  * @return array An array of DataObject instances with the variables specified in $assoc which can
  *	be committed to the table $table.
  */
 static function select_all($dao, $table, $keys, $where)
 {
     $obj = new DataObject();
     $obj->table = $table;
     $obj->dao = $dao;
     //Reference to the dao stored
     $obj->update = true;
     //This will be updated on commit
     $objects = array();
     $query_where = $obj->key_values($where);
     $query_part = implode(",", $keys);
     $query = "SELECT " . $query_part . " FROM " . $table . " WHERE " . implode(" AND ", $query_where) . " ORDER BY " . $keys[0] . " DESC;";
     $dao->myquery($query);
     $query_objects = $dao->fetch_all_part($keys);
     //determine primary key and value
     $dao->myquery("SHOW index FROM {$obj->table} where Key_name = 'PRIMARY';");
     // var_dump($dao->fetch_one_obj());
     $obj->primary_key = $dao->fetch_one_obj()->Column_name;
     foreach ($query_objects as $query_obj) {
         $new_obj = clone $obj;
         //Copy the default obj
         foreach ($keys as $key) {
             $new_obj->{$key} = $query_obj[$key];
         }
         $new_obj->primary_id = $new_obj->{$new_obj->primary_key};
         $objects[] = $new_obj;
     }
     return $objects;
 }
开发者ID:ThisIsGJ,项目名称:unify,代码行数:39,代码来源:mysql.php

示例2: DAO

            $conversation->user_picture = $user2->user_picture;
            $conversations[$convo_id] = $conversation;
        } else {
            $conversation = $conversations[$convo_id];
        }
        $conversation->messages[$message->msg_id] = $message;
    }
    return $conversations;
}
$dao = new DAO(false);
if (isset($_POST["user_id"])) {
    if ($_POST["user_id"] == "-1") {
        //Get an array of all the conversations
        $conversations_query = "(SELECT user_id2 AS user_id FROM chat_msg WHERE user_id1={$user->user_id} GROUP BY user_id2) \n\t\t\t\t\t\t\t\t\tUNION \n\t\t\t\t\t\t\t\t\t(SELECT user_id1 AS user_id FROM chat_msg WHERE user_id2={$user->user_id} GROUP BY user_id1)";
        $dao->myquery($conversations_query);
        $conversation_requests = $dao->fetch_all_part(array("user_id"));
        $conversations = array();
        foreach ($conversation_requests as $request) {
            $c = get_conversations($dao, $request["user_id"], -1, -1)[$request["user_id"]];
            $conversations[$request["user_id"]] = $c;
        }
        echo json_encode_strip($conversations);
    } else {
        $conversations = get_conversations($dao, $_POST["user_id"], -1, -1)[$_POST["user_id"]];
        echo json_encode_strip($conversations);
    }
} else {
    $conversation_requests = $_POST;
    $conversations = array();
    foreach ($conversation_requests as $request) {
        $c = get_conversations($dao, $request["user_id"], $request["latest_pulled"], $request["latest_seen_by_u2"])[$request["user_id"]];
开发者ID:ThisIsGJ,项目名称:unify,代码行数:31,代码来源:get.php


注:本文中的DAO::fetch_all_part方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。