prepare

PHP PDO Prepare queries

纵饮孤独 提交于 2019-12-09 10:51:21
问题 I read on PDO and I searched on StackOverFlow about pdo and prepare statement. I want to know what are/is the benefits or using the prepare statement. eg: $sql = 'SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour'; $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY)); $sth->execute(array(':calories' => 150, ':colour' => 'red')); $red = $sth->fetchAll(); vs $sql = "SELECT name, colour, calories FROM fruit WHERE calories < $calories

Fatal error: Call to a member function prepare() on null

耗尽温柔 提交于 2019-12-08 12:16:13
问题 code: function insertheadright($name) { $str1 = xss($name); $sql = "INSERT INTO `nav-menu` (`id`, `Head-categories`, `RightMenu`, `LeftMenu`, `Sub-categories`, `Show-sub`, `Show-head`, `keywords`, `description`) VALUES (NULL, ?, '1', '0', '0', '0', '1', '', '')"; $result = $connect->prepare($sql); $result->bindValue(1, $str1); $query = $result->execute(); if ($query) { $num = 1; return $num; } else { $num = 0; return $num; } } code 2: $object = insertheadright($_POST["nav-name"]); if (isset(

maven release:prepare IOException

两盒软妹~` 提交于 2019-12-08 03:36:30
问题 I'm trying to get maven's release plugin working with Perforce. When I run: mvn release:prepare -Dusername=PerforceUser -Dpassword=PerforcePassword I get this output (with some IPs/username/passwords removed): [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] root-project [INFO] project1 [INFO] project2 [INFO] project3 [INFO] project4 [INFO] project5 [INFO] project6 [INFO] project7 [INFO]

Android: MediaPlayer onPrepared is not being called

瘦欲@ 提交于 2019-12-07 16:49:03
问题 As title says, the onPrepared() overridden method is not being called. mediaPlayer = new MediaPlayer(); mediaPlayer.setOnPreparedListener(new OnPreparedListener(){ @Override public void onPrepared(MediaPlayer mp){ if (mp.equals(mediaPlayer)) isReady_mediaPlayer = true; Log.e("I", "Media player has been loaded to memory !"); } }); mediaPlayer = MediaPlayer.create(this, R.raw.my_sound_mp3); 回答1: It's because you are creating a new MediaPlayer object. This one does not have any

PDO : prepare with bindvalue and like %

試著忘記壹切 提交于 2019-12-06 12:31:57
I've looked over an hour on various website but I couldn't solve my problem. So here is the code that works: $animes = array(); $q = $this->_db->query('SELECT id, nom, nom_id FROM animes WHERE nom LIKE "%code%"'); while ($data = $q->fetch(PDO::FETCH_ASSOC)) { $animes[] = new Anime($data); } return $animes; And here is the one that doesn't work : $animes = array(); $q = $this->_db->prepare('SELECT id, nom, nom_id FROM animes WHERE nom LIKE :n'); $q->bindValue(':n',"%code%",PDO::PARAM_STR); while ($data = $q->fetch(PDO::FETCH_ASSOC)) { $animes[] = new Anime($data); } return $animes;` I use %code

MySQL Select into variable

会有一股神秘感。 提交于 2019-12-06 10:37:55
I want to further use in the procedure the values I get from a select into execution but can't figure out how to do it. As a test I wrote the following but cannot use the v_1, v_2 or v_3 variables for further logic as they don't take the values 1,2 & 3 as i expected... DROP PROCEDURE IF EXISTS MPT_testing; DELIMITER // CREATE PROCEDURE MPT_testing() READS SQL DATA BEGIN DECLARE v_1 INT; DECLARE v_2 INT; DECLARE v_3 INT; SET @sql=CONCAT('SELECT 1,2 into v_1, v_2'); PREPARE s1 FROM @sql; EXECUTE s1; DEALLOCATE PREPARE s1; SET v_3 = v_1 + v_2; SELECT v_3; END // DELIMITER ; Can somebody help here

PHP stmt prepare fails but there are no errors

拈花ヽ惹草 提交于 2019-12-06 04:01:19
问题 I am trying to prepare a mysqli query, but it fails silently without giving any error. $db_hostname = "test.com"; $db_database = "dbname"; $db_username = "db_user"; $db_password = "password"; $db = new mysqli($db_hostname,$db_username,$db_password,$db_database); $q = "INSERT INTO Members (`wp_users_ID`,`MemberID`,`Status`,`MiddleName`,`Nickname`,`Prefix`,`Suffix`,`HomeAddress`,`City`,`State`,`Zip`,`ExtendedZip`,`BadAddress`,`SpouseFirstName`,`SpouseMiddleName`,`HomePhone`,`CellPhone`,

MediaPlayer sometimes not preparing when screen is locked

China☆狼群 提交于 2019-12-06 00:52:47
I have a MusicService for MediaPlayback, wich uses a MediaPlayer with the settings: player.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); player.setAudioStreamType(AudioManager.STREAM_MUSIC); and those Listeners are set: OnPreparedListener, OnCompletionListener, OnErrorListener, OnSeekCompleteListener The MediaPlayer is used for mp3-Playback. When one Song is finished, onCompletion is called. Then PlayNext is called, wich resets the MediaPlayer, then sets the Datasource with the URI of the next Track. Uri is loaded with: Uri trackUri = ContentUris .withAppendedId(android

Android: MediaPlayer onPrepared is not being called

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 21:46:52
As title says, the onPrepared() overridden method is not being called. mediaPlayer = new MediaPlayer(); mediaPlayer.setOnPreparedListener(new OnPreparedListener(){ @Override public void onPrepared(MediaPlayer mp){ if (mp.equals(mediaPlayer)) isReady_mediaPlayer = true; Log.e("I", "Media player has been loaded to memory !"); } }); mediaPlayer = MediaPlayer.create(this, R.raw.my_sound_mp3); It's because you are creating a new MediaPlayer object. This one does not have any onPreparededListener set on it. Here you create and assign a MediaPlayer object: mediaPlayer = new MediaPlayer(); Next you

Qt QSqlQuery prepare and bindValue not working

瘦欲@ 提交于 2019-12-05 21:39:59
I have a problem with prepare and bindValue :( db.open(); QSqlQuery q; q.prepare("SELECT id_malade,nom,prenom FROM Malade WHERE nom LIKE %:p% OR prenom = %:f% ;"); q.bindValue(":p",ui->lineEdit->text()); q.bindValue(":f",ui->lineEdit->text()); qDebug() << q.boundValue(0) << " " << q.boundValue(1); qDebug() << q.executedQuery().toStdString().c_str(); db.close(); output is: QVariant(QString, "zit") QVariant(QString, "zit") SELECT id_malade,nom,prenom FROM Malade WHERE nom LIKE %?% OR prenom = %?% ; I tried to change :p and :f with ? and use int positions in bindValue but no luck. The query got