php Test2

  1. API
    Application Programming Interface, or API, defines the classes, methods, functions and variables that your application will need to call in order to carry out its desired task.
  2. extension
    term - extension. The PHP code consists of a core, with optional extensions to the core functionality.
  3. MySQL-related extensions
    PHP's MySQL-related extensions, such as the mysqli extension, and the mysql extension, are implemented using the PHP extension framework.
  4. There are 3 main API options to connect to mysql.
    • Mysqli extension
    • Mysql extension:
    • Php Data Objects (PDO)
  5. Create object
    • Create a mysqli object,
    • connect to the MySQL server and open the database.
    • Returns true on success and false on failure.
  6. prepare
    • protect against dangerous data reaching the database server.
    • by separating the SQL from the user data and sending them separately to the server.  (Malicious data would be a text field containing Bugs Bunny; drop table patients;)
    • Prepared statements improve performance.
    • prepares the SQL statement for execution.
    • ? is used for user entered variables.
    • returns a mysqli_stmt object on success
    •      returns false on failure.
  7. bind_param method
    • binds the specified values (user entered variables) to the ?s in the prepare statement.
    • first parameter lists the data type of each ?
    • s=string/date, i=int/bool, d=double, b=BLOB
    • must be 1:1 ?s in prepare: variables in
    • bind_param.
  8. bind_result method
    • binds the columns in the result set (the table data) to the specified variables.
    • Returns true on success and
    •     false on failure.
  9. execute
    • The
    • prepared statement is combined with the parameters values (if supplied) and statement is executed.
    • Returns true on success,
    •     false on failure.
  10. fetch
    • Fetch or return the next available row from the query results and place the
    • data in the bound variables.
    • Prepared statements come as binary so
    • data types are recognized for what they are.
    • Returns false when all the rows have been returned.
    • A record pointer is used to keep track
    • of the current row.
  11. affected_rows
    Returns the number of rows that were added/changed in the last execute statement.
  12. close
    Close the prepared stmt object.
  13. mysqli_close($mysqlObj)
    Close the connection.
  14. error
  15. class
    • A class is a definition of an object. A class contains data and the routines (methods) required to manipulate the data
    • Defines attributes and methods of a particular type of object.
    • It is a blue print for an object
  16. object
    • An instance of the class.
    • Groups together data and routines in a data structure.
    • You can create more than one object from a single class.
  17. Attribute
    • One piece of data inside the class.
    • Also called property, class variable, data member.
    • Attributes should be declared as private or protected, where possible.
  18. Method
    • A function inside a class.
    • works on the attributes in the class to produce a result.
    • works on only one object at a time.
    • Also called property.
    • Visibility can be:
    •   private: only accessible by the class that defines it.
    •   protected: accessible only within class itself and its inherited classes.
    •   public (the default): can be accessed anywhere.
    • Functions cannot be overloaded.
    • To call a method: $objectname->methodname(parameter list)
  19. Constructor
    • A method that is automatically called when the object is created.
    • It is optional (but recommended) to add parameters to the constructor. These optional parameters can be used to assign initial values to the attributes when the object is created.
    • If the constructor throws an exception on error, the object will not be created.
  20. Destructor
    • A method that is automatically executed when an object is destroyed.
    • typically used to release resources.
    • example, closing a database connection.
  21. Coding Properties
    • property is used to access private attributes from outside a class.
    • A Get property returns the value of the attribute.
    • A Set property receives a value as a parameter and assigns that value to the attribute.
    • The parameter should be validated and only assigned to the attribute if valid.
    • A public property can be directly accessed by code outside of the class.
    • Private properties cannot be directly accessed by code outside the class.
    • Protected properties can only be accessed within the class itself and its inherited classes.
    • By default, properties are public.
    • Style: provide the access modifier
    •      (private, protected or public)
    • Within a class, variable $this is used to refer to the current object. It allows you to access the properties and methods of the current object.
    • The object access operator (->) is used to provide the access.
Author
slc53
ID
325679
Card Set
php Test2
Description
php test2
Updated