3 include_once("pkgbasefuncs.inc.php");
6 * Determine if the user can delete a specific package comment
8 * Only the comment submitter, Trusted Users, and Developers can delete
9 * comments. This function is used for the backend side of comment deletion.
11 * @param string $comment_id The comment ID in the database
13 * @return bool True if the user can delete the comment, otherwise false
15 function can_delete_comment($comment_id=0) {
18 $q = "SELECT UsersID FROM PackageComments ";
19 $q.= "WHERE ID = " . intval($comment_id);
20 $result = $dbh->query($q);
26 $uid = $result->fetch(PDO
::FETCH_COLUMN
, 0);
28 return has_credential(CRED_COMMENT_DELETE
, array($uid));
32 * Determine if the user can delete a specific package comment using an array
34 * Only the comment submitter, Trusted Users, and Developers can delete
35 * comments. This function is used for the frontend side of comment deletion.
37 * @param array $comment All database information relating a specific comment
39 * @return bool True if the user can delete the comment, otherwise false
41 function can_delete_comment_array($comment) {
42 return has_credential(CRED_COMMENT_DELETE
, array($comment['UsersID']));
46 * Determine if the user can edit a specific package comment
48 * Only the comment submitter, Trusted Users, and Developers can edit
49 * comments. This function is used for the backend side of comment editing.
51 * @param string $comment_id The comment ID in the database
53 * @return bool True if the user can edit the comment, otherwise false
55 function can_edit_comment($comment_id=0) {
58 $q = "SELECT UsersID FROM PackageComments ";
59 $q.= "WHERE ID = " . intval($comment_id);
60 $result = $dbh->query($q);
66 $uid = $result->fetch(PDO
::FETCH_COLUMN
, 0);
68 return has_credential(CRED_COMMENT_EDIT
, array($uid));
72 * Determine if the user can edit a specific package comment using an array
74 * Only the comment submitter, Trusted Users, and Developers can edit
75 * comments. This function is used for the frontend side of comment editing.
77 * @param array $comment All database information relating a specific comment
79 * @return bool True if the user can edit the comment, otherwise false
81 function can_edit_comment_array($comment) {
82 return has_credential(CRED_COMMENT_EDIT
, array($comment['UsersID']));
86 * Check to see if the package name already exists in the database
88 * @param string $name The package name to check
90 * @return string|void Package name if it already exists
92 function pkg_from_name($name="") {
93 if (!$name) {return NULL;}
95 $q = "SELECT ID FROM Packages ";
96 $q.= "WHERE Name = " . $dbh->quote($name);
97 $result = $dbh->query($q);
101 $row = $result->fetch(PDO
::FETCH_NUM
);
106 * Get licenses for a specific package
108 * @param int $pkgid The package to get licenses for
110 * @return array All licenses for the package
112 function pkg_licenses($pkgid) {
114 $pkgid = intval($pkgid);
116 $dbh = DB
::connect();
117 $q = "SELECT l.Name FROM Licenses l ";
118 $q.= "INNER JOIN PackageLicenses pl ON pl.LicenseID = l.ID ";
119 $q.= "WHERE pl.PackageID = ". $pkgid;
120 $result = $dbh->query($q);
124 while ($row = $result->fetch(PDO
::FETCH_COLUMN
, 0)) {
132 * Get package groups for a specific package
134 * @param int $pkgid The package to get groups for
136 * @return array All package groups for the package
138 function pkg_groups($pkgid) {
140 $pkgid = intval($pkgid);
142 $dbh = DB
::connect();
143 $q = "SELECT g.Name FROM Groups g ";
144 $q.= "INNER JOIN PackageGroups pg ON pg.GroupID = g.ID ";
145 $q.= "WHERE pg.PackageID = ". $pkgid;
146 $result = $dbh->query($q);
150 while ($row = $result->fetch(PDO
::FETCH_COLUMN
, 0)) {
158 * Get providers for a specific package
160 * @param string $name The name of the "package" to get providers for
162 * @return array The IDs and names of all providers of the package
164 function pkg_providers($name) {
165 $dbh = DB
::connect();
166 $q = "SELECT p.ID, p.Name FROM Packages p ";
167 $q.= "INNER JOIN PackageRelations pr ON pr.PackageID = p.ID ";
168 $q.= "INNER JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
169 $q.= "WHERE rt.Name = 'provides' ";
170 $q.= "AND pr.RelName = " . $dbh->quote($name);
171 $result = $dbh->query($q);
177 $providers = array();
178 while ($row = $result->fetch(PDO
::FETCH_NUM
)) {
185 * Get package dependencies for a specific package
187 * @param int $pkgid The package to get dependencies for
189 * @return array All package dependencies for the package
191 function pkg_dependencies($pkgid) {
193 $pkgid = intval($pkgid);
195 $dbh = DB
::connect();
196 $q = "SELECT pd.DepName, dt.Name, pd.DepCondition, pd.DepArch, p.ID FROM PackageDepends pd ";
197 $q.= "LEFT JOIN Packages p ON pd.DepName = p.Name ";
198 $q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = p.Name ";
199 $q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
200 $q.= "WHERE pd.PackageID = ". $pkgid . " ";
201 $q.= "ORDER BY pd.DepName";
202 $result = $dbh->query($q);
206 while ($row = $result->fetch(PDO
::FETCH_NUM
)) {
214 * Get package relations for a specific package
216 * @param int $pkgid The package to get relations for
218 * @return array All package relations for the package
220 function pkg_relations($pkgid) {
222 $pkgid = intval($pkgid);
224 $dbh = DB
::connect();
225 $q = "SELECT pr.RelName, rt.Name, pr.RelCondition, pr.RelArch, p.ID FROM PackageRelations pr ";
226 $q.= "LEFT JOIN Packages p ON pr.RelName = p.Name ";
227 $q.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
228 $q.= "WHERE pr.PackageID = ". $pkgid . " ";
229 $q.= "ORDER BY pr.RelName";
230 $result = $dbh->query($q);
234 while ($row = $result->fetch(PDO
::FETCH_NUM
)) {
242 * Get the HTML code to display a package dependency link annotation
243 * (dependency type, architecture, ...)
245 * @param string $type The name of the dependency type
246 * @param string $arch The package dependency architecture
247 * @param string $desc An optdepends description
249 * @return string The HTML code of the label to display
251 function pkg_deplink_annotation($type, $arch, $desc=false) {
252 if ($type == 'depends' && !$arch) {
258 if ($type == 'makedepends') {
260 } elseif ($type == 'checkdepends') {
262 } elseif ($type == 'optdepends') {
266 if ($type != 'depends' && $arch) {
271 $link .= htmlspecialchars($arch);
275 if ($type == 'optdepends' && $desc) {
276 $link .= ' – ' . htmlspecialchars($desc) . ' </em>';
284 * Get the HTML code to display a package dependency link
286 * @param string $name The name of the dependency
287 * @param string $type The name of the dependency type
288 * @param string $cond The package dependency condition string
289 * @param string $arch The package dependency architecture
290 * @param int $pkg_id The package of the package to display the dependency for
292 * @return string The HTML code of the label to display
294 function pkg_depend_link($name, $type, $cond, $arch, $pkg_id) {
295 if ($type == 'optdepends' && strpos($name, ':') !== false) {
296 $tokens = explode(':', $name, 2);
303 $providers = array();
304 if (is_null($pkg_id)) {
306 * TODO: We currently perform one SQL query per nonexistent
307 * package dependency. It would be much better if we could
308 * annotate dependency data with providers so that we already
309 * know whether a dependency is a "provision name" or a package
310 * from the official repositories at this point.
312 $providers = pkg_providers($name);
315 if (count($providers) > 0) {
316 $link = htmlspecialchars($name) . ' ';
317 $link .= '<span class="virtual-dep">(';
318 foreach ($providers as $provider) {
319 $name = $provider[1];
320 $link .= '<a href="';
321 $link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES
);
322 $link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
323 $link .= htmlspecialchars($name) . '</a>, ';
325 $link = substr($link, 0, -2);
329 if (is_null($pkg_id)) {
330 $link .= 'https://www.archlinux.org/packages/?q=' . urlencode($name);
332 $link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES
);
334 $link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
335 $link .= htmlspecialchars($name) . '</a>';
336 $link .= htmlspecialchars($cond);
339 return $link . pkg_deplink_annotation($type, $arch, $desc);
343 * Get the HTML code to display a package requirement link
345 * @param string $name The name of the requirement
346 * @param string $depends The (literal) name of the dependency of $name
347 * @param string $type The name of the dependency type
348 * @param string $arch The package dependency architecture
349 * @param string $pkgname The name of dependant package
351 * @return string The HTML code of the link to display
353 function pkg_requiredby_link($name, $depends, $type, $arch, $pkgname) {
354 if ($type == 'optdepends' && strpos($name, ':') !== false) {
355 $tokens = explode(':', $name, 2);
360 $link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES
);
361 $link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
362 $link .= htmlspecialchars($name) . '</a>';
364 if ($depends != $pkgname) {
366 if (strpos($depends, ':') !== false) {
367 $tokens = explode(':', $depname, 2);
368 $depname = $tokens[0];
371 $link .= ' <span class="virtual-dep">(';
372 $link .= __('requires %s', htmlspecialchars($depname));
376 return $link . pkg_deplink_annotation($type, $arch);
380 * Get the HTML code to display a package relation
382 * @param string $name The name of the relation
383 * @param string $cond The package relation condition string
384 * @param string $arch The package relation architecture
386 * @return string The HTML code of the label to display
388 function pkg_rel_html($name, $cond, $arch) {
389 $html = htmlspecialchars($name) . htmlspecialchars($cond);
392 $html .= ' <em>(' . htmlspecialchars($arch) . ')</em>';
399 * Get the HTML code to display a source link
401 * @param string $url The URL of the source
402 * @param string $arch The source architecture
404 * @return string The HTML code of the label to display
406 function pkg_source_link($url, $arch) {
407 $url = explode('::', $url);
408 $parsed_url = parse_url($url[0]);
410 if (isset($parsed_url['scheme']) ||
isset($url[1])) {
411 $link = '<a href="' . htmlspecialchars((isset($url[1]) ?
$url[1] : $url[0]), ENT_QUOTES
) . '">' . htmlspecialchars($url[0]) . '</a>';
413 $link = htmlspecialchars($url[0]);
417 $link .= ' <em>(' . htmlspecialchars($arch) . ')</em>';
424 * Determine packages that depend on a package
426 * @param string $name The package name for the dependency search
427 * @param array $provides A list of virtual provisions of the package
429 * @return array All packages that depend on the specified package name
431 function pkg_required($name="", $provides) {
434 $dbh = DB
::connect();
436 $name_list = $dbh->quote($name);
437 foreach ($provides as $p) {
438 $name_list .= ',' . $dbh->quote($p[0]);
441 $q = "SELECT p.Name, pd.DepName, dt.Name, pd.DepArch FROM PackageDepends pd ";
442 $q.= "LEFT JOIN Packages p ON p.ID = pd.PackageID ";
443 $q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
444 $q.= "WHERE pd.DepName IN (" . $name_list . ") ";
445 $q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) IN (" . $name_list . ") ";
446 $q.= "ORDER BY p.Name";
447 $result = $dbh->query($q);
448 if (!$result) {return array();}
449 while ($row = $result->fetch(PDO
::FETCH_NUM
)) {
457 * Get all package sources for a specific package
459 * @param string $pkgid The package ID to get the sources for
461 * @return array All sources associated with a specific package
463 function pkg_sources($pkgid) {
465 $pkgid = intval($pkgid);
467 $dbh = DB
::connect();
468 $q = "SELECT Source, SourceArch FROM PackageSources ";
469 $q.= "WHERE PackageID = " . $pkgid;
470 $q.= " ORDER BY Source";
471 $result = $dbh->query($q);
475 while ($row = $result->fetch(PDO
::FETCH_NUM
)) {
483 * Get the package details
485 * @param string $id The package ID to get description for
487 * @return array The package's details OR error message
489 function pkg_get_details($id=0) {
490 $dbh = DB
::connect();
492 $q = "SELECT Packages.*, PackageBases.ID AS BaseID, ";
493 $q.= "PackageBases.Name AS BaseName, PackageBases.NumVotes, ";
494 $q.= "PackageBases.Popularity, PackageBases.OutOfDateTS, ";
495 $q.= "PackageBases.SubmittedTS, PackageBases.ModifiedTS, ";
496 $q.= "PackageBases.SubmitterUID, PackageBases.MaintainerUID, ";
497 $q.= "PackageBases.PackagerUID, PackageBases.FlaggerUID, ";
498 $q.= "(SELECT COUNT(*) FROM PackageRequests ";
499 $q.= " WHERE PackageRequests.PackageBaseID = Packages.PackageBaseID ";
500 $q.= " AND PackageRequests.Status = 0) AS RequestCount ";
501 $q.= "FROM Packages, PackageBases ";
502 $q.= "WHERE PackageBases.ID = Packages.PackageBaseID ";
503 $q.= "AND Packages.ID = " . intval($id);
504 $result = $dbh->query($q);
509 $row['error'] = __("Error retrieving package details.");
512 $row = $result->fetch(PDO
::FETCH_ASSOC
);
514 $row['error'] = __("Package details could not be found.");
522 * Display the package details page
524 * @param string $id The package ID to get details page for
525 * @param array $row Package details retrieved by pkg_get_details()
526 * @param string $SID The session ID of the visitor
530 function pkg_display_details($id=0, $row, $SID="") {
531 $dbh = DB
::connect();
533 if (isset($row['error'])) {
534 print "<p>" . $row['error'] . "</p>\n";
537 $base_id = pkgbase_from_pkgid($id);
538 $pkgbase_name = pkgbase_name_from_id($base_id);
540 include('pkg_details.php');
543 include('pkg_comment_box.php');
546 $limit = isset($_GET['comments']) ?
0 : 10;
547 $include_deleted = has_credential(CRED_COMMENT_VIEW_DELETED
);
548 $comments = pkgbase_comments($base_id, $limit, $include_deleted);
549 if (!empty($comments)) {
550 include('pkg_comments.php');
555 /* pkg_search_page(SID)
556 * outputs the body of search/search results page
559 * SID - current Session ID
561 * package search page has been accessed
562 * request variables have not been sanitized
565 * O - starting result number
566 * PP - number of search hits per page
567 * K - package search string
568 * SO - search hit sort order:
569 * values: a - ascending
571 * SB - sort search hits by:
572 * values: n - package name
573 * v - number of votes
574 * m - maintainer username
575 * SeB- property that search string (K) represents
576 * values: n - package name
577 * nd - package name & description
578 * b - package base name
579 * N - package name (exact match)
580 * B - package base name (exact match)
581 * k - package keyword(s)
582 * m - package maintainer's username
583 * s - package submitter's username
584 * do_Orphans - boolean. whether to search packages
585 * without a maintainer
588 * These two are actually handled in packages.php.
590 * IDs- integer array of ticked packages' IDs
591 * action - action to be taken on ticked packages
592 * values: do_Flag - Flag out-of-date
593 * do_UnFlag - Remove out-of-date flag
597 * do_Notify - Enable notification
598 * do_UnNotify - Disable notification
600 function pkg_search_page($SID="") {
601 $dbh = DB
::connect();
604 * Get commonly used variables.
605 * TODO: Reduce the number of database queries!
608 $myuid = uid_from_sid($SID);
610 /* Sanitize paging variables. */
611 if (isset($_GET['O'])) {
612 $_GET['O'] = max(intval($_GET['O']), 0);
617 if (isset($_GET["PP"])) {
618 $_GET["PP"] = bound(intval($_GET["PP"]), 50, 250);
624 * FIXME: Pull out DB-related code. All of it! This one's worth a
625 * choco-chip cookie, one of those nice big soft ones.
628 /* Build the package search query. */
629 $q_select = "SELECT ";
631 $q_select .= "CommentNotify.UserID AS Notify,
632 PackageVotes.UsersID AS Voted, ";
634 $q_select .= "Users.Username AS Maintainer,
635 Packages.Name, Packages.Version, Packages.Description,
636 PackageBases.NumVotes, PackageBases.Popularity, Packages.ID,
637 Packages.PackageBaseID, PackageBases.OutOfDateTS ";
639 $q_from = "FROM Packages
640 LEFT JOIN PackageBases ON (PackageBases.ID = Packages.PackageBaseID)
641 LEFT JOIN Users ON (PackageBases.MaintainerUID = Users.ID) ";
643 /* This is not needed for the total row count query. */
644 $q_from_extra = "LEFT JOIN PackageVotes
645 ON (PackageBases.ID = PackageVotes.PackageBaseID AND PackageVotes.UsersID = $myuid)
646 LEFT JOIN CommentNotify
647 ON (PackageBases.ID = CommentNotify.PackageBaseID AND CommentNotify.UserID = $myuid) ";
652 $q_where = 'WHERE PackageBases.PackagerUID IS NOT NULL ';
654 if (isset($_GET['K'])) {
655 if (isset($_GET["SeB"]) && $_GET["SeB"] == "m") {
656 /* Search by maintainer. */
657 $q_where .= "AND Users.Username = " . $dbh->quote($_GET['K']) . " ";
659 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "s") {
660 /* Search by submitter. */
661 $q_where .= "AND SubmitterUID = " . intval(uid_from_username($_GET['K'])) . " ";
663 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "n") {
664 /* Search by name. */
665 $K = "%" . addcslashes($_GET['K'], '%_') . "%";
666 $q_where .= "AND (Packages.Name LIKE " . $dbh->quote($K) . ") ";
668 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "b") {
669 /* Search by package base name. */
670 $K = "%" . addcslashes($_GET['K'], '%_') . "%";
671 $q_where .= "AND (PackageBases.Name LIKE " . $dbh->quote($K) . ") ";
673 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "k") {
674 /* Search by keywords. */
675 $q_where .= construct_keyword_search($dbh, false);
677 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "N") {
678 /* Search by name (exact match). */
679 $q_where .= "AND (Packages.Name = " . $dbh->quote($_GET['K']) . ") ";
681 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "B") {
682 /* Search by package base name (exact match). */
683 $q_where .= "AND (PackageBases.Name = " . $dbh->quote($_GET['K']) . ") ";
686 /* Keyword search (default). */
687 $q_where .= construct_keyword_search($dbh, true);
691 if (isset($_GET["do_Orphans"])) {
692 $q_where .= "AND MaintainerUID IS NULL ";
695 if (isset($_GET['outdated'])) {
696 if ($_GET['outdated'] == 'on') {
697 $q_where .= "AND OutOfDateTS IS NOT NULL ";
699 elseif ($_GET['outdated'] == 'off') {
700 $q_where .= "AND OutOfDateTS IS NULL ";
704 $order = (isset($_GET["SO"]) && $_GET["SO"] == 'd') ?
'DESC' : 'ASC';
706 $q_sort = "ORDER BY ";
707 $sort_by = isset($_GET["SB"]) ?
$_GET["SB"] : '';
710 $q_sort .= "NumVotes " . $order . ", ";
713 $q_sort .= "Popularity " . $order . ", ";
717 $q_sort .= "Voted " . $order . ", ";
722 $q_sort .= "Notify " . $order . ", ";
726 $q_sort .= "Maintainer " . $order . ", ";
729 $q_sort .= "ModifiedTS " . $order . ", ";
732 /* For compatibility with old search links. */
733 $q_sort .= "-ModifiedTS " . $order . ", ";
738 $q_sort .= " Packages.Name " . $order . " ";
740 $q_limit = "LIMIT ".$_GET["PP"]." OFFSET ".$_GET["O"];
742 $q = $q_select . $q_from . $q_from_extra . $q_where . $q_sort . $q_limit;
743 $q_total = "SELECT COUNT(*) " . $q_from . $q_where;
745 $result = $dbh->query($q);
746 $result_t = $dbh->query($q_total);
748 $row = $result_t->fetch(PDO
::FETCH_NUM
);
755 if ($result && $total > 0) {
756 if (isset($_GET["SO"]) && $_GET["SO"] == "d"){
764 /* Calculate the results to use. */
765 $first = $_GET['O'] +
1;
767 /* Calculation of pagination links. */
768 $per_page = ($_GET['PP'] > 0) ?
$_GET['PP'] : 50;
769 $current = ceil($first / $per_page);
770 $pages = ceil($total / $per_page);
771 $templ_pages = array();
774 $templ_pages['« ' . __('First')] = 0;
775 $templ_pages['‹ ' . __('Previous')] = ($current - 2) * $per_page;
778 if ($current - 5 > 1)
779 $templ_pages["..."] = false;
781 for ($i = max($current - 5, 1); $i <= min($pages, $current +
5); $i++
) {
782 $templ_pages[$i] = ($i - 1) * $per_page;
785 if ($current +
5 < $pages)
786 $templ_pages["... "] = false;
788 if ($current < $pages) {
789 $templ_pages[__('Next') . ' ›'] = $current * $per_page;
790 $templ_pages[__('Last') . ' »'] = ($pages - 1) * $per_page;
793 include('pkg_search_form.php');
795 $searchresults = array();
797 while ($row = $result->fetch(PDO
::FETCH_ASSOC
)) {
798 $searchresults[] = $row;
802 include('pkg_search_results.php');
808 * Construct the WHERE part of the sophisticated keyword search
810 * @param handle $dbh Database handle
811 * @param boolean $namedesc Search name and description fields
813 * @return string WHERE part of the SQL clause
815 function construct_keyword_search($dbh, $namedesc) {
821 foreach (str_getcsv($_GET['K'], ' ') as $term) {
825 if ($count > 0 && strtolower($term) == "and") {
829 if ($count > 0 && strtolower($term) == "or") {
833 if ($count > 0 && strtolower($term) == "not") {
838 $term = "%" . addcslashes($term, '%_') . "%";
839 $q_keywords .= $op . " (";
841 $q_keywords .= "Packages.Name LIKE " . $dbh->quote($term) . " OR ";
842 $q_keywords .= "Description LIKE " . $dbh->quote($term) . " OR ";
844 $q_keywords .= "EXISTS (SELECT * FROM PackageKeywords WHERE ";
845 $q_keywords .= "PackageKeywords.PackageBaseID = Packages.PackageBaseID AND ";
846 $q_keywords .= "PackageKeywords.Keyword LIKE " . $dbh->quote($term) . ")) ";
855 if (!empty($q_keywords)) {
856 $where_part = "AND (" . $q_keywords . ") ";
863 * Determine if a POST string has been sent by a visitor
865 * @param string $action String to check has been sent via POST
867 * @return bool True if the POST string was used, otherwise false
869 function current_action($action) {
870 return (isset($_POST['action']) && $_POST['action'] == $action) ||
871 isset($_POST[$action]);
875 * Determine if sent IDs are valid integers
877 * @param array $ids IDs to validate
879 * @return array All sent IDs that are valid integers
881 function sanitize_ids($ids) {
883 foreach ($ids as $id) {
893 * Determine package information for latest package
895 * @param int $numpkgs Number of packages to get information on
897 * @return array $packages Package info for the specified number of recent packages
899 function latest_pkgs($numpkgs) {
900 $dbh = DB
::connect();
902 $q = "SELECT Packages.*, MaintainerUID, SubmittedTS ";
903 $q.= "FROM Packages LEFT JOIN PackageBases ON ";
904 $q.= "PackageBases.ID = Packages.PackageBaseID ";
905 $q.= "ORDER BY SubmittedTS DESC ";
906 $q.= "LIMIT " . intval($numpkgs);
907 $result = $dbh->query($q);
911 while ($row = $result->fetch(PDO
::FETCH_ASSOC
)) {