====== LanguageDao ======
**Layer:** ''DAO'' · **Source:** ''lib/dao/LanguageDao.php:22'' (lines 22–198)
----
class LanguageDao extends Dao
LanguageDao
Data Access Object for the `tbl_languages` table. Handles CRUD for the
supported languages (en, ar, zh, fr, ru, es, id), the active/default
language lookups, and language code uniqueness checks.
======= Docblock Metadata =======
^ Tag ^ Value ^
| ''@category'' | DAO Class |
| ''@author'' | M.Noermoehammad |
| ''@license'' | MIT |
| ''@version'' | 1.0 |
| ''@since'' | Since Release 1.0 |
======= Inheritance =======
^ Relation ^ Type ^ Meaning ^
| extends | [[scriptlog:lib:core:dao|''Dao'']] | parent class/interface |
======= Constants (0) =======
//None.//
======= Properties (0) =======
//None declared.//
======= Methods (11) =======
^ Visibility ^ Method ^ Summary ^ Line ^
| public | ''createLanguage()'' | Create a new language record. | 44 |
| public | ''findById()'' | Find a language record by its primary key. | 66 |
| public | ''findLanguageByCode()'' | Find a language record by its unique language code. | 79 |
| public | ''findActiveLanguages()'' | Find all active language records. | 94 |
| public | ''findDefaultLanguage()'' | Find the default language record. | 108 |
| public | ''updateLanguage()'' | Update an existing language record. | 125 |
| public | ''setDefaultLanguage()'' | Mark a language as the site's default. | 140 |
| public | ''deleteLanguage()'' | Delete a language record by its primary key. | 152 |
| public | ''countLanguages()'' | Count all language records. | 162 |
| public | ''codeExists()'' | Check whether a language code already exists. | 177 |
| public | ''findAllLanguages()'' | Find all language records, active or not. | 192 |
======== createLanguage() ========
public function createLanguage(array $data): int
//lines 44–58 (15)//
Create a new language record.
The `lang_code` value is normalized to lowercase before persistence.
Optional keys fall back to sensible defaults when omitted:
`lang_locale` (null), `lang_direction` ('ltr'),
`lang_sort` (0), `lang_is_default` (0), `lang_is_active` (1).
^ Parameter ^ Type ^ Default ^ Description ^
| ''$data'' | ''array'' | //required// | //none// |
**Returns:** ''int'' — int The ID of the newly created language record
======== findById() ========
public function findById(int $id): ?array
//lines 66–71 (6)//
Find a language record by its primary key.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$id'' | ''int'' | //required// | The language ID |
**Returns:** ''?array'' — array|null The language row, or null when not found
======== findLanguageByCode() ========
public function findLanguageByCode(string $code): ?array
//lines 79–84 (6)//
Find a language record by its unique language code.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$code'' | ''string'' | //required// | The language code, e.g. 'en' or 'ar' |
**Returns:** ''?array'' — array|null The language row, or null when not found
======== findActiveLanguages() ========
public function findActiveLanguages(): array
//lines 94–101 (8)//
Find all active language records.
Results are ordered by `lang_sort` ascending, then by `lang_name`
ascending. Only languages with `lang_is_active = 1` are returned.
//Takes no parameters.//
**Returns:** ''array'' — array> List of active language rows
======== findDefaultLanguage() ========
public function findDefaultLanguage(): ?array
//lines 108–113 (6)//
Find the default language record.
//Takes no parameters.//
**Returns:** ''?array'' — array|null The language marked as default, or null when none exists
======== updateLanguage() ========
public function updateLanguage(int $id, array $data): void
//lines 125–128 (4)//
Update an existing language record.
Only the columns present in `$data` are modified; unknown keys are
ignored by the database wrapper.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$id'' | ''int'' | //required// | The language ID to update |
| ''$data'' | ''array'' | //required// | //none// |
**Returns:** ''void'' — void
======== setDefaultLanguage() ========
public function setDefaultLanguage(int $id): void
//lines 140–144 (5)//
Mark a language as the site's default.
This is a two-step operation: first the `lang_is_default` flag is
cleared on every language record, then it is set to 1 for the given
language ID, guaranteeing exactly one default at a time.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$id'' | ''int'' | //required// | The language ID to promote to default |
**Returns:** ''void'' — void
======== deleteLanguage() ========
public function deleteLanguage(int $id): void
//lines 152–155 (4)//
Delete a language record by its primary key.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$id'' | ''int'' | //required// | The language ID to delete |
**Returns:** ''void'' — void
======== countLanguages() ========
public function countLanguages(): int
//lines 162–167 (6)//
Count all language records.
//Takes no parameters.//
**Returns:** ''int'' — int The total number of languages
======== codeExists() ========
public function codeExists(string $code): bool
//lines 177–182 (6)//
Check whether a language code already exists.
Useful for uniqueness validation before insert or update operations.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$code'' | ''string'' | //required// | The language code to check, e.g. 'en' |
**Returns:** ''bool'' — bool True when the code already exists, false otherwise
======== findAllLanguages() ========
public function findAllLanguages(): array
//lines 192–197 (6)//
Find all language records, active or not.
Results are ordered by `lang_sort` ascending, then by `lang_name`
ascending. This is the admin-panel counterpart of `findActiveLanguages()`.
//Takes no parameters.//
**Returns:** ''array'' — array> List of all language rows
======= Imports =======
^ Alias ^ Fully-qualified name ^
| ''Dao'' | [[scriptlog:lib:core:dao|''Scriptlog\Core\Dao'']] |
----
//This page is generated from source by 'tools/gendoc'. Edits will be overwritten.//