wpdb::show_errors PHP Method

show_errors() public method

This function should be used only to enable showing of errors. wpdb::hide_errors() should be used instead for hiding of errors. However, this function can be used to enable and disable showing of database errors.
See also: wpdb::hide_errors()
Since: 0.71
public show_errors ( boolean $show = true ) : boolean
$show boolean Whether to show or hide errors
return boolean Old value for showing errors.
    public function show_errors($show = true)
    {
        $errors = $this->show_errors;
        $this->show_errors = $show;
        return $errors;
    }

Usage Example

コード例 #1
0
ファイル: mixcloud-embed-core.php プロジェクト: seoduda/Patua
 function __toString()
 {
     // if the playlist are saved to db, i load it from db
     $playlist = $this->wpdb->get_row("SELECT ID, url, playlist FROM " . $this->table_name . " WHERE url = '" . $this->url . "'");
     if ($this->wpdb->num_rows > 0) {
         $playlist = unserialize($playlist->playlist);
     } else {
         $playlist = array();
         $code = implode("", file($this->url));
         if ($code == "") {
             $this->errors->add('no_content', __('The url $url are not valid!'));
         }
         preg_match_all("/section-row-track(.+)/", $code, $results);
         for ($i = 0; $i < sizeof($results[0]); $i++) {
             preg_match("/class=\"tracklisttrackname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match);
             $title = $match[1];
             preg_match("/class=\"tracklistartistname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match);
             $artist = $match[1];
             if ($title != "" || $artist != "") {
                 $playlist[] = array("title" => $title, "artist" => $artist);
             }
         }
         $this->wpdb->show_errors();
         // save to db the playlist for this url
         $this->wpdb->insert($this->table_name, array("url" => $this->url, "playlist" => serialize($playlist)), array("%s", "%s"));
     }
     $code = "<h3>Playlist</h3><ul class='mixcloud-embed-playlist'>";
     for ($i = 0; $i < count($playlist); $i++) {
         $code .= "<li><span class='mixcloud-embed-position'>" . ($i + 1) . "</span>";
         $code .= "<span class='mixcloud-embed-artist'>" . $playlist[$i]["artist"] . "</span>";
         $code .= "<span class='mixcloud-embed-title'>" . $playlist[$i]["title"] . "</span></li>";
     }
     $code .= "</ul>";
     return $code;
 }
All Usage Examples Of wpdb::show_errors