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


PHP Dal::query_one_object方法代码示例

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


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

示例1: getRelationData

 /**
  * Add the friend in the database by giving their user_id as relations_id.
  * @param int $relation_id This is user id of the user to whom user is adding as a friend
  * if this relation_id is given as -1, it is a external relation (flickr friend etc)
  * in that case the extra parameters MUST be supplied
  * in_family parameter added  by gurpreet to mark whether the person added is in family.
  */
 public static function getRelationData($user_id, $relation_id, $network_id)
 {
     $res = Dal::query_one_object("SELECT * FROM {relations} WHERE user_id=? AND relation_id=? AND network_uid=?", array($user_id, $relation_id, $network_id));
     if (!$res) {
         return NULL;
     }
     return new RelationData($res);
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:15,代码来源:Relation.php

示例2: get_user_type

 /**
  * get the type of user for a given network
  * @access public static.
  * @param address of the network
  */
 static function get_user_type($network_id, $uid)
 {
     Logger::log("[Enter: static function Network::get_user_type]network_id = {$network_id},uid={$uid}");
     $row = Dal::query_one_object("SELECT user_type FROM {networks_users} WHERE network_id = ? AND user_id = ?", array($network_id, $uid));
     Logger::log("[Exit: static function Network::get_user_type] ");
     return $row ? $row->user_type : NULL;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:12,代码来源:Network.php

示例3: add_all_users_to_mother_network

 function add_all_users_to_mother_network()
 {
     //    echo "<pre>Adding all users to the mother network</pre>\n";
     $res = Dal::query("select network_id from {networks} where type=1");
     $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
     $mother_id = $row->network_id;
     $q = Dal::query_one_object("SELECT * FROM {networks_users} WHERE network_id={$mother_id}");
     if ($q) {
         return;
     }
     $res = Dal::query("select user_id from {users} where is_active=1");
     $result_data = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
         $result_data[] = $row;
     }
     foreach ($result_data as $key => $value) {
         $type = $value['user_id'] == $this->admin_id ? 'owner' : 'member';
         $sql = "INSERT INTO {networks_users} (network_id,user_id,user_type) values(?,?,?)";
         $res = Dal::query($sql, array($mother_id, $value['user_id'], $type));
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:21,代码来源:net_extra.class.php

示例4: testStorage

 function testStorage()
 {
     // test Storage - public API
     // store test.txt
     echo "saving test.txt with a crazy name\n";
     $file_id = Storage::save('test.txt', 'O*Bc3wukygfsT@#($0876)$!@#*+_][.txt');
     echo "resulting file_id = {$file_id}\n";
     $file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($file_id));
     $this->assertEquals($file->link_count, 0);
     $this->assertEquals($file->last_linked, NULL);
     $file_path = Storage::getPath($file_id);
     $file_url = Storage::getURL($file_id);
     echo "getPath({$file_id}) -> {$file_path}\n";
     echo "getURL({$file_id}) -> {$file_url}\n";
     $this->assertTrue(strpos($file_path, PA::$path . "/web/files/") === 0);
     $this->assertTrue(strpos($file_url, PA::$url) === 0);
     // link it in somewhere
     $link_id = Storage::link($file_id, array('role' => 'avatar', 'user' => 1));
     echo "linked it in as avatar for user 1; link_id = {$link_id}\n";
     $link = Dal::query_one_object("SELECT * FROM file_links WHERE link_id=?", array($link_id));
     $this->assertEquals($link->file_id, $file_id);
     $file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($file_id));
     $this->assertEquals($file->link_count, 1);
     $this->assertNotEquals($file->last_linked, NULL);
     // another file
     $child_file_id = Storage::save('test2.txt', 'this is the child file.jpg', 'throwaway', 'image/jpeg');
     echo "child file: {$child_file_id}\n";
     $child_file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($child_file_id));
     $child_file_path = Storage::getPath($child_file_id);
     $child_file_url = Storage::getURL($child_file_id);
     echo "getPath({$child_file_id}) -> {$child_file_path}\n";
     echo "getURL({$child_file_id}) -> {$child_file_url}\n";
     $this->assertTrue(strpos($child_file_path, PA::$path . "/web/files/") === 0);
     $this->assertTrue(strpos($child_file_url, PA::$url) === 0);
     // link child file in as a thumbnail of first file
     $child_link_id = Storage::link($child_file_id, array('role' => 'thumb', 'file' => $file_id, 'dim' => '123x123'));
     echo "child link id: {$child_link_id}\n";
     $child_link = Dal::query_one_object("SELECT * FROM file_links WHERE link_id=?", array($child_link_id));
     $this->assertEquals($child_link->file_id, $child_file_id);
     $this->assertEquals($child_link->parent_file_id, $file_id);
     $child_file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($child_file_id));
     $this->assertEquals($child_file->link_count, 1);
     $this->assertNotEquals($child_file->last_linked, NULL);
     // this should fail (missing role)
     try {
         Storage::link($file_id, array("user" => 1));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // this should fail (missing network)
     try {
         Storage::link($file_id, array("role" => "header", "group" => 42));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // this should fail (network not valid)
     try {
         Storage::link($file_id, array("role" => "thumb", "network" => 1, "file" => $file_id, "dim" => "123x123"));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // this should fail (parent_file_id == file_id)
     try {
         $link_id = Storage::link($file_id, array("role" => "thumb", "file" => $file_id, "dim" => "123x123"));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // Now unlink the two files we just created ...
     // unlink the first - but don't delete it
     Storage::unlink($file_id, $link_id, FALSE);
     // make sure it's gone
     $this->assertEquals(Dal::query_one("SELECT * FROM file_links WHERE link_id=?", array($link_id)), NULL);
     // the file should still be there, with zero links, though
     $file = Dal::query_one("SELECT * FROM files WHERE file_id=?", array($file_id));
     $this->assertNotEquals($file, NULL);
     $this->assertEquals($file->link_count, 0);
     // try a bad unlink operation
     try {
         Storage::unlink($file_id, $child_link_id);
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), FILE_NOT_FOUND);
     }
     // unlink and delete the second
     Storage::unlink($child_file_id, $child_link_id);
     // make sure it's gone
     $this->assertEquals(Dal::query_one("SELECT * FROM file_links WHERE link_id=?", array($child_link_id)), NULL);
     // and make sure the file is gone too
     $this->assertEquals(Dal::query_one("SELECT * FROM files WHERE file_id=?", array($child_file)), NULL);
     // reap unlinked files (immediately - no grace period)
     Storage::cleanupFiles(-1, -1);
     // make sure the first file is now gone
     $this->assertEquals(Dal::query_one("SELECT * FROM files WHERE file_id=?", array($file_id)), NULL);
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:98,代码来源:StorageTest.php


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