.. _php-useobjectapi: .. _use-php-object-api: Use PHP Object API ++++++++++++++++++ OOP API is the modern version of the PHP API. When PHP offers the alternative between procedural and OOP api for the same features, it is recommended to use the OOP API. Often, this least to more compact code, as methods are shorter, and there is no need to bring the resource around. Lots of new extensions are directly written in OOP form too. OOP / procedural alternatives are available for `mysqli `_.php>`_, `tidy `_.php>`_, `cairo `_, `finfo `_, and some others. .. code-block:: php connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } /* Create table doesn't return a resultset */ if ($mysqli->query("CREATE TEMPORARY TABLE myCity LIKE City") === TRUE) { printf("Table myCity successfully created.\n"); } /* Select queries return a resultset */ if ($result = $mysqli->query("SELECT Name FROM City LIMIT 10")) { printf("Select returned %d rows.\n", $result->num_rows); /* free result set */ $result->close(); } ?> Connex PHP features ------------------- + `object-api `_ Suggestions ___________ * Use the object API Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Php/UseObjectApi | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Changed Behavior ` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Slow (1 hour) | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ClearPHP | `use-object-api `__ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-wordpress-php-useobjectapi`, :ref:`case-prestashop-php-useobjectapi` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+