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


PHP Querier::prepare方法代码示例

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


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

示例1: writeTable

 function writeTable($qualifier, $subject_id = '', $description_search = 0)
 {
     global $IconPath;
     global $proxyURL;
     $db = new Querier();
     // sanitize submission
     switch ($qualifier) {
         case "Num":
             $connection = $db->getConnection();
             $statement = $connection->prepare("SELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n      \tFROM title as t\n      \tINNER JOIN location_title as lt\n      \tON t.title_id = lt.title_id\n      \tINNER JOIN location as l\n      \tON lt.location_id = l.location_id\n      \tINNER JOIN restrictions as r\n      \tON l.access_restrictions = r.restrictions_id\n      \tINNER JOIN rank as rk\n      \tON rk.title_id = t.title_id\n      \tINNER JOIN source as s\n      \tON rk.source_id = s.source_id\n      \tWHERE left(title, 1)  REGEXP '[[:digit:]]+'\n      \tAND eres_display = 'Y'\n      \tORDER BY newtitle");
             $statement->execute();
             $results = $statement->fetchAll();
             break;
         case "All":
             $connection = $db->getConnection();
             $statement = $connection->prepare("\n        SELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide, alternate_title\n        FROM title as t\n        INNER JOIN location_title as lt\n        ON t.title_id = lt.title_id\n        INNER JOIN location as l\n        ON lt.location_id = l.location_id\n        INNER JOIN restrictions as r\n        ON l.access_restrictions = r.restrictions_id\n        INNER JOIN rank as rk\n        ON rk.title_id = t.title_id\n        INNER JOIN source as s\n        ON rk.source_id = s.source_id\n        WHERE title != ''\n        AND eres_display = 'Y'\n        \t\tORDER BY newtitle");
             $statement->execute();
             $results = $statement->fetchAll();
             break;
         case "bysub":
             if (isset($subject_id)) {
                 // get title ids in pluslets' resource token connected to subject
                 // I don't know the purpose of this, so I zeroed it out below by resetting the $lobjTitleIds array --agd
                 $lobjGuide = new Guide($subject_id);
                 $lobjTitleIds = $lobjGuide->getRelatedTitles();
                 $lobjTitleIds = array();
                 if (count($lobjTitleIds) > 0) {
                     $connection = $db->getConnection();
                     $statement = $connection->prepare("\n        \tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide, alternate_title\n        \tFrom title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE title LIKE :qualifer\n        \tAND eres_display = 'Y'\n        ORDER BY newtitle");
                     /*
                     $condition1 = "WHERE (subject_id = $subject_id";
                     $condition1 .= count ( $lobjTitleIds ) > 0 ? "\nOR t.title_id IN (" . implode ( ',', $lobjTitleIds ) . ")" : "";
                     $condition1 .= ")";
                     */
                     $letter = "%" . $qualifier . "%";
                     $statement->bindParam(":qualifer", $letter);
                     $statement->execute();
                     $results = $statement->fetchAll();
                 } else {
                     $connection = $db->getConnection();
                     $statement = $connection->prepare("\n        \tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide, alternate_title\n        \tFROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE subject_id = :subject_id\n        \tAND eres_display = 'Y'\n        ORDER BY newtitle");
                     $statement->bindParam(":subject_id", $subject_id);
                     $statement->execute();
                     $results = $statement->fetchAll();
                 }
             } else {
                 $connection = $db->getConnection();
                 $statement = $connection->prepare("\n        \tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n        \tFROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE title LIKE :qualifer\n        \tAND eres_display = 'Y'\n        ORDER BY newtitle");
                 $letter = "%" . $qualifier . "%";
                 $statement->bindParam(":qualifer", $letter);
                 $statement->execute();
                 $results = $statement->fetchAll();
             }
             break;
         case "bytype":
             if (isset($_GET["type"])) {
                 $type = scrubData("%" . $_GET["type"] . "%");
                 $connection = $db->getConnection();
                 $statement = $connection->prepare("\n        \t\tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n            FROM title as t\n            INNER JOIN location_title as lt\n            ON t.title_id = lt.title_id\n            INNER JOIN location as l\n            ON lt.location_id = l.location_id\n            INNER JOIN restrictions as r\n            ON l.access_restrictions = r.restrictions_id\n            INNER JOIN rank as rk\n            ON rk.title_id = t.title_id\n            INNER JOIN source as s\n            ON rk.source_id = s.source_id\n            WHERE ctags LIKE :type\n            AND eres_display = 'Y'\n            ORDER BY newtitle");
                 $statement->bindParam(":type", $type);
                 $statement->execute();
                 $results = $statement->fetchAll();
             }
             break;
         case "search":
             // If you uncomment the next line, it will search description field
             $connection = $db->getConnection();
             $statement = $db->prepare("\n        \tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n        \tFROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE (title LIKE :qualifier OR description LIKE :qualifier)\n        \tAND eres_display = 'Y'\n        ORDER BY newtitle");
             $qualifier = "%" . $qualifier . "%";
             $statement->execute();
             $results = $statement->fetchAll();
             break;
         default:
             // This is the simple output by letter and also the search
             if (strlen($qualifier) == 1) {
                 // Is like the first letter
                 $connection = $db->getConnection();
                 $statement = $connection->prepare("\n\tSELECT DISTINCT LEFT(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide,alternate_title\n        \tFROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE left(t.title, 1) LIKE :qualifer\n        \tAND eres_display = 'Y'\n\n        UNION\n        \tSELECT DISTINCT LEFT(alternate_title,1) as initial, alternate_title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide,alternate_title\n            FROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE left(alternate_title, 1) LIKE :qualifer\n        \tAND eres_display = 'Y'\nORDER BY newtitle\n\n");
                 $letter = $qualifier . "%";
                 $statement->bindParam(":qualifer", $letter);
                 $statement->execute();
                 $results = $statement->fetchAll();
             } else {
                 $connection = $db->getConnection();
                 $statement = $connection->prepare("\n        \tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n        \tFROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE title LIKE :qualifer\n        \tAND eres_display = 'Y'\n        ORDER BY newtitle");
                 $letter = "%" . $qualifier . "%";
                 $statement->bindParam(":qualifer", $letter);
                 $statement->execute();
                 $results = $statement->fetchAll();
                 $condition1 = "WHERE title LIKE " . $db->quote("%" . $qualifier . "%");
             }
             if ($description_search == 1) {
                 $connection = $db->getConnection();
                 $statement = $connection->prepare("\n        \tSELECT distinct left(t.title,1) as initial, t.title as newtitle, t.description, location, access_restrictions, t.title_id as this_record,eres_display, display_note, pre, citation_guide, ctags, helpguide\n        \tFROM title as t\n        \tINNER JOIN location_title as lt\n        \tON t.title_id = lt.title_id\n        \tINNER JOIN location as l\n        \tON lt.location_id = l.location_id\n        \tINNER JOIN restrictions as r\n        \tON l.access_restrictions = r.restrictions_id\n        \tINNER JOIN rank as rk\n        \tON rk.title_id = t.title_id\n        \tINNER JOIN source as s\n        \tON rk.source_id = s.source_id\n        WHERE (title LIKE :qualifer OR description LIKE :qualifer1)\n        \tAND eres_display = 'Y'\n        ORDER BY newtitle");
                 $qualifier = "%" . $qualifier . "%";
                 $statement->bindParam(":qualifer", $qualifier);
                 $statement->bindParam(":qualifer1", $qualifier);
                 $statement->execute();
                 $results = $statement->fetchAll();
             }
//.........这里部分代码省略.........
开发者ID:johnwinsor,项目名称:SubjectsPlus,代码行数:101,代码来源:DbHandler.php


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