Skip to content

Commit

Permalink
4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecc-business-account committed Aug 2, 2024
1 parent 07fa007 commit a185263
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,9 @@ 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.9 2024-08-02
* [update] camelize update to consider "-" and "\_" and not only "\_"
* [update] update dependencies.
* 4.8 2024-07-06
* [upd] added fetchMode for runRawQuery()
* [new] added setFetchMode()
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"require": {
"php": ">=7.4",
"ext-json": "*",
"eftec/clione": "^1.32",
"eftec/clione": "^1.33",
"ext-pdo": "*",
"ext-readline": "*",
"eftec/messagecontainer": "^2.8"
"eftec/messagecontainer": "^2.9"
},
"bin": [
"lib/pdoonecli"
Expand Down
4 changes: 2 additions & 2 deletions lib/IPdoOneCache.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php /** @noinspection PhpMissingParamTypeInspection */

<?php /** @noinspection UnknownInspectionInspection */
/** @noinspection PhpMissingParamTypeInspection */
/** @noinspection AccessModifierPresentedInspection */

namespace eftec;
Expand Down
27 changes: 20 additions & 7 deletions lib/PdoOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,6 @@ public function setMessages(MessageContainer $messageContainer): void
*
* @param string $txt
*
* @throws Exception
*/
public function storeInfo(string $txt): void
{
Expand Down Expand Up @@ -1646,7 +1645,7 @@ private function strposa($haystack, $needles = [])
* @param int $fetchMode The mode to fetch
* @param null $fetchArgument The argument of the fetch model
* @return bool|PDOStatement|array an array of associative or a pdo statement. False is the operation fails
* @throws JsonException
* @throws Exception
* @test equals [0=>[1=>1]],this('select 1',null,true)
*/
public function runRawQuery(string $rawSql, ?array $params = null, ?bool $returnArray = true, bool $useCache = false, $cacheFamily = null, int $fetchMode = PDO::FETCH_ASSOC, $fetchArgument = null)
Expand Down Expand Up @@ -2525,9 +2524,21 @@ private function typeDict($row)
return $this->service->typeDict($row);
}

public static function camelize($input, $separator = '_')
/**
* It transform a string into a camel case format<br>
* **Example:**
* ```
* $value=PdoOne::camelize('camel_format'); //CamelFormat
* $value=PdoOne::camelize('camel-format'); //CamelFormat
* ```
*
* @param string $input
* @param string $separator (optional)
* @return array|string|string[]
*/
public static function camelize(string $input,string $separator = '_-')
{
return str_replace($separator, '', ucwords($input, $separator));
return str_replace(str_split($separator), '', ucwords($input, $separator));
}

public static function varExport($input, $indent = "\t"): ?string
Expand Down Expand Up @@ -2838,9 +2849,11 @@ public function getDefIdentities(string $table): array
/**
* It sets a value into the query (insert or update)<br>
* **Example:**
* ->from("table")->set('field1=?',20),set('field2=?','hello')->insert()<br>
* ->from("table")->set("type=?",[6])->where("i=1")->update()<br>
* set("type=?",6) // automatic<br>
* ```
* $this->from("table")->set('field1=?',20),set('field2=?','hello')->insert();
* $this->from("table")->set("type=?",[6])->where("i=1")->update();
* $this->>set("type=?",6); // automatic
* ```
*
* @param string|array $sqlOrArray
* @param array|mixed $param
Expand Down
6 changes: 5 additions & 1 deletion tests/PdoOne_mysql_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,11 @@ public function test_runRawQuery(): void
$x=$this->pdoOne->setFechMode(PDO::FETCH_CLASS,SomeClass::class)->runRawQuery('select ? as abc',['1'])[0];
self::assertInstanceOf(SomeClass::class,$x);
self::assertEquals("1",$x->abc);

}
public function test_camel():void {
self::assertEquals('CamelFormat',PdoOne::camelize('camel_format'));
self::assertEquals('CamelFormat',PdoOne::camelize('camel-format'));
self::assertEquals('CamelFormat',PdoOne::camelize('camelFormat'));
}

/**
Expand Down

0 comments on commit a185263

Please sign in to comment.