My Controller:  class Page extends CI_Controller {}  public function add() {     // $this-&gt;input-&gt;post('title')      $models = $this-&gt;load-&gt;model('Page_Model', 'page');      echo $models-&gt;page-&gt;insertData(); }   My Model:  class Page_model extends CI_Model {}  public function insertData() {     echo 'sdvsdf'; }   Error:  Fatal error: Call to a member function insertData() on a non-object in  I do not know what happened. Seems working correctly.
24549
So I'm refactoring my code to implement more OOP.  I set up a class to hold page attributes.  class PageAtrributes  {   private $db_connection;   private $page_title;      public function __construct($db_connection)      {         $this-&gt;db_connection = $db_connection;         $this-&gt;page_title = '';     }      public function get_page_title()     {         return $this-&gt;page_title;     }      public function set_page_title($page_title)     {         $this-&gt;page_title = $page_title;     } }   Later on I call the set_page_title() function like so  function page_properties($objPortal) {         $objPage-&gt;set_page_title($myrow['title']); }   When I do I receive the error message:     Call to a member function set_page_title() on a non-object   So what am I missing?
68431
Can any one explain the usage of controller and extensions in Visualforce? In which scenario we have to use controller and extensions?
111364
Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST)  Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue?
30396
I'm programmatically creating a user with the following code.  $newUser = array(   'name' =&gt; $mail,    'pass' =&gt; 'password',  // note: do not md5 the password   'mail' =&gt; $mail,    'status' =&gt; 1,    'init' =&gt; $mail,   'roles' =&gt; array(5) ); $user = user_save(null, $newUser);   I have got a role with the role ID equal to 5; when I create the user, in the table "users_roles" there is only a row with the value 0 for the role ID, but if I print the user object with var_dump(), it looks like the roles are created.  What am I doing wrong?
29173
How do you solve the following error when creating a simple post?     It looks like your post is mostly code; please add some more details
99243
I have a view with a few different displays, each of them with slightly overridden filters, like this one used in a panel.  How do you add this pseudocode via the UI?  AND (node.type='story' OR node.comment_count &gt;=1)   I found an article (), but I still don't know what to do.  What does the following code do, and what is "advf_filter"?  if ($view-&gt;name == 'YOURVIEW') {   $view-&gt;query-&gt;add_where('advf_filter',"(node.type='%s' OR node_comment_statistics.comment_count &gt;= %d)",'forum',1);   $view-&gt;query-&gt;set_group_operator('AND'); }
50564
In Drupal 7 module development, I could include a custom inc, api, or php class file using the  directive in the module.info file or the drupal_load_included() function.   With D8 using PSR, what is the proper way to package up a "plain ole PHP object" and reference it in DefaultController.php? Think something like: $a = new POPO();.  Is just giving the PHP file containing the class a namespace sufficient? How does the controller (or module in general) know to reference or scan for that class?
76431
When I load script/console, sometimes I want to play with the output of a controller or a view helper method.  Are there ways to:   simulate a request? call methods from a controller instance on said request? test helper methods, either via said controller instance or another way?
101111
We've had a community deployment and my brain is fried and I just whipped up a quick class that is throwing the below error. What have I done wrong here?     Error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MSI_UserTrigger:   execution of AfterInsert caused by: System.StringException: Invalid   id: () : [] () : []: ()   What I am trying to accomplish is:   When a new user is created and is active, if they are linked to a ContactId and part of a specific profile (by name), add their ContactId to a Set&lt;ID> Then loop through contacts where the Id is in the set, and update the Community_User__c field to TRUE      Trigger:   trigger MSI_UserTrigger on User (after insert) {       if(Trigger.isAfter){          if(Trigger.isInsert){              MSIUserTriggerHandler.executeAfterInsert(Trigger.new);          }      } }      Class:   public with sharing class MSIUserTriggerHandler {     private static final String COMMUNITY_PROFILE = 'Community Knowledge User';     private MSIUserTriggerHandler() {}      public static void executeAfterInsert(List&lt;User&gt; newList){         setCreatedCommunityUsers(newList);     }      private static void setCreatedCommunityUsers(List&lt;User&gt; newList){         List&lt;User&gt; usersWithContacts = new List&lt;User&gt;();         List&lt;Contact&gt; contactsToUpdate = new List&lt;Contact&gt;();         Set&lt;ID&gt; contactIds = new Set&lt;ID&gt;();          for(User u: newList){             if(u.ContactId == null &amp;&amp; u.ContactId == ''){                 continue;             }             if((u.ContactId != null &amp;&amp; u.ContactId != '') &amp;&amp; u.Profile.Name == COMMUNITY_PROFILE &amp;&amp; u.isActive == true){                 contactIds.add(u.ContactId);             }         }          for(Contact c : [Select Id,Name,Community_User_Created__c from Contact where Id in :contactIds]){             if(!c.Community_User_Created__c){                 c.Community_User_Created__c = true;                 contactsToUpdate.add(c);             }         }         update contactsToUpdate;     } }   Am I not adding the ID correctly to the Set&lt;ID>, or am I querying wrong in my for(Contacts) loop?
73749
I am doing a tutorial and am getting this error:     Fatal error: Class 'MySQLi' not found (LONG URL) on line 8   The code on line 8 is:  $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);   I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".  Also, I am running PHP version 5.2.5
112390
Is there a list describing all of the data_type parameters you can use in PDOStatement::bindParam() ? If none, what do you commonly use, and for what type of field ?  According to PHP manual: data_type Explicit data type for the parameter using the PDO::PARAM_* constants.   I know about the PDO::PARAM_INT and PDO::PARAM_STR . I've heard of PDO::PARAM_LOB but I wasn't sure how and when to use that, though. (for date ?)
58950
In views I can add PHP snippets for custom validation or when I want to provide default value for contextual filter. It is telling me that I can use $view or $argument - but where is documentation of these objects? Where can I read what are my possibilities in these areas (or how check this, by using debugger for example)?
54950
I am using the following line in a controller class.      \Drupal::moduleHandler()-&gt;alter('mymodule_myfunction', $plugin_items);   Pareview.sh is giving me this error message.     \Drupal calls should be avoided in classes, use dependency injection instead.   How should I accomplish this? Do I need to create a constructor, create a method, or a service? If so, what code should the service need? I found an example on  for a case where a service already exists.
18084
Im creating a visit/page views counter with ajax,jquery and php, I have been reading a few articles that recommend the use of nonces for data manipulation through ajax, however i am not sure if i need to integrate the use of nonces for my simple counter?  my code looks somewhat like this;  jquery  jQuery.ajax({         type: 'POST',         url: ajaxurl,         data: {action: 'countHits', status: 'true'},         });   php  //ajax functions add_action('wp_ajax_countHits', 'countHits'); add_action('wp_ajax_nopriv_countHits', 'countHits'); function countHits() {      if($_POST['status'] != "") {        $status= $_POST['status'];      if(!isset($_COOKIE['UNIQUEUSER'] &amp;&amp; $status == 'true'){        $uniqueUser= get_option('stats');        $uniqueUser['uniqueUser']+=1;        update_option('stats', $uniqueUser);     } die();  }   So as you can see it is very simple, do I need to use nonces for each ajax request?(i have two separate request in my jquery which return variables one for false one for true) furthermore, if I wanted to implement nonces how would i go about doing that?
121895
I have a trigger and a class that seem to be causing an insert fail in Dataloader.  I am trying to insert 200 records to see if an error is generated before moving these to production. I'm just inserting the mandatory fields such as Name, Owner, Market, Customer_Success_Manager__c, and Business Unit.   Each time I get an error:     UpdateCSMTeam:execution of AfterInsertcaused by: System.DmlException:   Insert failed. First exception on row 0 with id01MJ0000009gXthMAE;   first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an   insert call: [Id]Class.UpdateCSM.updateTeamMem . I've listed the class   and trigger below.   APEX CLASS  public class UpdateCSM {             public static void updateTeamMember(List&lt;Account&gt; accounts) {                     List&lt;AccountShare&gt; ashareLIST = new List&lt;AccountShare&gt;();                     List&lt;AccountTeamMember&gt; ATM = new List&lt;AccountTeamMember&gt;();                    Set&lt;String&gt; rmMember = new Set&lt;String&gt;();                     Map&lt;ID, ID&gt; acctToBRepMap = new Map&lt;ID, ID&gt;();                      for(Account a:accounts){                              AccountShare caSharingRule = new AccountShare();                                caSharingRule.AccountId = a.Id;                                caSharingRule.OpportunityAccessLevel = 'Edit';                                caSharingRule.CaseAccessLevel = 'Edit';                                caSharingRule.AccountAccessLevel = 'Edit';                                caSharingRule.UserOrGroupId = a.Customer_Success_Manager__c;                                ashareLIST.add(caSharingRule);                                    if(a.Customer_Success_Manager__c!= null){                                   AccountTeamMember Teammemberad=new AccountTeamMember();                 Teammemberad.AccountId=a.id;                 Teammemberad.UserId=a.Customer_Success_Manager__c;                 Teammemberad.TeamMemberRole = 'Customer Success Manager';                                   ATM.add(Teammemberad);                             if(!ATM.isEmpty()){                                    insert ATM;                                              insert ashareLIST;                                                         if(a.Customer_Success_Manager__c==null){                                            list&lt;AccountTeamMember&gt; ratm = [SELECT UserId                                                                             FROM AccountTeamMember                                                                             WHERE (TeamMemberRole = 'Customer Success Manager')                                                          AND AccountId =:a.id];                                             if(ratm.size()&gt;0)                                                 delete ratm;                                        }                                    }                                 }                            }                         }                    } ...   APEX TRIGGER  trigger UpdateCSMTeam on Account (After update, After insert){         UpdateCSM.updateTeamMember(trigger.new); }
73868
I need help. I am currently trying to test this code before uploading  public class CoreValuesExt { ApexPages.StandardController sc; public boolean readonly {get; set;} public Core_Values__c cv {get; set;} public integer countEdit = 1; public string buttonValue {get; set;} public integer recordScan;  public CoreValuesExt(ApexPages.StandardController sc) {     this.sc = sc;     cv = new Core_Values__c();     cv.Account__c = sc.getid();      readonly = true;     buttonValue = 'Edit';     recordScan = [SELECT COUNT() FROM Core_Values__c WHERE Account__c = :cv.Account__c];    if (recordScan != 0){    cv = [SELECT id, HSE__c, Professionalism_Integrity__c, Quality_Accuracy__c, Technology_Innovation__c, Timeliness__c, Value_for_money__c FROM Core_Values__c WHERE Account__c = :cv.Account__c];     }  }  public ApexPages.PageReference Save() {     return sc.Save(); }  public void ApplyAction() {     countEdit++;     Integer modolus = Math.mod(countEdit, 2);     String total = cv.HSE__c + cv.Professionalism_Integrity__c + cv.Quality_Accuracy__c + cv.Technology_Innovation__c + cv.Value_for_Money__c + cv.Timeliness__c;     if(modolus == 0)     {         readonly = false;         buttonValue = 'Save';     }     else     {         if(total != 'nullnullnullnullnullnull')            {         if (recordScan == 0){         insert cv;         readonly = true;         buttonValue = 'Edit';         }         else         {         update cv;         readonly = true;         buttonValue = 'Edit';         }         }     }    }   }  With this trigger.  trigger CoreValuesTrigger on Core_Values__c (before insert) {  Core_Values__c cvs = Trigger.new; CoreValuesExt.ApplyAction(cvs);  }   But when I try to save, I get a message saying:      Illegal assignment from List to   CoreValuesExt__Core_Values__c at line 3 column 1   "  How do I go through with this? I need help. Thanks
101459
I'm doing some polymorphic programming, and I decided that I wanted to be able to gracefully handle partial saves using SaveResult without blocking the user experience. The code looks roughly like this:  static void logDmlErrors(SObject[] src, SObject[] dest, SaveResult[] results, String message) {     // Transform results into Chatter error messages, send them to admins }   I then went about writing the utility methods that would use this function:  public static void insertRecords(SObject[] src, SObject[] dest, String message) {     logDmlErrors(src, dest, Database.insert(dest, false), message); }   Everything went well, until I came across the delete and undelete methods, which instead use DeleteResult and UndeleteResult. Both of those two classes contain the exact same methods as SaveResult, and yet don't appear to inherit from a common ancestor. This means that I can't just cast to a super-type to get to this information.  Thankfully, Summer 16 apparently introduced support for serializing (and deserializing) these classes as JSON, so I do have a fairly expensive (but accurate) workaround if I want proper polymorphic behavior, but I thought I'd throw it out there and see if someone has an alternative solution to this problem.