diff --git a/README.md b/README.md
index b49389f..facc0a6 100644
--- a/README.md
+++ b/README.md
@@ -1686,7 +1686,7 @@ The nested operators are methods that should be in between of our chain of metho
> ClassRepo::op()::where()::finalop() is ✅
>
-> ClassRepo::op()::op()::where() will left the chain open ❌
+> ClassRepo::op()::op()::where() will leave the chain open ❌
For example:
@@ -1862,7 +1862,8 @@ In a nutshell:
> Every minor version means that it adds a new functionality i.e. 1.5 -> 1.6 (new methods)
>
> Every decimal version means that it patches/fixes/refactoring a previous functionality i.e. 1.5.0 -> 1.5.1 (fix)
-
+* 4.3.3 2023-09-05
+ * change the PHPDOC comments, now it uses markdown instead of "pre" tag.
* 4.3.2 2023-09-05
* A small fix with the error messages, now on level 1 it shows the cause of the error.
* 4.3.1 2023-09-02
@@ -2079,7 +2080,7 @@ it as a PHP file.
*
* **_BasePdoOneRepo** now works more closely with the class **PdoOneQuery**, so each query is a different instance.
- * **[fix]** **PdoOne** dateConvertInput() does not crashes when the value is not a date.
+ * **[fix]** **PdoOne** dateConvertInput() does not crash when the value is not a date.
* **[fix]** **PdoOne** throwError() does not stack errors but still triggers the last error (if any).
@@ -2267,7 +2268,7 @@ echo $this->internalCacheCounter;
the type. It also allows many other different kind of combinations.
* Before: **$this->runRawQuery($sql,['i',20,'s','hello]);**
* Now: **$this->runRawQuery($sql,[20,'hello']);**
- * Also (named): **$this->runRawQuery($sql,['col1'=>20,'col2'=>'hello']);**
+ * Also, (named): **$this->runRawQuery($sql,['col1'=>20,'col2'=>'hello']);**
* Since it is a core change, then former code that uses the version 1.x could not be compatible without changing all
references to methods that use arguments specifying the types.
* runRawQuery()
diff --git a/lib/PdoOne.php b/lib/PdoOne.php
index 6907a59..275e750 100644
--- a/lib/PdoOne.php
+++ b/lib/PdoOne.php
@@ -336,10 +336,10 @@ public static function newColFK($key, $refcol, $reftable, $extra = null, $name =
/**
* We clean a sql that it could contain columns
* Example:
- *
+ * ```php * PdoOne::cleanColumns("col1,col2"); // col1,col2 * PdoOne::cleanColumns("col1';,col2"); // col1;,col2 - *+ * ``` * @param string $sql * @return array|string|string[] */ @@ -465,9 +465,9 @@ public static function dateTimeSql2PHP(string $sqlField, bool &$hasTime = false) /** * It converts a date (as string) into another format or false if it fails.
+ * ```php * $pdoOne->dateConvert('01/01/2019','human','sql'); // 2019-01-01 - *+ * ``` * iso it is the standard format used for transporting
+ * ```php * $r=PdoOne::dateConvertInput('01/12/2020','human',$ms,$time); // it depends on the fields self::$date*HumanFormat * $r=PdoOne::dateConvertInput('2020-12-01','iso',$ms,$time); // it depends on the fields self::$date*Format * $r=PdoOne::dateConvertInput('2020-12-01','sql',$ms,$time); // it depends on the database * $r=PdoOne::dateConvertInput(50000,'timestamp',$ms,$time); // a timestamp * $r=PdoOne::dateConvertInput(new DateTime(),'class',$ms,$time); // a DateTime object (it keeps the same one) - *+ * ``` * * @param mixed $inputValue the input value. * @param string $inputFormat =['iso','human','sql','class','timestamp'][$i] The input format @@ -829,12 +829,12 @@ public static function tableCase(?string $txt) * It converts a name to singular. This method is used automatically for the generation of the repository * classes
+ * ```php * self::singularTable('categories'); // category * self::singularTable('churches'); // church * self::singularTable('prices'); // pric (it fail with this kind of cases) * self::singularTable('users'); // user - *+ * ``` * @param $tableName * @return false|mixed|string */ @@ -940,11 +940,11 @@ public function validateDefTable(string $table, array $defArray, $defKeys, array *
+ * ```php * $this->getDefTable('tablename',$conversion); * // ['col1'=>['alias'=>'','phptype'=>'int','conversion'=>null,'type'=>'int','size'=>null * // ,'null'=>false,'identity'=>true,'sql'='int not null auto_increment' - *+ * ``` * * @param string $table The name of the table * @param array|null $specialConversion An associative array to set special conversion of values with the key as the @@ -999,10 +999,10 @@ public function getDefTable(string $table, ?array $specialConversion = null): ar /** * It converts a sql type into a 'php type' and a pdo::param type
+ * ```php * $this->dbTypeToPHP('varchar'); // ['string',PDO::PARAM_STR] * $this->dbTypeToPHP('int'); // ['int',PDO::PARAM_INT] - *+ * ``` * PHP Types: binary, date, datetime, decimal,int, string,time, timestamp
+ * ```php * $this->getDefTableKeys('table1'); * // ["IndexName"=>'',"ColumnName"=>'',"is_unique"=>0,"is_primary_key"=>0,"TYPE"=>''] - *+ * ``` * * @param string $table The name of the table to analize. * @param bool $returnSimple true= returns as a simple associative @@ -1139,11 +1139,11 @@ public function getDefTableFK(string $table, bool $returnSimple = true, bool $as * The results of the table depend on the kind of database. For example, sqlsrv returns the schema used (dbo), * while mysql returns the current schema (database). * Example:
+ * ```php * $this->getDefTableExtended('table'); // ['name','engine','schema','collation','description'] * $this->getDefTableExtended('table',true); // "some description of the table" * - *
+ * ```php * $values=$con->runRawQuery('select * from table where id=?',[20]',true); // with parameter * $values=$con->runRawQuery('select * from table where id=:name',['name'=>20]',true); // with named parameter * $values=$con->runRawQuery('select * from table,[]',true); // without parameter. @@ -1777,13 +1777,13 @@ public function runRawQuery(string $rawSql, ?array $params = null, ?bool $return /** * It returns the sql command (in lower case) or the type (family) of sql command of a query
* Example:
- *+ * ```php * $this->queryCommand("select * from table") // returns "select" * $this->queryCommand("select * from table",true) // returns "dql" - *+ * ``` * * @param string $sql - * @param false $returnType if true then it returns DML (insert/updat/delete/etc) or DQL (select/show/display) + * @param false $returnType if true then it returns DML (insert/updat/delete/etc.) or DQL (select/show/display) * * @return string * @@ -1960,8 +1960,7 @@ public function getType(&$v): int * @test equals true,$this->pdoOne->runQuery($this->pdoOne->prepare('select * 1 from dual')) * @test equals - * [1=>1],$this->pdoOne->select('1')->from('dual')->first(),'it - * must runs' + * [1=>1],$this->pdoOne->select('1')->from('dual')->first(),'it must run' */ public function runQuery(PDOStatement $stmt, ?array $namedArgument = null, bool $throwError = true): ?bool { @@ -2347,7 +2346,7 @@ public function generateCodeArrayConst( /** * It returns an array with all the tables of the schema, also the foreign key and references of each table
* Example: - *+ * ```php * $this->tableDependency(); * // ['table'=>['city','country'], * // 'after'=>['city'=>['country'],'country=>[]], @@ -2358,7 +2357,7 @@ public function generateCodeArrayConst( * // ,"after" => ["city" => ["countryfk" => "country"],"country" => []] * // ,"before" => ["city" => [],"country" => ["country_id" => "country_id","city"]] * // ] - *+ * ``` * * @param bool $returnColumn If true then in "after" and "before", it returns the name of the columns * @param bool $forceLowerCase if true then the names of the tables are stored as lowercase @@ -2739,10 +2738,10 @@ public function getRelations(string $tableName, ?string $pkFirst): array /** * It returns a field, column or table, the quotes defined by the current database type. It doesn't consider points * or space
- *+ * ```php * $this->addQuote("aaa"); // [aaa] (sqlserver) `aaa` (mysql) * $this->addQuote("[aaa]"); // [aaa] (sqlserver, unchanged) - *+ * ``` * * @param string $txt * @@ -2896,7 +2895,7 @@ public function rollback(bool $throw = true, string $cause = ''): bool * For example, if we always want to convert tinyint into boolean, then we could use this function * , instead of specify per each column.
* Example:
- *+ * ```php * $this->parent->generateCodeClassConversions( * ['datetime'=>'datetime2' * ,'tinyint'=>'bool' // converts tinyint as boolean @@ -2904,7 +2903,7 @@ public function rollback(bool $throw = true, string $cause = ''): bool * ]); * echo $this->parent->generateCodeClassAll('table'); * $this->parent->generateCodeClassConversions(); // reset. - *+ * ``` * PHP Conversions: *
+ * ```php * init * // [EDIT:c1] * ccc * // [/EDIT] * end - *+ * ``` * filename content:
+ * ```php * init modified * // [EDIT:c1] * modified * // [/EDIT] * end modified - *+ * ``` * result:
+ * ```php * init * // [EDIT:c1] * modified * // [/EDIT] * end - *+ * ``` * * @param string $filename The full filename of the old archive. If the archive doesn't exist, * then it keeps the new content @@ -3351,9 +3350,9 @@ public function truncate(string $tableName, string $extra = '', bool $forced = f /** * It calls a store procedure.
+ * ```php * $this->callProcedure('procexample',['in_name'=>'aa','in_description'=>'bbb'],['in_description]) - *
+ * ```php * // arg1 and arg2 are "in" arguments: * $this->createProcedure('proc1','in arg1 int,in arg2 varchar(50)','//body here'); * // arg1 and arg2 are "in" arguments: @@ -3448,7 +3447,7 @@ public function createSequence(?string $tableSequence = null, string $method = ' * ['arg1','int'], * ['arg2','varchar(50)'] * ],'//body here'); - *+ * ``` * * @param string $procedureName The name of the store procedure * @param array|string $arguments The arguments. It could be an associative array, a string or a multiple array @@ -3469,12 +3468,12 @@ public function createProcedure(string $procedureName, $arguments = [], string $ /** * Create a table
+ * ```php * // no universal (false indicates native sql) * createTable('products',['id'=>'int not null','name'=>'varchar(50) null'],'id','','',false); * // universal (true indicates universal) * createTable('products',['id int','name string(50) null'],'id','','',true); - *+ * ``` * * @param string $tableName The name of the new table. This method will fail if the table exists. * @param array $definition An associative array with the definition of the columns.
+ * ```php * $this->addColumn("customer",['id'=>'int']); - *+ * ``` * @param string $tableName The name of the new table. * @param array $definition The definition of the columns
+ * ```php * $this->deleteColumn("customer",'col1'); * $this->deleteColumn("customer",['col1','col2']); - *+ * ``` * @param string $tableName The name of the new table. * @param array|string $definition The definition of the columns
+ * ```php * "name string(20) null" -> "name varchar(20) null" * "creationDate datetime null" -> "creationDate date null" * "id int" -> "id int not null" * "id int extra" -> "id int not null extra" (check the double space for null) - *+ * ``` * types allowed: int, long, decimal, bool, date, datetime, timestamp, string
+ * ```php * $this->runMultipleRawQuery("insert into() values(1); insert into() values(2)"); * $this->runMultipleRawQuery(["insert into() values(1)","insert into() values(2)"]); - *+ * ``` * * @param string|array $listSql SQL multiples queries separated * by ";" or an array @@ -3665,11 +3664,11 @@ public function runMultipleRawQuery($listSql, bool $continueOnError = false): bo /** * It adds foreign keys to a table
+ * ```php * $this->createFK('table',['col'=>"FOREIGN KEY REFERENCES`tableref`(`colref`)"]); // mysql * $this->createFK('table',['col'=>"FOREIGN KEY REFERENCES[tableref]([colref])"]); // sqlsrv * $this->createFK('table',['col'=>"FOREIGN KEY REFERENCES TABLE1(COL1)"]); // oci - *+ * ``` * * @param string $tableName The name of the table. * @param array $definitions Associative array with the definition (SQL) of the foreign keys. @@ -3689,9 +3688,9 @@ public function createFK(string $tableName, array $definitions): bool /** * It creates indexes. It doesn't replace previous indexes. The definition could depend on the type of database
+ * ```php * $this->createIndex('table',['col1'=>'INDEX','col2=>'UNIQUE INDEX']); - *+ * ``` * * @param string $tableName the name of the table. * @param array $definitions An associative array @@ -4201,7 +4200,7 @@ public function filterKey($condition, $columns, $returnSimple) /** * Generates and execute an insert command.
+ * ```php * insert('table',['col1',10,'col2','hello world']); // simple array: name1,value1,name2,value2.. * insert('table',null,['col1'=>10,'col2'=>'hello world']); // definition is obtained from the values * insert('table',['col1'=>10,'col2'=>'hello world']); // definition is obtained from the values @@ -4294,7 +4293,7 @@ public function min(string $sql = '', string $arg = '') /** * It generates a query for "count". It is a macro of select() *
Example:
- *+ * ```php * ->from('table')->count('') // select count(*) from * table+ * ``` * * @param string|null $sql [optional] * @param string $arg [optional] @@ -4383,13 +4382,13 @@ public function avg(string $sql = '', string $arg = '') * Adds a from for a query. It could be used by select,insert,update and * delete.
* ->count('from table')->firstScalar() // select count(*) from table
@@ -4302,7 +4301,7 @@ public function min(string $sql = '', string $arg = '') * from table where condition=1
* ->count('from table','col')->firstScalar() // select count(col) from * table
- *
* Example:
- *+ * ```php * from('table') * from('table alias') * from('table alias','dbo') // from dbo.table alias * from('table1,table2') * from('table1 inner join table2 on table1.c=table2.c') - *+ * ``` * * @param string $sql Input SQL query * @param string|null $schema The schema/database of the table without trailing dot.
@@ -4451,7 +4450,7 @@ public function delete( /** * Generate and run an update in the database. *
Example:
- *+ * ```php * update('table',['col1',10,'col2','hello world'],['wherecol',10]); * update('table',['col1','col2'],[10,'hello world'],['wherecol'],[10]); * $this->from("producttype") @@ -4459,7 +4458,7 @@ public function delete( * ->where('idproducttype=?',[6]) * ->update(); * update('product_category set col1=10 where idproducttype=1') - *+ * ``` * * @param string|null $tableName The name of the table or the whole * query. @@ -4504,11 +4503,11 @@ public function right(string $sql): PdoOneQuery * Adds a left join to the pipeline. It is possible to chain more than one * join
* Example:
- *+ * ```php * left('table on t1.c1=t2.c2') * left('table on table.c1=t2.c2').left('table2 on * table1.c1=table2.c2') - *+ * ``` * * @param string $sql Input SQL query * @@ -4583,10 +4582,10 @@ public function having($sql, $param = PdoOne::NULL): PdoOneQuery /** * It generates an inner join
* Example:
- *+ * ```php * join('tablejoin on t1.field=t2.field')+ * ``` * * @param string $sql Example "tablejoin on table1.field=tablejoin.field" * @param string $condition @@ -4617,10 +4616,10 @@ public function group(string $sql): PdoOneQuery /** * It adds an "order by" in a query.
* join('tablejoin','t1.field=t2.field')
- *
* Example:
- *+ * ```php * ->select("")->order("column")->toList(); * ->select("")->order("col1,col2")->toList(); - *+ * ``` * * @param string $sql Input SQL query * @@ -4637,9 +4636,9 @@ public function order(string $sql): PdoOneQuery /** * It adds a "limit" in a query. It depends on the type of database
* Example:
- *+ * ```php * ->select("")->limit("10,20")->toList(); - *+ * ``` * * @param string $sql Input SQL query * @@ -4655,7 +4654,7 @@ public function limit(string $sql): PdoOneQuery /** * Adds a distinct to the query. The value is ignored if the select() is * written complete.
- *+ * ```php * ->select("*")->distinct() // works * ->select("select *")->distinct() // distinct is ignored. *@@ -4673,9 +4672,9 @@ public function distinct(string $sql = 'distinct'): PdoOneQuery /** * It sets a recursive array.
* Example::
- *+ * ```php * $this->recursive(['field1','field2']); - *+ * ``` * * @param array|mixed $rec The fields to load recursively. * @@ -4700,7 +4699,7 @@ public function getRecursive(): array * It sets to use cache for the current pipelines. It is disabled at the end of the pipeline
* It only works if we set the cacheservice
* Example
- *+ * ```php * $this->setCacheService($instanceCache); * $this->useCache()->select()..; // The cache never expires * $this->useCache(60)->select()..; // The cache lasts 60 seconds. @@ -4712,7 +4711,7 @@ public function getRecursive(): array * // it could be invalidated by invalidateCache() * $this->useCache(60,'*')->select('col') * ->from('table')->toList(); // '*' uses all the table assigned. - *+ * ``` * * @param null|bool|int $ttl null then the cache never expires.
* false then we don't use cache.
diff --git a/lib/PdoOneCli.php b/lib/PdoOneCli.php index bb6387b..5eb973e 100644 --- a/lib/PdoOneCli.php +++ b/lib/PdoOneCli.php @@ -11,11 +11,11 @@ * It is the CLI interface for PdoOne.
* How to execute it?
* In the command line, runs the next line:
- *+ * ```php * php vendor/eftec/PdoOne/lib/pdoonecli * or * vendor/bin/pdoonecli (Linux/macOS) / vendor/bin/pdoonecli.bat (Windows) - *+ * ``` * * @see https://github.com/EFTEC/PdoOne * @package eftec diff --git a/lib/PdoOneQuery.php b/lib/PdoOneQuery.php index 94d750f..c5dee00 100644 --- a/lib/PdoOneQuery.php +++ b/lib/PdoOneQuery.php @@ -442,7 +442,7 @@ public function having($sql, $param = PdoOne::NULL): PdoOneQuery /** * Add a condition to the query. * Example:
- *+ * ```php * $this->where( ['field'=>20] ) // associative array with automatic type * $this->where( ['/_field/subfield',20] ) // (for ORM) recursive query * //, where _field is a relational column (alias). @@ -457,7 +457,7 @@ public function having($sql, $param = PdoOne::NULL): PdoOneQuery * $this->where('field like ?',['%'.$value.'%']); // OK, like condition. Note: the % is added in the value. * $this->where("field like concat('%', ?, '%')",[$value]); // this will work using Mysql. * $this->where('field like %?%',[$value]); // THIS WILL NOT WORK. - *+ * ``` * * @param string|array $sql Input SQL query or associative/indexed * array @@ -484,7 +484,7 @@ public function where($sql, $param = PdoOne::NULL, bool $isHaving = false, ?stri /** * Example:
- *+ * ```php * where( ['field'=>20] ) // associative array (named) * where( ['field=?'=>20] ) // associative array (numeric) * where( ['field=:name'=>20] ) // associative array (named) @@ -499,7 +499,7 @@ public function where($sql, $param = PdoOne::NULL, bool $isHaving = false, ?stri * defined where('field=?,field2=?', [20,'hello'] ) * where('field=:field,field2=:field2', * ['field'=>'hello','field2'=>'world'] ) // associative array as value - *+ * ``` * * @param array|string $where * @param string|array|int $params @@ -689,9 +689,9 @@ public function constructParam2( * Note: This method could not be efficient because it reads all the values. * If you can, then use the methods sort()::first()
* Example:
- *+ * ```php * $con->select('*')->from('table')->last(); // select * from table (last scalar value) - *+ * ``` * * @return array|null * @throws Exception @@ -739,9 +739,9 @@ public function last(): ?array * It returns an array of simple columns (not declarative). It uses the * first column
* Example:
- *+ * ```php * select('select id from table')->toListSimple() // ['1','2','3','4'] - *+ * ``` * * @return array|bool * @throws Exception @@ -783,7 +783,7 @@ private function usingORM(bool $addColumns = false): void /** * It adds a select to the query builder. *
Example:
- *+ * ```php * $this->select("\*")->from('table') //"select * from table" * $this->select(['col1','col2'])->from('table') // "select col1,col2 from table" * $this->select('col1,col2')->from('table') // "select col1,col2 from table" @@ -791,7 +791,7 @@ private function usingORM(bool $addColumns = false): void * $this->select('select * from table') // "select * from table" * * $this->select('select * from table')->where(['id'],[1]) // "select * from table where id=1" * $this->select('select * from table where id=1') // "select * from table where id=1" - *+ * ``` * * @param string|array $sql * @@ -814,13 +814,13 @@ public function select($sql): PdoOneQuery * Adds a from for a query. It could be used by select,insert,update and delete.
* Note: The prefix (PdoOne->$prefixTable) is considered only if the table is defined alone. * Example:
- *+ * ```php * from('table') * from('table alias') * from('table1,table2') * from('table1,table2','dbo') * from('table1 inner join table2 on table1.c=table2.c') - *+ * ``` * * @param string|null $sqlOrTableName Input SQL query * @param string|null $schema The schema/database of the table without trailing dot.
@@ -928,12 +928,12 @@ public function table($sql): self * If there is 3 columns, and it does not use a separator, then it only uses the first 2 columns
* If there is 3 columns, and it does use a separator, then the second value is the merge of the last 2 columns
* Example:
- *+ * ```php * select('select cod,name from table')->toListKeyValue() * // ['cod1'=>'name1','cod2'=>'name2'] * select('select cod,name,ext from table')->toListKeyValue('|') * // ['cod1'=>'name1|ext1','cod2'=>'name2|ext2'] - *+ * ``` * * @param string|null $extraValueSeparator (optional) It allows to read a * third value and returns it @@ -993,13 +993,13 @@ public function _toList($pdoMode = PDO::FETCH_ASSOC, bool $returnArray = true) * If not data is found, then it returns an empty array
* This method is an end of the chain method, so it clears the method stack
* Example:
- *+ * ```php * $this->select('select id,name from table')->toList() // [['id'=>'1','name'='john'],['id'=>'2','name'=>'anna']] * $this->select('id,name') * ->from('table') * ->where('condition=?',[20]) * ->toList(); - *+ * ``` * * @param int $pdoMode (optional) By default is PDO::FETCH_ASSOC * @param bool $returnArray @@ -1019,12 +1019,12 @@ public function toList(int $pdoMode = PDO::FETCH_ASSOC, bool $returnArray = true /** * It returns a PdoStatement from a query.
* Example:
- *+ * ```php * $stmt=$this->select('select id,name from table')->toPdoStatement(); * while ($row = $stmt->fetch()) { * // do something * } - *+ * ``` * * @param int $pdoMode (optional) By default is PDO::FETCH_ASSOC * @return PDOStatement|null It returns a PdoStatement or null if error. @@ -1040,10 +1040,10 @@ public function toPdoStatement(int $pdoMode = PDO::FETCH_ASSOC): ?PDOStatement * This method could be used when we don't want to read all the information at once, so you can read and process * each line separately
* Example:
- *+ * ```php * $this->select('select id,name from table') * ->fetchLoop(static function($row,$numRow) {return($row);},\PDO::FETCH_ASSOC) - *+ * ``` * * @param callable $callable the function to call. This function could have the next arguments
* $row (array|null) with the values of the row
@@ -1091,13 +1091,13 @@ public function toResult() * It returns the first row. If there is not a row then it returns false.
* This method is an end of the chain method, so it clears the method stack
* Example:
- *+ * ```php * $con->select('*')->from('table')->first(); // select * from table (first value) * Repo::->method(...)->first(1); // (ORM only), the first value where the primary key is 1 * Repo::->method(...)->first([1,2]); // (ORM only), first value where the primary keys are 1 and 2 * Repo::->method(...)->first(['id1'=>1,'id'=>2]); // (ORM only),first value where the primary keys are 1 and 2 * - *+ * ``` * * @param mixed $pk the argument is used together with ORM. * @return array|null|false @@ -1171,7 +1171,7 @@ public function _first() /** * It generates a query for "count". It is a macro of select() *
Example:
- *+ * ```php * ->from('table')->count('') // select count(*) from * table+ * ``` * * @param string|null $sql [optional] * @param string $arg [optional] @@ -1225,9 +1225,9 @@ public function _aggFn(string $method, string $sql = '', string $arg = '') * If value is not found then it returns null.
* ->count('from table') // select count(*) from table
@@ -1179,7 +1179,7 @@ public function _first() * from table where condition=1
* ->count('from table','col') // select count(col) from * table
- *
* * This method is an end of the chain method, so it clears the method stack
* Example:
- *+ * ```php * $con->select('*')->from('table')->firstScalar(); // select * from table (first scalar value) - *+ * ``` * * @param string|null $colName If it's null then it uses the first * column. @@ -1412,9 +1412,9 @@ public function page(int $numPage, ?int $pageSize = null): PdoOneQuery /** * It adds a "limit" in a query. It depends on the type of database
* Example:
- *+ * ```php * ->select("")->limit("10,20")->toList(); - *+ * ``` * * @param mixed $first Input SQL query * @param mixed $second Input SQL query @@ -1487,7 +1487,7 @@ public function factory(?array $values = null, string $recursivePrefix = ''): ar /** * Adds a distinct to the query. The value is ignored if the select() is * written complete.
- *+ * ```php * ->select("*")->distinct() // works * ->select("select *")->distinct() // distinct is ignored. *@@ -1523,11 +1523,11 @@ public function setThrowOnError(bool $value = false): self /** * If true then the stack/query builder will not reset the stack (but on error) when it is finished
* Example:
- *+ * ```php * $this->parent->pdoOne->select('*')->from('missintable')->setNoReset(true)->toList(); * // we do something with the stack * $this->parent->pdoOne->builderReset(true); // reset the stack manually - *+ * ``` * * @param bool $noReset * @@ -1576,11 +1576,11 @@ public function buildUniqueID($extra = null, string $prefix = ''): string * Adds a left join to the pipeline. It is possible to chain more than one * join
* Example:
- *+ * ```php * left('table on t1.c1=t2.c2') * left('table on table.c1=t2.c2').left('table2 on * table1.c1=table2.c2') - *+ * ``` * * @param string|null $sql Input SQL query * @@ -1691,14 +1691,14 @@ public function include($fields): self /** * It sets a recursive array.
* example::
- *+ * ```php * $this->recursive(['field1','field2']); * RepoClass::recursive(['/_relation1','/_relation1/_subrelation1']); // For ORM: use of recursive * RepoClass::recursive(['/_manytomany*'); // Form ORM: the postfix "*" indicates (only in a many-to-many relation) * // "*": in the case of insert, update or merge, the relational table, left and right table would be * modified. * // "" : in the case of insert, update or merge, only the relational table and left table would be modified. - *+ * ``` * * @param array|mixed $rec The fields to load recursively. * @@ -1914,7 +1914,7 @@ private function constructInsert(): string /** * Generates and execute an insert command.
* Example:
- *+ * ```php * insert('table',['col1',10,'col2','hello world']); // simple array: name1,value1,name2,value2.. * insert('table',null,['col1'=>10,'col2'=>'hello world']); // definition is obtained from the values * insert('table',['col1'=>10,'col2'=>'hello world']); // definition is obtained from the values @@ -2083,7 +2083,7 @@ public function now(): ?string /** * Generate and run an update in the database.
* Example:
- *+ * ```php * update('table',['col1',10,'col2','hello world'],['wherecol',10]); * update('table',['col1'=>10=>'col2'=>'hello world'],['wherecol'=>10]); * update('table',['col1','col2'],[10,'hello world'],['wherecol'],[10]); @@ -2092,15 +2092,15 @@ public function now(): ?string * ->where('idproducttype=?',[6]) * ->update(); * update('product_category set col1=10 where idproducttype=1') - *+ * ``` * Example ORM:
* If $entity has a missing field, then the missing field will not be updated.
* If $entity has an extra field (a field not defined in the table), then it will throw an error
- *+ * ```php * $result=self::factory(); * $result['name']='name changed'; * $ok=self::update($customer); - *+ * ``` * * @param string|null|array $tableOrObject The name of the table or the whole * query. @@ -2212,10 +2212,10 @@ public function getHavingParamAssoc(): array /** * It adds an "order by" in a query.
* Example:
- *+ * ```php * ->select("")->order("column")->toList(); * ->select("")->order("col1,col2")->toList(); - *+ * ``` * * @param ?string $sql Input SQL query * @@ -2234,11 +2234,11 @@ public function order(?string $sql): PdoOneQuery /** * Alias of method join().
* Example:
- *+ * ```php * innerjoin('tablejoin on t1.field=t2.field') * innerjoin('tablejoin tj on t1.field=t2.field') * innerjoin('tablejoin','t1.field=t2.field') - *+ * ``` * * @param string $sql * @param string $condition @@ -2254,10 +2254,10 @@ public function innerjoin(string $sql, string $condition = ''): PdoOneQuery /** * It generates an inner join
* Example:
- *+ * ```php * join('tablejoin on t1.field=t2.field')+ * ``` * * @param string $sql Example "tablejoin on table1.field=tablejoin.field" * @param string $condition @@ -2282,7 +2282,7 @@ public function join(string $sql, string $condition = ''): PdoOneQuery * It sets to use cache for the current pipelines. It is disabled at the end of the pipeline
* join('tablejoin','t1.field=t2.field')
- *
* It only works if we set the cacheservice
* Example
- *+ * ```php * $this->setCacheService($instanceCache); * $this->useCache()->select()…; // The cache never expires * $this->useCache(60)->select()..; // The cache lasts 60 seconds. @@ -2294,7 +2294,7 @@ public function join(string $sql, string $condition = ''): PdoOneQuery * // it could be invalidated by invalidateCache() * $this->useCache(60,'*')->select('col') * ->from('table')->toList(); // '*' uses all the table assigned. - *+ * ``` * * @param null|bool|int $ttl null then the cache never expires.
* false then we don't use cache.
diff --git a/lib/ext/PdoOne_IExt.php b/lib/ext/PdoOne_IExt.php index 2d843ea..ab66506 100644 --- a/lib/ext/PdoOne_IExt.php +++ b/lib/ext/PdoOne_IExt.php @@ -62,11 +62,11 @@ public function resetIdentity(string $tableName, int $newValue = 0, string $colu * The results of the table depend on the kind of database. For example, sqlsrv returns the schema used (dbo), * while mysql returns the current schema (database). * Example:
- *+ * ```php * $this->getDefTableExtended('table'); // ['name','engine','schema','collation','description'] * $this->getDefTableExtended('table',true); // "some description of the table" * - *+ * ``` * * @param string $table The name of the table * @param bool $onlyDescription If true then it only returns a description @@ -79,10 +79,10 @@ public function getDefTableExtended(string $table, bool $onlyDescription = false /** * Returns an associative array with the definition of a table (columns of the table).
* Example:
- *+ * ```php * $this->getDefTable('table'); * // ['col1'=>'int not null','col2'=>'varchar(50)'] - *+ * ``` * * @param string $table * @@ -175,7 +175,7 @@ public function createSequence(string $tableSequence = null, string $method = 's /** * It creates a store procedure
* Example:
- *+ * ```php * // arg1 and arg2 are "in" arguments: * $this->createProcedure('proc1','in arg1 int,in arg2 varchar(50)','//body here'); * // arg1 and arg2 are "in" arguments: @@ -192,7 +192,7 @@ public function createSequence(string $tableSequence = null, string $method = 's * ['arg1','int'], * ['arg2','varchar(50)'] * ],'//body here'); - *+ * ``` * * @param string $procedureName The name of the store procedure * @param array|string $arguments The arguments. It could be an associative array, a string or a multiple array @@ -212,14 +212,14 @@ public function translateType(string $universalType, $len = null): string; /** * DCL command. It creates a database.
* Example: - *+ * ```php * $this->createtable("customer" * ,['id'=>'int','name'=>'varchar(50)'] * ,'id'); * $this->createtable("customer" * ,['id'=>'int','name'=>'varchar(50)'] * ,['id'=>'PRIMARY KEY','name'=>'KEY']); - *+ * ``` * * * @param string $tableName The name of the table @@ -242,10 +242,10 @@ public function createTable(string $tableName, array $definition, $primaryKey = /** * DCL command. It adds a column in a table.
- * Example: - *- * $this->addColumn("customer",['id'=>'int']); - *+ * Example: + * ```php + * $this->addColumn("customer",['id'=>'int']); + * ``` * @param string $tableName The name of the table * @param array $definition An associative array with the definition of the column.
* The key is used as the name of the field @@ -277,10 +277,10 @@ public function createIndex(string $tableName, array $indexesAndDef): string; /** * It adds a limit operation for the query. It depends on the type of the database. * Example:
- *+ * ```php * ->select("")->limit("10,20")->toList(); * ->select("")->limit(10,20)->toList(); - *+ * ``` * * @param int|null $first The whole expression separated by comma, or the first expression (the initial row) * @param int|null $second The numbers of row to read. If null, then it uses $sql.