Tôi đang cố gắng gửi một biến dưới dạng chuỗi trong câu lệnh SQL đến hàm DB của tôi, sau đó sẽ sử dụng chuỗi đó làm biến và thực hiện xử lý.
Nhiều tập lệnh chèn [như mảng] cần ID chèn cuối cùng, đây là mã rút ngắn:
$insertID = "$"."insertID";
$sql = array["first INSERT Script", "INSERT into blah[`ID`, `Name`]
VALUE ['$insertID', '$name']", "Third script"];
$result = dbInsert[$sql];
if [$result]{
// do something
}
Đây là chức năng chèn, tôi đang thử nghiệm nếu theo cách này sẽ hoạt động:
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
Xin lưu ý tập lệnh đầu tiên không yêu cầu bất kỳ ID chèn cuối cùng nào, nhưng các bản tiếp theo làm. Tôi biết tôi có thể thực hiện các phần chèn cá nhân và bỏ qua toàn bộ cách này, nhưng sẽ tốt nếu tôi chỉ gửi một mảng SQLS và chức năng thực hiện việc chèn và gửi lại ID chèn cuối cùng [để xác minh].
Khi tôi lặp lại [& die] câu lệnh SQL trong hàm dbinsert có "$ results" [giá trị của $ insertid], nhưng nó đọc nó dưới dạng chuỗi chứ không phải là biến, giữ ID chèn cuối cùng. Tôi đã thử một vài kết hợp nhưng không có kết quả.
Current:
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Nên là:
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES ['418', '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Tôi hy vọng tôi có ý nghĩa và ai đó sẽ có thể chỉ cho tôi đi đúng hướng. Đánh giá cao thời gian và sự giúp đỡ của bạn, cảm ơn bạn!
Hóa ra, tôi đã đi về nó sai cách. Tất cả những gì tôi cần làm là truyền vào "last_insert_id []" thay vì chuyển biến, vv Cảm ơn bạn vì tất cả sự giúp đỡ! Ai đó có thể được hưởng lợi từ điều này, do đó cập nhật bài đăng.
Simmo ở 9000 chấm 000
8 tháng trước
Tesdy14 tại gmail dot com
Twysto ¶
6 tháng trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
0Tianyiw tại VIP Dot qq dot com ¶
1 tháng trước
rsperduta tại gmail dot com ¶
igorsantos07 tại gmail dot com ¶
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
1John ¶
15 năm trước
Dmitry Dot Balabka tại Gmail Dot Com ¶
2 does not assign the default
value. function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
Ví dụ #4 Sử dụng các tham số mặc định trong các chức năng
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
3Ví dụ trên sẽ xuất ra:
Making a cup of cappuccino. Making a cup of . Making a cup of espresso.
Các giá trị tham số mặc định có thể là các giá trị vô hướng, mảng, loại đặc biệt
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
2 và kể từ Php 8.1.0, các đối tượng sử dụng cú pháp ClassName [] mới.arrays, the special type function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
2, and as of PHP 8.1.0, objects using the new ClassName[] syntax. Ví dụ #5 Sử dụng các loại không phân chia làm giá trị mặc định
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
5Ví dụ #6 Sử dụng các đối tượng làm giá trị mặc định [kể từ Php 8.1.0]
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
6Giá trị mặc định phải là một biểu thức không đổi, không [ví dụ] một biến, thành viên lớp hoặc lệnh gọi hàm.
Lưu ý rằng bất kỳ đối số tùy chọn nên được chỉ định sau bất kỳ đối số bắt buộc nào, nếu không chúng không thể được bỏ qua khỏi các cuộc gọi. Xem xét ví dụ sau:
Ví dụ #7 Sử dụng không chính xác đối số chức năng mặc định
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
7 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
8 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
9Ví dụ trên sẽ xuất ra:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 42
Các giá trị tham số mặc định có thể là các giá trị vô hướng, mảng, loại đặc biệt
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
2 và kể từ Php 8.1.0, các đối tượng sử dụng cú pháp ClassName [] mới.Ví dụ #5 Sử dụng các loại không phân chia làm giá trị mặc định
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
0 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
8 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
2Ví dụ trên sẽ xuất ra:
Making a bowl of raspberry yogurt.
Các giá trị tham số mặc định có thể là các giá trị vô hướng, mảng, loại đặc biệt
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
2 và kể từ Php 8.1.0, các đối tượng sử dụng cú pháp ClassName [] mới.Ví dụ #5 Sử dụng các loại không phân chia làm giá trị mặc định
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
3 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
4 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
5Ví dụ trên sẽ xuất ra:
Making a bowl of raspberry natural yogurt.
Ví dụ #6 Sử dụng các đối tượng làm giá trị mặc định [kể từ Php 8.1.0]
2 default makes the type implicitly nullable. This usage remains allowed, though it is recommended to use an explicit nullable type instead. function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
Giá trị mặc định phải là một biểu thức không đổi, không [ví dụ] một biến, thành viên lớp hoặc lệnh gọi hàm.
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
8Lưu ý rằng bất kỳ đối số tùy chọn nên được chỉ định sau bất kỳ đối số bắt buộc nào, nếu không chúng không thể được bỏ qua khỏi các cuộc gọi. Xem xét ví dụ sau:: As of PHP 7.1.0, omitting a parameter which does not specify a default throws an ArgumentCountError; in previous versions it raised a Warning.
Ví dụ #7 Sử dụng không chính xác đối số chức năng mặc định: Arguments that are passed by reference may have a default value.
Bây giờ, so sánh những điều trên với điều này:
Ví dụ #8 Sử dụng đúng đối số chức năng mặc định
Kể từ Php 8.0.0, các đối số được đặt tên có thể được sử dụng để bỏ qua nhiều tham số tùy chọn.: It is also possible to achieve variable-length arguments by using func_num_args[], func_get_arg[], and func_get_args[] functions. This technique is not recommended as it was used prior to the introduction of the
9 token.INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`] VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Ví dụ #9 Sử dụng đúng đối số chức năng mặc định
Kể từ Php 8.0.0, tuyên bố các đối số bắt buộc sau khi các đối số tùy chọn bị phản đối. Điều này thường có thể được giải quyết bằng cách bỏ giá trị mặc định, vì nó sẽ không bao giờ được sử dụng. Một ngoại lệ cho quy tắc này là các đối số của Mẫu
6, trong đó mặc định INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
2 làm cho loại này không thể vượt qua được. Việc sử dụng này vẫn được phép, mặc dù nên sử dụng một loại có thể điều chỉnh rõ ràng. function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES ['418', '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
3 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
4 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES ['418', '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
5Ví dụ trên sẽ xuất ra:
Ví dụ #10 Khai báo các đối số tùy chọn sau các đối số bắt buộcarray or Traversable variable or literal into the argument list:
Lưu ý: Kể từ Php 7.1.0, việc bỏ qua một tham số không chỉ định một mặc định ném một archarchChoolror; Trong các phiên bản trước, nó đã nêu ra một cảnh báo.
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES ['418', '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
8 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
4Making a cup of cappuccino. Making a cup of . Making a cup of espresso.0
Ví dụ trên sẽ xuất ra:
Lưu ý: Các đối số được truyền qua tham chiếu có thể có giá trị mặc định.
Danh sách đối số có độ dài thay đổi
PHP có hỗ trợ cho các danh sách đối số có độ dài thay đổi trong các hàm do người dùng xác định bằng cách sử dụng mã thông báo
9. INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Making a cup of cappuccino. Making a cup of . Making a cup of espresso.5
Ví dụ trên sẽ xuất ra:
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 2
Lưu ý: Cũng có thể đạt được các đối số có độ dài thay đổi bằng cách sử dụng các hàm func_num_args [], func_get_arg [] và func_get_args []. Kỹ thuật này không được khuyến nghị vì nó đã được sử dụng trước khi giới thiệu mã thông báo
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9. Danh sách đối số có thể bao gồm mã thông báo INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9 để biểu thị rằng hàm chấp nhận một số lượng đối số biến. Các đối số sẽ được chuyển vào biến đã cho dưới dạng một mảng; Ví dụ:
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Ví dụ #11 Sử dụng
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9 để truy cập các đối số biếnfunc_num_args[], func_get_arg[] and
func_get_args[].
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9 cũng có thể được sử dụng khi gọi các chức năng để giải nén một mảng hoặc biến có thể đi qua hoặc nghĩa đen vào danh sách đối số:Ví dụ #12 Sử dụng
9 để cung cấp các đối số INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Making a cup of cappuccino. Making a cup of . Making a cup of espresso.8
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
4 INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES ['418', '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
5Ví dụ trên sẽ xuất ra:
Bạn có thể chỉ định các đối số vị trí bình thường trước mã thông báo INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9. Trong trường hợp này, chỉ các đối số kéo dài không khớp với đối số vị trí sẽ được thêm vào mảng được tạo bởi INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9.
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Cũng có thể thêm một khai báo loại trước mã thông báo
INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9. Nếu điều này có mặt, thì tất cả các đối số được ghi lại bởi INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
9 phải khớp với loại tham số đó.Ví dụ #13 Loại đối số biến được khai báo
Cuối cùng, các đối số biến cũng có thể được truyền bằng cách tham chiếu bằng cách tiền tố
9 với một ampersand và [ INSERT INTO `tblstudent` [`userid`, `scholarnumber`, `firstname`, `middlename`, `lastname`, `datecreated`]
VALUES [$result, '35566', 'Joe', '', 'Blog', CURRENT_TIMESTAMP];
Making a cup of cappuccino.
Making a cup of .
Making a cup of espresso.
7].
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 421
Các phiên bản cũ của PHP
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 422
Không có cú pháp đặc biệt nào được yêu cầu để lưu ý rằng một hàm là variadic; Tuy nhiên, quyền truy cập vào các đối số của hàm phải sử dụng func_num_args [], func_get_arg [] và func_get_args [].
Ví dụ #17 Ví dụ tương tự như trên với một thứ tự khác nhau của các tham số
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 423
Các đối số được đặt tên có thể được kết hợp với các đối số vị trí. Trong trường hợp này, các đối số được đặt tên phải đến sau các đối số vị trí. Cũng có thể chỉ định một số đối số tùy chọn của một hàm, bất kể thứ tự của chúng.
Ví dụ #18 Kết hợp các đối số được đặt tên với các đối số vị trí
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 424
Vượt qua cùng một tham số nhiều lần dẫn đến một ngoại lệ lỗi.
Ví dụ #19 Lỗi ném khi vượt qua cùng một tham số nhiều lần
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 425
Kể từ Php 8.1.0, có thể sử dụng các đối số được đặt tên sau khi giải nén các đối số. Một đối số được đặt tên không được ghi đè một đối số đã được giải nén.
Ví dụ #20 Sử dụng các đối số được đặt tên sau khi giải nén
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 426
PHP tại Richardneill Dot org ¶ ¶
7 năm trước
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 427
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 428
Fatal error: Uncaught ArgumentCountError: Too few arguments to function makeyogurt[], 1 passed in example.php on line 429
Making a bowl of raspberry yogurt.0
Making a bowl of raspberry yogurt.1
Making a bowl of raspberry yogurt.2
Making a bowl of raspberry yogurt.3
Making a bowl of raspberry yogurt.4
Making a bowl of raspberry yogurt.5
Making a bowl of raspberry yogurt.6
Lilywhite ¶ ¶
1 năm trước
Making a bowl of raspberry yogurt.7
Making a bowl of raspberry yogurt.8
Making a bowl of raspberry yogurt.9
Making a bowl of raspberry natural yogurt.0
Gabriel tại FigDice Dot org ¶ ¶
6 năm trước
Making a bowl of raspberry natural yogurt.1
Making a bowl of raspberry natural yogurt.2
Making a bowl of raspberry natural yogurt.3
Making a bowl of raspberry natural yogurt.4
Boan Dot Web tại Outlook Dot Com ¶ ¶
4 năm trước
Making a bowl of raspberry natural yogurt.5
Making a bowl of raspberry natural yogurt.6
Making a bowl of raspberry natural yogurt.7
Making a bowl of raspberry natural yogurt.8
Making a bowl of raspberry natural yogurt.9
Hayley Watson ¶ ¶
5 năm trước
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 20
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 21
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 22
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 23
Sergio Santana: Ssantana tại tlaloc dot imta dot mx ¶ ¶
17 năm trước
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 24
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 25
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 26
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 27
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 28
3 days Catchable fatal error: Argument 2 passed to total_intervals[] must be an instance of DateInterval, null given, called in - on line 14 and defined in - on line 29
0
Making a bowl of raspberry natural yogurt.9
Catman tại esteticas dot se ¶ ¶
6 năm trước
2
3
Making a bowl of raspberry natural yogurt.9
Boan Dot Web tại Outlook Dot Com ¶ ¶
4 năm trước
5
6
7
8
9
Making a bowl of raspberry natural yogurt.3
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
01Hayley Watson ¶ ¶
5 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
02 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
03Making a bowl of raspberry natural yogurt.9
Hayley Watson ¶ ¶
5 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
05 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
06Making a bowl of raspberry natural yogurt.9
Sergio Santana: Ssantana tại tlaloc dot imta dot mx ¶ ¶
17 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
08 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
09 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
10 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
11 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
12Making a bowl of raspberry natural yogurt.9
Catman tại esteticas dot se ¶ ¶
JCAPLAN tại Bogus Dot Amazon Dot Com ¶
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
14 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
15 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
1616 năm trước ¶
1 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
17 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
18 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
19 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
20 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
21 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
22 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
23Making a bowl of raspberry natural yogurt.9
Gabriel tại FigDice Dot org ¶ ¶
6 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
25 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
26 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
27 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
28 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
29Boan Dot Web tại Outlook Dot Com ¶ ¶
4 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
30Hayley Watson ¶ ¶
1 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
31 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
32Making a bowl of raspberry natural yogurt.9
Gabriel tại FigDice Dot org ¶ ¶
4 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
34 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
35 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
36 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
37Making a bowl of raspberry natural yogurt.9
Hayley Watson ¶ ¶
5 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
39 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
40 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
41 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
42 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
43Making a bowl of raspberry natural yogurt.9
Sergio Santana: Ssantana tại tlaloc dot imta dot mx ¶ ¶
4 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
45 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
46 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
47 function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
48Hayley Watson ¶ ¶
5 năm trước
function dbInsert[$sql]{
$con = dbConnect[];
try {
// begin a transaction
mysqli_begin_transaction[$con];
foreach [$sql as $value] {
if [$con-> query[$value]] {
$insertID = $con-> insert_id;
} else {
trigger_error[mysqli_error[$con]];
}
}
// if no error, commit.
mysqli_commit[$con];
} catch [Exception $e] {
// if any error, catch the exception and rollback
mysqli_rollback[$con];
}
/* close connection and return the result */
$con->close[];
return $insertID;
}
49