Alzabo::QuickRef(3pm)
π¦ NAME π¦
Alzabo::QuickRef β a quick reference to methods in the Alzabo classes. yes bestie, it's literally the cheat sheet π
β¨
πΈ GENERAL πΈ
Okay so this reference is your lil pocket guide to some of the more commonly used methods that Alzabo hands you. And bonus: it also gives you an idea of which classes contain which types of methods, so when you're sitting there like "how do I even do this thing??" you actually know where to go look. π«Ά
π Alzabo, Alzabo::Create, and Alzabo::Runtime
These modules? Mostly they just get used to load other modules. That's it, that's the whole job. π
But Alzabo::Runtime has a lil glow-up: it can preload schemas at compile time by doing:
use Alzabo::Runtime qw( schema1 schema2 schema3 );
π Alzabo::MethodMaker
This module can be used to generate a whole bunch of useful convenience methods. How? By auto-generating methods in new packages and re-blessing some of the schema objects into those packages. lowkey iconic.
To have it generate all the possible methods for a schema, you'd do:
use Alzabo::MethodMaker ( schema => 'some_schema',
# Root for new packages
class_root => 'My::Data',
# Make all possible methods
all => 1 );
This will make convenience methods for things like getting table and column objects, following various types of foreign keys, and getting data from row objects. slay π
π₯ METHODS π₯
π Retrieving data
Alzabo::Runtime::Schema
This object lets you connect to the database. It contains several data retrieval methods, including join.
load_from_fileβ load an existing schema object from disk. Returns a new schema object. πset_user ($user)β set the username to be used when connecting to the database.set_password ($password)β set the password to be used when connecting to the database.set_host ($host)β set the host to be used when connecting to the database.connect (%params)β connect to the RDBMS. This will use the previously set username/password/host, though those can be overridden by the%paramsgiven to the call.
β οΈ Important: this method must be called before any data retrieval is attempted. no skipping, bestie, I mean it.
joinβ fetch rows from one or more tables based on a table join. Returns either anAlzabo::Runtime::RowCursororAlzabo::Runtime::JoinCursorobject.function/selectβ lets you execute arbitrary column aggregate SQL functions such asAVGorMAXwith a multi-table join.table ($name)β returns anAlzabo::Runtime::Tableobject. This one matters a lot, because most of the row fetching operations are table object methods. iykyk.
Alzabo::Runtime::Table
Objects in this class have methods that let you insert new rows and retrieve existing data in the form of Alzabo::Runtime::Row or Alzabo::Runtime::RowCursor objects.
- All methods that return a single row return an
Alzabo::Runtime::Rowobject. - All methods that return multiple rows return an
Alzabo::Runtime::RowCursorobject. - All methods that return rows can be given the
no_cacheparameter, which ensures that the row(s) returned will not be cached. Rows obtained this way should not be updated or deleted, because that will play havoc with the caching system. See theAlzabo::Runtime::Rowdocumentation for more details. - All methods that return multiple rows in the form of a cursor object can take an
order_byparameter. See theAlzabo::Runtime::Tabledocumentation for more details. insertβ insert a new row and return it. β¨row_by_pkβ returns the row identified by the primary key given.rows_whereβ retrieves a set of rows based on a where clause. Please see the method documentation for details on how where clauses are constructed.all_rowsβ retrieves all the rows in the table. every single one. π«Άfunction/selectβ lets you execute arbitrary column aggregate SQL functions such asAVGorMAX.potential_rowβ make a newAlzabo::Runtime::Rowin thepotentialstate.
Alzabo::Runtime::Row
Objects in this class represent a single row of data. You can retrieve the actual column values from it, update it, or delete it. main character energy, fr.
select (@list_of_column_names)β given a list of column names, this method returns the values for those columns.update (%hash_of_columns_and_values)β given a hash of columns and values, this method will update the database and the object to match those values.deleteβ deletes the row from the database. Further attempts to retrieve data from this row will throw an exception. π brutal but true.rows_by_foreign_keyβ given a foreign key object from the row's table to another table, returns either anAlzabo::Runtime::Rowobject or anAlzabo::Runtime::RowCursorobject for the row(s) in the table to which the relationship exists, based on the value of the relevant column(s) in the current row.
This method can also take a no_cache and/or order_by parameter.
Alzabo::Runtime::RowCursor
Objects in this class are used to return multiple rows as a cursor, rather than as a list. This is much more efficient β at the expense of a few extra lines in your code. trade-offs, bestie, we love efficiency π
nextβ returns the nextAlzabo::Runtime::Rowobject, orundefif there are no more.all_rowsβ returns a list of all the remainingAlzabo::Runtime::Rowobjects, or an empty list if there are no more.
π§ Creating/removing a schema
Alzabo::Create::Schema
This object represents a schema, and it contains one or more table objects. It's only used when creating or altering a schema, as opposed to when fetching data. Data manipulation happens via the Alzabo::Runtime::* classes.
reverse_engineerβ connect to a database and reverse engineer a schema. Returns a new schema object. π¦load_from_fileβ load an existing schema object from disk. Returns a new schema object.createβ if the schema has not yet been instantiated in an RDBMS, this method will instantiate the schema. If it has been previously instantiated, it will bring the schema in the RDBMS into sync with its object representation (altering tables/columns, etc.). Where possible, existing data will be preserved. π«Άmake_sqlβ returns an array, each element of which is a SQL statement. The SQL is either the SQL to create the schema from scratch or the SQL needed to update the RDBMS to match the current object. See thecreatemethod for more details.dropβ drop the database from the RDBMS where it was created. Does not remove the schema object itself from disk. careful, bestie πdeleteβ delete the schema object files from disk. Does not drop the database from the RDBMS.
π AUTHOR π
Dave Rolsky, <autarch@urth.org>
and that's the whole page, babe π this absolute gem is from perl v5.34.0, dated 2022-06-14 β go forth and query, you're gonna ate it ππΈβ¨
π¦ where this page comes from
- debian bookworm: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms