SQLSTATE[HY093]: Invalid parameter number: no parameters were bound
Khanh is a full stack web developer with over 15 years of experience developing for the web
Search for a command to run...
Khanh is a full stack web developer with over 15 years of experience developing for the web
No comments yet. Be the first to comment.
Elevate your bus reservation experience (or even movie, theater, train, ship, plane tickets) with the React Bus Seat Map Picker – a sophisticated and meticulously crafted script designed exclusively for bus seat bookings. Engineered with strict TypeS...

In previous blog, I migrated all posts from my WordPress to Hashnode at https://blog.donamkhanh.com. Now I create a simple landing page for my main domain and hosted on Github Page. You can access at https://donamkhanh.com. In feature, I'm going to h...

I just finished migrating my blog from Wordpress (self hosted on DigitalOcean) to Hashnode. How did I migrate? I don't have too many articles on Wordpress but I don't like doing it manually so the first thing I did was look to see if there was an aut...

Dự án mình đang làm có yêu cầu sử dụng Azure Active Directory (AAD) để lưu trữ thông tin người dùng & xác thực đăng nhập các kiểu. Ngoài các trường thông tin cơ bản mà AAD hỗ trợ ra thì dự án mình cần lưu thêm 1 số thông tùy chọn khác cho người dùng....

Introduction This is a concise front-end application developed with Angular. You can create a beautiful form with drag and drop visualization. You can get inspiration from it to make a draggable form; at the same time, you can also modify it to suit ...

Một lỗi củ chuối vừa bị dính ngày hôm qua. Chuỗi sql:
$value = $this->_db->quote($value); // output like ' test? \' special characters' $query = "UPDATE table_abc SET field_def = $value WHERE field_xyz = 123"; $this->_db->query($query);
Nếu chạy PHP phiên bản thấp hơn 5.2.7 thì sẽ bị lỗi SQLSTATE[HY093]: Invalid parameter number: no parameters were bound, do PDO parse sai placeholder dẫn đến bind param sai toét. Lỗi này xảy ra khi execute trực tiếp câu lệnh sql mà trong value của nó chứa đồng thời 2 ký tự question mark (?) và single quote (')
Trong ZF thì khắc phục đơn giản bằng cách sử dung Zend_Db update method (làm bừa nó lại ngon :()
$data = array('field_def' => $value); $this->_db->update('table_abc', $data, 'field_xyz = 123');
[Bổ sung] Ở đoạn code trên là xử lý cho trường hợp UPDATE, nếu trong trường hợp SELECT thì vẫn bị lỗi bind param, mặc dù dùng Zend_Db_Select. Cách giải quyết cực kỳ đơn giản, có thể fix được cho cả trường hợp UPDATE, đó là thay đổi lại setting của Zend_Db để nó không tự động bind param nữa:
$this->_db->getConnection()->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, false);
\======================================================= 1.^ Lỗi cụ thể xem tại: http://bugs.php.net/44251 2.^ http://www.php.net/ChangeLog-5.php, section 5.2.7 3.^ http://framework.zend.com/issues/browse/ZF-1343