Download the PHP package sirmekus/ahia without Composer

On this page you can find all versions of the php package sirmekus/ahia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ahia

Ahia

Ahia helps with database CRUD operation for a more robust and syntactic operation.

Installation

To get started all you need to do is:

and you're in. Ahia, in Igbo language, means "Market" and in context, a database is a "market place" with lots of 'items' (data) in it. Lol.


Usage


You don't have to craft [complicated] SQL queries in your script anymore and make your code more readable and clean. Welcome to the OOP way.

Using this package requires knowledge of our convention (it's not much. You don't have to learn anything new at all. Don't be scared...#winks). But first, to start using this feature you should import the Model class to your script like so:

By default you should create a .env (preferred) or env.php file that contains your database configurations. It is from this file that database configuration connection will be called and initialised. You should copy and place this in your root folder (with the exact keys):

or

We encourage you to store your core database connection config in a file as suggested above. However, you can choose to pass these configurations as aruments to the class like so:

Passing Name of Table

When using any of the CRUD methods in this class the last argument is always the name of the database table (as you'll soon see below). This is one way to always pass the name of the table at runtime.

Another way is by setting the public table property to the name of the table. Example:

And finally, you can specify the table to use by extending the Model class and giving the class the same name as the table. By default, if none of the above is specified this is used. The lower-case, snake-case name of the class will become the name of the database table to use. Example:

You can also, if you don't like our naming convention, set the public table property to the name of the table or pass it as argument to any of the CRUD methods. To get the name of your table simply call the getTable() method on an instance of Model or any class derived from it.

Please note that you should always set the table by passing the name as argument to any of the CRUD method when called or by setting it via the table property on an instantiated class if you use the Model class directly.


Examples

You can insert into table by using the insert() method of the class. This method expects a multi-dimensional array of data (specifying the table column(s) and appropriate value(s)) as first argument and an optional "table" parameter as second argument. Example:

You can also insert into the table by specifying dynamic properties at runtime, and then call the save() method. Example:

They all do the same work effectively. You may choose to, instead of always specifying your table, extend the Model class with the name of your table as actual class name and then run your operation using this extended class.


To update the table call the update() method, passing it an array of data (specifying the table column(s) and appropriate value(s)) as first argument, an optional array of "where" clause(s) as second argument and an optional "table name" as the final argument. Example:


Sometimes we will like to update a record if the record/row exists in the database else insert it. You can do this by calling the updateOrCreate() method, passing a key-value array specifying the where clause - the column(s) and key(s) that makes each record unique - as the first argument; key-value array containing the table's column-value as second argument (what should be inserted or created); and then an optional table as final argument. Example:

It searches the database for matching record using the first argument. If a record is found the table will be updated with the data provided in the second argument else a new record will be created by merging the first and second arguments.


To select from table simply call the select() method. This method accepts an optional array as first argument, like in the above cases, but with specific keys that have special meanings; an optional array of key-value (table "column=>value") "where" clause(s) as second argument; and an optional table as final argument.

Example:

or

The expected array keys in the first argument are optional and they are:


To count record simply use the count() method. The count() method works like the select() method above but the only possible array key is just the: column. Example:

In the above example, the 'column' is specified. This is useful since you can pass the same config array used in a select() method call to the count() method so that only the column key can be picked (as it is all it needs).

You can also specify a where clause via the second argument of the method. Example:

Or, if without the first argument then it will be:

Remember that the last argument is the name of the table to query, and it's an optional argument.


To delete a record simply call the delete() method and pass it an optional key-value array, like in other cases, as first argument and an optional table parameter value as final argument. Example:

Note that if you've already set dynamic properties and then call this method without passing the first argument the dynamic property, or properties, added will be considered and used as the "where" clause. Example:

Meanwhile

You can connect with me on LinkedIn for insightful tips and so we can grow our networks together.

Patronise us on Webloit.

And follow me on Twitter.

I encourage contribution even if it's in the documentation. Thank you, and I really hope you find this package helpful.


All versions of ahia with dependencies

PHP Build Version
Package Version
Requires sirmekus/zam Version >=2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sirmekus/ahia contains the following files

Loading the files please wait ....