php - Call to a member function fetchAll() on a non-object -


इस सवाल का पहले से ही एक उत्तर है: < / p>

  • 8 जवाब

    मुझे पता नहीं क्यों एक गैर-ऑब्जेक्ट त्रुटि पर सदस्य फ़ंक्शन फ़ेच करें () को कॉल करें क्योंकि मैं _sth ऑब्जेक्ट पर fetchAll विधि का उपयोग कर रहा हूं।

    क्या कोई यह जानता है कि यह ऐसा क्यों करता है?

    FormValidator PHP

      $ users = $ this- & gt; _db- & gt; क्वेरी ("SELECT * FROM $ ruleValue $ input = ? ", सरणी ($ inputValue)); अगर ($ उपयोगकर्ता- & gt; गिनती ()) {$ this- & gt; addError ($ इनपुट, $ नियम); }   

    विधि

      सार्वजनिक फ़ंक्शन क्वेरी ($ sql, $ params = array ()) {$ this- & gt; _sth = $ this- & gt; _dbh- & gt; तैयार ($ sql); अगर ($-> यह- & gt; _sth = $- >- ($ params)) निष्पादित करें ($ params)) {वापसी $ this- & gt; _sth- & gt; फैल सभी (PDO :: FETCH_OBJ); } विवरण झूठा है; }    

      यदि ($ this- & gt; _sth = $ this- & gt ; _sth- & gt; निष्पादित करें ($ params)) <  

    एकल = एक असाइनमेंट ऑपरेटर है execute () एक बूलियन TRUE या FALSE देता है, और आप यह निर्दिष्ट कर रहे हैं कि $ this-> _sth

      वापसी $ इस- & gt; _sth- & gt; fetchAll (पीडीओ :: FETCH_OBJ);   

    न तो सही और न ही कोई वस्तु है, और कोई fetchAll () विधि नहीं है।

    @RocketHazmat से टिप्पणी सही है, आप execute () बिना के _trh को निर्दिष्ट करने के बदले मूल्य का परीक्षण कर सकते हैं। उदाहरण:

      यदि ($ this- & gt; _sth- & gt; निष्पादित करें ($ params)) {वापसी $ this- & gt; _sth- & gt; प्राप्त करें सभी (PDO :: FETCH_OBJ); }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -