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


PHP table::find方法代码示例

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


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

示例1: table

<?php

include '../rolisz.php';
rolisz::connect('MySQLi', 'localhost', 'root', '', 'rolisz');
include '../db.php';
table::set('posts');
table::addRelationM2MS('posts', 'post_category', 'id', 'pid', 'category', 'id', 'cid');
table::addRelationM2MS('posts', 'post_tags', 'id', 'pid', 'tags', 'id', 'tid');
table::addRelationS('posts', 'users', 'author', 'id');
table::addRelationS('posts', 'comments', 'pid');
//var_dump(table::findS('posts'));
$posts = new table('posts');
// $posts->addRelationM2M('post_category','id','pid','category','id','cid');
// $posts->addRelation('users','author','id');
// $posts->addRelation('comments','pid');
$posts->title = 'Test Post';
$posts->body = 'Lorem Ipsum Doloret coloret';
$posts->author = 1;
//$posts->save();
$posts1 = new table('posts', 1);
$test = $posts1->find('category');
$comment = new table('comments', 1);
$comment->posts(array('id' => 1));
$comment->save();
$author = new table('users', 1);
$posts2 = new table('posts', 2);
$posts2->tags(array('tag' => 'google'));
开发者ID:rolisz,项目名称:framework,代码行数:27,代码来源:dbtest.php

示例2: table

<?php

include '../rolisz.php';
rolisz::connect('MySQLi', 'localhost', 'root', '', 'wordpress');
include '../db.php';
$posts = new table('wpb_posts', '59');
$posts->addRelationM2M('wpb_term_relationships', 'id', 'object_id', 'wpb_terms', 'term_id', 'term_taxonomy_id');
$posts->addRelation('wpb_users', 'post_author', 'ID');
$posts->addRelation('wpb_comments', 'comment_post_ID');
$term_rel = new table('wpb_terms');
$term_rel->addRelation('wpb_term_taxonomy', 'term_id');
//$posts->save();
$test = $posts->find('wpb_posts', array('wpb_terms' => array('wpb_term_taxonomy' => array('taxonomy' => 'category'), 'name' => 'Customization')));
var_dump($test);
echo 'yooooo';
$test = $posts->find('wpb_terms');
var_dump($test);
开发者ID:rolisz,项目名称:framework,代码行数:17,代码来源:dbtest1.php

示例3: findMany

 /**
  * Returns an array of table objects each set to there id
  *
  * @param string $where (sql where clause to limit which rows are fetched)
  * @param string $orderby (sql order by clause to order the result records)
  * @param string $other (any other sql you would like to tack on the end)
  * @return array or bool (array on success, bool on none found)
  * @access public
  */
 function findMany($where = '', $orderby = '', $other = '')
 {
     $all = array();
     $sql = "SELECT {$this->primary_key} FROM {$this->table} {$where} {$orderby} {$other}";
     if ($this->debug) {
         echo '<p><strong>Find Many SQL:</strong> ' . $sql . '</p>';
         if ($this->db->isError()) {
             echo $this->db->getErrorMsg();
             return false;
         }
     }
     $result = $this->db->query($sql);
     if ($result->numRows() > 0) {
         while ($row = $result->fetchRow()) {
             $t = new table($this->db, $this->table);
             $t->find($row[$this->primary_key]);
             $all[] = $t;
         }
         return $all;
     } else {
         if ($this->debug) {
             echo "<p>No results were found based on the criteria you provided. (where = {$where} // orderby = {$orderby})</p>";
         }
         return false;
     }
 }
开发者ID:laiello,项目名称:bitcero-modules,代码行数:35,代码来源:class.table.php

示例4: findS

 /** 
  * Static wrapper for find(). Arguments the same.
  * 		@param string $table Table in which to search
  * 		@param array $filters Filters to apply. Can be name=>value pair, SQL statement, or recursive array relating to conditions on other tables
  * 		@param array $ordergroup How to order, group and limit the search
  * 		@param array $columns What columns to return in search
  * 		@return array
  **/
 public static function findS($table, $filters = array(), $ordergroup = array(), $columns = array())
 {
     $Table = new table($table);
     return $Table->find($table, $filters, $ordergroup, $columns);
 }
开发者ID:rolisz,项目名称:framework,代码行数:13,代码来源:table.php

示例5: editACL

 /**
  *  Edit the ACL. Parameters the same as for addNew(), except an extra parameter.
  * 		@param string $type It can be 'resource', 'action', 'requester' or 'permission'
  * 		@param mixed $what For 'resource', 'action' and 'requester' it should be a string containing the name of the new 
  * 	element. For 'permission' it should be an associative array containing key-value pairs for each of the types. If no action
  * 	has to be defined then it action should be NULL. 
  * 		@param string $towhat What to change this to
  * 		@param string $where Used only for 'requester', it should the name of the node after which to insert. If it is not found,
  * 	the new value is inserted as a new group.
  * 		@retval false It returns false if you are trying to use it without a database or XML file or if an element can't be found.
  * 		@retval true
  * 
  */
 public function editACL($type, $what, $towhat, $where = FALSE)
 {
     if (is_null($this->prefix)) {
         return false;
     }
     if (is_string($what)) {
         $req = table::findS($this->prefix . "_{$type}s", array($type => $what));
         if (!$req) {
             trigger_error("Can't find {$what} of {$type}");
             return false;
         }
         $what = $req->id;
     }
     if ($type == 'resource' || $type == 'action') {
         $req = new table($this->prefix . "_{$type}s", $what);
         $req->{$type} = $towhat;
         $req->save();
     }
     if ($type == 'requester') {
         $req = new table($this->prefix . '_requesters', $what);
         if (!$req) {
             trigger_error("Can't find {$what} {$type} to edit");
             return false;
         }
         //Treat cases where $where is another requester, another id, or it is not defined/found
         if ($where) {
             if (is_numeric($where)) {
                 $orig = new table($this->prefix . '_requesters', $where);
             } else {
                 $orig = $req->find($this->prefix . '_requesters', array('requester' => $where));
             }
             if ($orig) {
                 $right = $orig->right;
             } else {
                 trigger_error("Can't find {$where} to put there the {$what} {$type}");
                 return false;
             }
             rolisz::get('dbCon')->query("UPDATE `{$this->prefix}_requesters` SET \n\t\t\t\t\t\t\t\tleft = left-2 WHERE left>{$req->right} AND left<{$right}+3");
             rolisz::get('dbCon')->query("UPDATE `{$this->prefix}_requesters` SET \n\t\t\t\t\t\t\t\tright = right-2 WHERE right>{$req->right} AND right<{$right}+3");
             $req->left = $right + 1;
             $req->right = $right + 2;
         }
         $req->requester = $towhat;
         $req->save();
     }
     if ($type == 'permission') {
         //Loop through each type and if it's a string, get the associated id
         foreach ($towhat as $type => $value) {
             if (is_string($value)) {
                 $towhat[$type] = rolisz::table($this->prefix . "_{$type}s")->find($this->prefix . "_{$type}s", array($type => $value));
                 if (!$towhat[$type]) {
                     trigger_error("{$value} {$type} not found");
                     return false;
                 }
                 $towhat[$type] = $towhat[$type]->id;
             }
         }
         $perm = new table($this->prefix . '_permissions', $what);
         foreach ($towhat as $type => $value) {
             $perm->{$type} = $value;
         }
         $perm->save();
     }
     return true;
 }
开发者ID:rolisz,项目名称:framework,代码行数:78,代码来源:acl.php


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