Skip to content

Commit

Permalink
* 2.9 2021-02-16 see README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecc committed Feb 16, 2021
1 parent 36661eb commit d8bd31a
Show file tree
Hide file tree
Showing 34 changed files with 592 additions and 237 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1946,9 +1946,12 @@ In a nutshell:
* Every decimal version means that it patches/fixes/refactoring a previous functionality i.e. 1.5.0 -> 1.5.1 (fix)



* 2.9 2021-02-16
* BasePdoOneRepo::getPdoOne() validates if the static class uses the right version. It is only done once
(when it creates the instance of pdoOne), so it must not affects the performance.
* **You should re-generate all ORM classes generated (if you are generated one)**
* **2.8** 2021-02-13
* Updated _BasePdoOneRepo to 4.13
* Updated _BasePdoOneRepo to 4.13. **You should re-generate all ORM classes generated (if you are generated one)**
* 2.7.1 2021-01-21
* Oracle is still a WIP (OCI)
* **2.7** 2021-01-10
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eftec/pdoone",
"description": "Procedural PDO Data access class in a single Class",
"version": "2.8",
"version": "2.9",
"type": "library",
"keywords": [
"dao",
Expand Down
71 changes: 48 additions & 23 deletions examples/repomysql/generated/AbstractTableCategoryRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Exception;

/**
* Generated by PdoOne Version 2.1 Date generated Fri, 14 Aug 2020 16:47:00 -0400.
* Generated by PdoOne Version 2.8 Date generated Tue, 16 Feb 2021 10:15:08 -0300.
* DO NOT EDIT THIS CODE. Use instead the Repo Class.
* @copyright (c) Jorge Castro C. MIT License https://github.com/EFTEC/PdoOne
* Class AbstractTableCategoryRepo
Expand All @@ -27,11 +27,13 @@
abstract class AbstractTableCategoryRepo extends TestDb
{
const TABLE = 'TableCategory';
const COMPILEDVERSION=3;
const IDENTITY = NULL;
const PK = [
'IdTableCategoryPK'
];
const ME=__CLASS__;
CONST EXTRACOLS='';
const EXTRACOLS='';

/**
* It returns the definitions of the columns<br>
Expand All @@ -41,8 +43,9 @@ abstract class AbstractTableCategoryRepo extends TestDb
* self::getDef('sql'); // ['colName'=>'sql','colname2'=>'sql2']
* self::getDef('identity',true); // it returns the columns that are identities ['col1','col2']
* </pre>
* <b>PHP Types</b>: binary, date, datetime, decimal,int, string,time, timestamp<br>
* <b>PHP Conversions</b>: datetime3 (human string), datetime2 (iso), datetime (datetime class), timestamp (int), bool, int, float<br>
* <b>PHP Types</b>: binary, date, datetime, decimal/float,int, string,time, timestamp<br>
* <b>PHP Conversions</b>: datetime (datetime class), datetime2 (iso),datetime3 (human string)
* , datetime4 (sql no conversion!), timestamp (int), bool, int, float<br>
* <b>Param Types</b>: PDO::PARAM_LOB, PDO::PARAM_STR, PDO::PARAM_INT<br>
*
* @param string|null $column =['phptype','conversion','type','size','null','identity','sql'][$i]
Expand Down Expand Up @@ -92,11 +95,14 @@ public static function getDef($column=null,$filter=null) {

/**
* It converts a row returned from the database.<br>
* If the column is missing then it sets the null value.
* If the column is missing then it sets the field as null.
*
* @param array $row [ref]
*/
public static function convertOutputVal(&$row) {
if($row===false || $row===null) {
return;
}
$row['IdTableCategoryPK']=isset($row['IdTableCategoryPK']) ? (int)$row['IdTableCategoryPK'] : null;
!isset($row['Name']) and $row['Name']=null; // varchar

Expand Down Expand Up @@ -152,12 +158,12 @@ public static function getDefNoInsert() {
*/
public static function getDefNoUpdate() {
return [

'IdTableCategoryPK'
];
}

/**
* It adds a where to the income query. It could be stacked with more where()<br>
* It adds a where to the query pipeline. It could be stacked with many where()
* <b>Example:</b><br>
* <pre>
* self::where(['col'=>'value'])::toList();
Expand All @@ -172,7 +178,7 @@ public static function getDefNoUpdate() {
*/
public static function where($sql, $param = PdoOne::NULL)
{
self::getPdoOne()->where($sql, $param);
self::getPdoOne()->where($sql, $param,false,TableCategoryRepo::TABLE);
return TableCategoryRepo::class;
}

Expand Down Expand Up @@ -219,23 +225,32 @@ public static function getRelations($type='all') {

}

public static function toList($filter=null,$filterValue=null) {
public static function toList($filter=PdoOne::NULL,$filterValue=null) {
if(self::$useModel) {
return TableCategoryModel::fromArrayMultiple( self::_toList($filter, $filterValue));
}
return self::_toList($filter, $filterValue);
}

/**
* It sets the recursivity.<br>
* It sets the recursivity. By default, if we query or modify a value, it operates with the fields of the entity.
* With recursivity, we could use the recursivity of the fields, for example, loading a MANYTOONE relation<br>
* <b>Example:</b><br>
* <pre>
* self::setRecursive([]); // (default) no use recursivity.
* self::setRecursive('*'); // recursive every MANYTOONE,ONETOONE,MANYTOONE and ONETOONE relations (first level)
* self::setRecursive('MANYTOONE'); // recursive all relations of the type MANYTOONE (first level)
* self::setRecursive(['_relation1','_relation2']); // recursive only the relations of the first level
* self::setRecursive(['_relation1','_relation1/_subrelation1']); // recursive the relations (first and second level)
* </pre>
* If array then it uses the values to set the recursivity.<br>
* If string then the values allowed are '*', 'MANYTOONE','ONETOMANY','MANYTOMANY','ONETOONE' (first level only)<br>
*
* @param string|array $recursive=self::factory();
*
* @return TableCategoryRepo
* {@inheritDoc}
*/
public static function setRecursive($recursive)
public static function setRecursive($recursive=[])
{
if(is_string($recursive)) {
$recursive=TableCategoryRepo::getRelations($recursive);
Expand All @@ -253,10 +268,10 @@ public static function limit($sql)
* It returns the first row of a query.
* @param array|mixed|null $pk [optional] Specify the value of the primary key.
*
* @return array|bool
* @return array|bool It returns false if not file is found.
* @throws Exception
*/
public static function first($pk = null) {
public static function first($pk = PdoOne::NULL) {
if(self::$useModel) {
return TableCategoryModel::fromArray(self::_first($pk));
}
Expand Down Expand Up @@ -343,36 +358,46 @@ public static function deleteById($pk,$transactional=true) {
}

/**
* Initialize an empty array with default values (0 for numbers, empty for string, and array|null if recursive)
*
* @param string $recursivePrefix It is the prefix of the recursivity.
* Returns an array with the default values (0 for numbers, empty for string, and array|null if recursive)
*
* @param array|null $values =self::factory()
* @param string $recursivePrefix It is the prefix of the recursivity.
*
* @return array
*/
public static function factory($recursivePrefix='') {
public static function factory($values = null, $recursivePrefix = '') {
$recursive=static::getRecursive();
static::setRecursive(); // reset the recursivity.
$row= [
'IdTableCategoryPK'=>0,
'_TableParentxCategory'=>(in_array($recursivePrefix.'_TableParentxCategory',$recursive,true))
? []
: null, /* ONETOMANY! */
'Name'=>''
];


if ($values !== null) {
$row = array_merge($row, $values);
}
return $row;
}

/**
* Initialize an empty array with null values
* It returns an empty array with null values and no recursivity.
* @param array|null $values=self::factoryNull()
*
* @return null[]
* @return array
*/
public static function factoryNull() {
return [
public static function factoryNull($values=null) {
$row= [
'IdTableCategoryPK'=>null,
'_TableParentxCategory'=>null, /* ONETOMANY! */
'Name'=>null
];
if ($values !== null) {
$row = array_merge($row, $values);
}
return $row;
}

}
Loading

0 comments on commit d8bd31a

Please sign in to comment.