2017 © Pedro Peláez
 

library pdope

A composer package that provides solutions for simplifying PDO query parameterization

image

jimonade/pdope

A composer package that provides solutions for simplifying PDO query parameterization

  • Tuesday, September 5, 2017
  • by peledies
  • Repository
  • 3 Watchers
  • 0 Stars
  • 422 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

PDope

php pdo practical extensions for simple 1-table mvc models, (*1)

this helper class is required in your model's base class, (*2)

class DataProperty {
  public $name;
  private $type;
  public $required;

  function __construct($name, $type=NULL, $required=FALSE) {
    $this->name = $name;
    if (empty($type)) {
      $type = "STRING";
    }
    $this->type = $type;
    $this->required = $required;
  }
  public function set_type($type) {
    $this->type = strtoupper($type);
  }
  public function get_type() {
    return $this->type;
  }
}

first, define data properties in your model constructor, (*3)

  function __construct($props=null) {
    parent:: __construct($props);

    $this->define_data_property("id", "STRING", TRUE);
    $this->define_data_property("title", "STRING", FALSE);
    $this->define_data_property("description", "STRING", FALSE);
    $this->define_data_property("organization_id", "STRING", FALSE);
    $this->define_data_property("address_line_1", "STRING", FALSE);
    $this->define_data_property("address_line_2", "STRING", FALSE);
    $this->define_data_property("address_line_3", "STRING", FALSE);
    $this->define_data_property("city", "STRING", FALSE);
    $this->define_data_property("state", "STRING", FALSE);
    $this->define_data_property("zip", "STRING", FALSE);
    $this->define_data_property("capacity", "INT", FALSE);
    $this->define_data_property("latitude", "FLOAT", FALSE);
    $this->define_data_property("longitude", "FLOAT", FALSE);
    $this->define_data_property("created_at", "DATE", FALSE);
    $this->define_data_property("updated_at", "DATE", FALSE);
    $this->define_data_property("active", "BOOL", FALSE);
  }

example, simple query, (*4)

  $db = new \PDope\Statement("select", "facility", $this);
  $db->add_where_parameters_auto(TRUE);
  return $db->execute();

example, simple insert, (*5)

  $db = new \PDope\Statement("insert", "facility", $this);
  $db->add_parameters_auto(TRUE);
  $db->add_parameter("id", "UUID");
  $db->add_parameter("created_at", "NOW");
  $db->add_parameter("updated_at", "NOW");
  $db->execute();

example, simple update, (*6)

  $db = new \PDope\Statement("update", "facility", $this);
  $db->add_parameters_auto(TRUE);

  //we dont want to update "id" or "created_at"
  $db->remove_parameter("id");
  $db->remove_parameter("created_at");

  $db->add_parameter("updated_at", "NOW");
  $db->add_where_parameter("id", "STRING");
  $db->execute();

example, simple suspend, (*7)

  $db = new \PDope\Statement("update", "facility", $this);
  $db->add_parameter("updated_at", "NOW");
  $db->add_parameter("active");
  $db->add_where_parameter("id");
  $db->execute();

example, you can always just use the pdo object to build your own statement from scratch, (*8)

$pdo = \PDope\Connection:: connection();
$statement = $pdo->prepare("SELECT property FROM table WHERE id = :id");
$statement->execute(['id' => $model->id]);
$results = $statement->fetchAll(\PDO::FETCH_OBJ);

The Versions

05/09 2017

dev-master

9999999-dev

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

05/09 2017

1.0.10

1.0.10.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

17/03 2017

1.0.9

1.0.9.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

30/09 2016

1.0.8

1.0.8.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

29/08 2016

1.0.7

1.0.7.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

22/07 2016

1.0.6

1.0.6.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

21/07 2016

1.0.5

1.0.5.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

18/07 2016

1.0.4

1.0.4.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

14/07 2016

1.0.3

1.0.3.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

30/06 2016

1.0.2

1.0.2.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

28/06 2016

1.0.1

1.0.1.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney

01/06 2016

1.0.0

1.0.0.0

A composer package that provides solutions for simplifying PDO query parameterization

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jim Harney