Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit 310459a

Browse files
committed
Updated to version 1.1.2
1 parent a584d5f commit 310459a

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

README-ES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ $table → (string) Nombre de la tabla.
332332

333333
$foreing_key → (string) Foreing key.
334334

335-
**references**($references) (Opcional)
335+
**reference**($reference) (Opcional)
336336

337-
$references → (string) Columna a la que se hace referencia.
337+
$reference → (string) Columna a la que se hace referencia.
338338

339339
**on**($table) (Opcional)
340340

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ $table → (string) Database table name.
333333

334334
$foreing_key → (string) Foreing key.
335335

336-
**references**($references) (Optional)
336+
**reference**($reference) (Optional)
337337

338-
$references → (string) Column reference.
338+
$reference → (string) Column reference.
339339

340340
**on**($table) (Optional)
341341

src/Database.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Database {
116116
*
117117
* @var array
118118
*/
119-
private $_references;
119+
private $_reference;
120120

121121
/**
122122
* Database reference table for foreing key.
@@ -412,17 +412,17 @@ public function foreing($id) {
412412
}
413413

414414
/**
415-
* Set references for foreing keys.
415+
* Set reference for foreing keys.
416416
*
417417
* @since 1.1.2
418418
*
419419
* @param array $data → table and id
420420
*
421421
* @return object
422422
*/
423-
public function references($data) {
423+
public function reference($data) {
424424

425-
$this->_references[] = $data;
425+
$this->_reference[] = $data;
426426

427427
return $this;
428428
}
@@ -450,7 +450,7 @@ public function on($table) {
450450
*/
451451
public function actions($action) {
452452

453-
$this->_action[] = $action;
453+
$this->_actions[] = $action;
454454

455455
return $this;
456456
}
@@ -726,7 +726,7 @@ private function _reset() {
726726
$this->_limit = null;
727727
$this->_statements = null;
728728
$this->_foreing = null;
729-
$this->_references = null;
729+
$this->_reference = null;
730730
$this->_on = null;
731731
$this->_actions = null;
732732
$this->_engine = null;
@@ -804,7 +804,7 @@ public function execute($result = 'obj') {
804804
$this->_table,
805805
$this->_data,
806806
$this->_foreing,
807-
$this->_references,
807+
$this->_reference,
808808
$this->_on,
809809
$this->_actions,
810810
$this->_engine,

src/Provider/PDOprovider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,19 @@ public function create($table, $data, $foreing, $reference, $on, $actions, $engi
179179
$index = '';
180180
$references = '';
181181

182-
if (!is_null($foreing, $reference, $on) && $count = count($foreing) === count($on) && count($reference) === count($foreing)) {
182+
if (isset($foreing, $reference, $on) && count($foreing) === count($on) && count($reference) === count($foreing)) {
183+
184+
$count = count($foreing);
183185

184186
for ($i=0; $i < $count; $i++) {
185187

186-
$action = (isset($actions[$i])) ? $actions[$i] : $actions;
188+
$action = (isset($actions[$i])) ? $actions[$i] : $actions[0];
187189

188-
$index .= ' INDEX (' . $foreing[$i] . '), ';
190+
$index .= ' INDEX (`'.$foreing[$i].'`), ';
189191

190-
$references .= ' FOREIGN KEY (' . $foreing[$i] . ') ' .
191-
'REFERENCES ' . $on[$i] . ' (' .
192-
$reference[$i] . ') ' . $action . ',';
192+
$references .= 'CONSTRAINT FOREIGN KEY (`'.$foreing[$i].'`) '.
193+
'REFERENCES ' . $on[$i] .
194+
' (`'.$reference[$i].'`) ' . $action . ',';
193195
}
194196
}
195197

0 commit comments

Comments
 (0)