Example #1
0
function GetAllGenres()
{
    // Set variable
    //-------------
    $aGenre = [];
    $i = 0;
    $sDisplay = "<input class=\"form-control\" list=\"chose_genre\" type=\"search\" id=\"g\" name=\"g\"><datalist id=\"chose_genre\">";
    ///////////////
    // Connection to DB
    //-----------------
    $oMyDB = new PDO('mysql:host=' . MYSQLHOST . ';dbname=' . DATABASE, MYSQLUSER, MYSQLPWD);
    $oMyDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //////////////////////////////////////////////////////////////
    // Set query
    //----------
    $sQuery = "\n\tSELECT\n\t\tgenre\n\tFROM\n\t\tgenres\n\t";
    $oResponse = ExecuteQuerie($oMyDB, $sQuery, "SELECT");
    ///////////////////////////////////////////////////////
    // Insert result in array for return
    //----------------------------------
    while ($aDataG = $oResponse->fetch()) {
        $aGenre[$i] = $aDataG['genre'];
        $i++;
    }
    ///////////////////////////////////////////////////////
    // Display options
    //----------------
    foreach ($aGenre as $val) {
        $sDisplay .= "<option value=" . $val . "/>";
    }
    $sDisplay .= "</datalist>";
    /////////////////////////////////////////////////////////////////
    return $sDisplay;
}
Example #2
0
function AddUnCorrectMovie($aFileNotFound)
{
    // Set variable
    //-------------
    $sMustInsert = "";
    // Connection to DB
    //-----------------
    $oMyDB = new PDO('mysql:host=' . MYSQLHOST . ';dbname=' . DATABASE, MYSQLUSER, MYSQLPWD);
    $oMyDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //////////////////////////////////////////////////////////////
    // String format
    //--------------
    foreach ($aFileNotFound as $sFile) {
        $sMustInsert .= '("' . $sFile['source'] . '","' . rtrim($sFile['correct']) . '","' . $sFile['path'] . '"),';
    }
    $sMustInsert = rtrim($sMustInsert, ",");
    //////////////////////////////////////////////////////////////
    // Insert uncorrect filename in DB if not already in
    //--------------------------------------------------
    $sQuery = 'SELECT
                    id_correct
				FROM
                    corrects
				WHERE
                    filename_source = "' . $sFile['source'] . '"
                AND
					file_path		= "' . str_replace("\\\\", "\\", $sFile['path']) . '";';
    $oResponse = ExecuteQuerie($oMyDB, $sQuery, 'SELECT');
    $aDataFile = $oResponse->fetch();
    //////////////////////////////////////////////////////////////
    // If the uncorrect movies isn't in DB, add it
    //--------------------------------------------
    if (!isset($aDataFile['id_correct'])) {
        $sQuery = 'INSERT INTO
					corrects
					(filename_source,
					filename_correct,
					file_path)
					VALUES ' . $sMustInsert;
        ExecuteQuerie($oMyDB, $sQuery, 'INSERT');
    }
    ////////////////////////////////////////////
}