从另一个表插入到表SELECT中不提供ID

时间:2019-01-09 23:11:29

标签: php pdo

我试图弄清楚如何将select中的数据提供给一个语句。

$statement = "INSERT INTO $table2 ($fields2) SELECT $fields$table$whereOrderBy";
echo $statement;
return $datas = $this->query($statement, $fields2, false, null); //fields2 is attributes..

INSERT INTO match_players (match_id,team_id,team_player_id,name,squad_number,display_order,status ) SELECT id,team1_id,210,SUEMA,13,23,first_eleven FROM matches WHERE team1_id = 1 AND is_deleted = 0

//it doesnt show 'team1_id' is 1....
  

警告:PDOStatement :: execute()期望参数1为数组,   在/var/opt/lampp/htdocs/testLAB/query/query.php中给出的字符串   59

$db->insertSelect('all', ['fields2' => ['match_id', 'team_id', 'team_player_id', 'name', 'squad_number', 'display_order', 'status'], 'fields' => ['id', 'team1_id', $team_player_id, $name, $squad_number, $display_order, $default_status], 'conditions' => ['team1_id' => $id, 'is_deleted' => 0]]);

错误代码:

  

警告:PDOStatement :: execute()期望参数1为数组,   在/var/opt/lampp/htdocs/testLAB/query/query.php中给出的字符串   59

功能:function prepare($statement, $attributes, $one = false, $fetch = null) 59:$res = $req->execute($attributes);

var_dump($ attriputes):

array(6) { [0]=> string(8) "TYRAJYRA" [1]=> string(1) "1" [2]=> string(2) "44" [3]=> string(13) "not_available" [4]=> string(2) "33" [5]=> string(16) "img/default.jpeg" } 
INSERT INTO match_players (match_id,team_id,team_player_id,name,squad_number,display_order,status ) SELECT id,team1_id,211,TYRAJYRA,44,33,not_available FROM matches WHERE team1_id = 1 AND is_deleted = 0
string(71) "match_id,team_id,team_player_id,name,squad_number,display_order,status " 

0 个答案:

没有答案