The following code: {code...} generates the following SQL statement, and {code...} executes the preceding statement in PHP. No exception is thrown if an error occurs. If the pdo throw exception mode {code...} is enabled, the following error occurs when you run phpmyadmin.
The following code:
/*** Write data ** @ param string $ table * @ param array $ data * @ return int */public function insert ($ table, $ data) {try {$ SQL = "INSERT ". $ this-> table ($ table); $ columns = $ values = ''; foreach ($ data as $ k => $ v) {$ columns. = "'$ k',"; $ values. = ": $ k," ;}$ columns = rtrim ($ columns, ','); $ values = rtrim ($ values ,','); $ SQL = $ SQL. "($ columns) VALUES ($ values)"; $ this-> _ init ($ SQL, $ data); unset ($ SQL, $ columns, $ values ); return $ this-> insertId ();} catch (\ PDOException $ e) {$ this-> halt ($ e-> getMessage (), $ this-> getSql (); return false ;}}
The following SQL statement is generated,
Insert into 'dba _ tables '('pid', 'sellerid', 'cardnum', 'processunit', 'prodate', 'dateofpro', 'shipdate', 'clinicname ', 'Doctor', 'created ', 'doctormail', 'doctormobile', 'treattime', 'treatdesc', 'patient', 'patientemail', 'remark') VALUES, '2dfbd1-9e27-cffd-6846-459ca9e9', 'workshop 2', 1460476800,1459008000, 1463068800, 'hospital ', 'Doctor', 1460507802, 'd @ a.com ', '123 ','', 'Ya ', 'xx mou', 'c @ a.com', 'asfasdf ')
If you use PHP to execute the preceding statement, no exception will be thrown even when an error occurs.
The pdo throw exception mode has been enabled.
$this->_pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
However, the following error occurs when phpmyadmin is used.
Reply content:
The following code:
/*** Write data ** @ param string $ table * @ param array $ data * @ return int */public function insert ($ table, $ data) {try {$ SQL = "INSERT ". $ this-> table ($ table); $ columns = $ values = ''; foreach ($ data as $ k => $ v) {$ columns. = "'$ k',"; $ values. = ": $ k," ;}$ columns = rtrim ($ columns, ','); $ values = rtrim ($ values ,','); $ SQL = $ SQL. "($ columns) VALUES ($ values)"; $ this-> _ init ($ SQL, $ data); unset ($ SQL, $ columns, $ values ); return $ this-> insertId ();} catch (\ PDOException $ e) {$ this-> halt ($ e-> getMessage (), $ this-> getSql (); return false ;}}
The following SQL statement is generated,
Insert into 'dba _ tables '('pid', 'sellerid', 'cardnum', 'processunit', 'prodate', 'dateofpro', 'shipdate', 'clinicname ', 'Doctor', 'created ', 'doctormail', 'doctormobile', 'treattime', 'treatdesc', 'patient', 'patientemail', 'remark') VALUES, '2dfbd1-9e27-cffd-6846-459ca9e9', 'workshop 2', 1460476800,1459008000, 1463068800, 'hospital ', 'Doctor', 1460507802, 'd @ a.com ', '123 ','', 'Ya ', 'xx mou', 'c @ a.com', 'asfasdf ')
If you use PHP to execute the preceding statement, no exception will be thrown even when an error occurs.
The pdo throw exception mode has been enabled.
$this->_pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
However, the following error occurs when phpmyadmin is used.
The answer has been deleted. Sorry.