/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Connection.php
* @param array $info Array containing URL parts
* @return Connection
*/
protected function __construct($info)
{
try {
// unix sockets start with a /
if ($info->host[0] != '/')
{
$host = "host=$info->host";
if (isset($info->port))
$host .= ";port=$info->port";
}
else
$host = "unix_socket=$info->host";
$this->connection = new PDO("$info->protocol:$host;dbname=$info->db", $info->user, $info->pass, static::$PDO_OPTIONS);
} catch (PDOException $e) {
throw new DatabaseException($e);
}
}
/**
* Retrieves column meta data for the specified table.
*
* @param string $table Name of a table
* @return array An array of {@link Column} objects.
*/
public function columns($table)
{
$columns = array();
$sth = $this->query_column_info($table);
while (($row = $sth->fetch())) {
$c = $this->create_column($row);
$columns[$c->name] = $c;
}
return $columns;
}
Arguments
"""
PDOException: SQLSTATE[HY000] [1045] Access denied for user 'thep_bhawani'@'localhost' (using password: YES) in /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Connection.php:260\n
Stack trace:\n
#0 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Connection.php(260): PDO->__construct('mysql:host=loca...', 'thep_bhawani', 'demo!1@123', Array)\n
#1 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Connection.php(122): ActiveRecord\Connection->__construct(Object(stdClass))\n
#2 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/ConnectionManager.php(33): ActiveRecord\Connection::instance('mysql://thep_bh...')\n
#3 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Table.php(114): ActiveRecord\ConnectionManager::get_connection('development')\n
#4 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Table.php(90): ActiveRecord\Table->reestablish_connection(false)\n
#5 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Table.php(71): ActiveRecord\Table->__construct('Setting')\n
#6 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Model.php(765): ActiveRecord\Table::load('Setting')\n
#7 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Model.php(1657): ActiveRecord\Model::table()\n
#8 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Model.php(1605): ActiveRecord\Model::find_by_pk(Array, Array)\n
#9 [internal function]: ActiveRecord\Model::find('all', 1)\n
#10 /home/thepos.xyz/bhawani-medical/vendor/php-activerecord/php-activerecord/lib/Model.php(1436): call_user_func_array('static::find', Array)\n
#11 /home/thepos.xyz/bhawani-medical/app/routes/admin/index.php(14): ActiveRecord\Model::all(1)\n
#12 /home/thepos.xyz/bhawani-medical/core/classes/Router.php(288): {closure}()\n
#13 /home/thepos.xyz/bhawani-medical/index.php(7): Router->run()\n
#14 {main}
"""
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Connection.php
{
$config = Config::instance();
if (strpos($connection_string_or_connection_name, '://') === false)
{
$connection_string = $connection_string_or_connection_name ?
$config->get_connection($connection_string_or_connection_name) :
$config->get_default_connection_string();
}
else
$connection_string = $connection_string_or_connection_name;
if (!$connection_string)
throw new DatabaseException("Empty connection string");
$info = static::parse_connection_url($connection_string);
$fqclass = static::load_adapter_class($info->protocol);
try {
$connection = new $fqclass($info);
$connection->protocol = $info->protocol;
$connection->logging = $config->get_logging();
$connection->logger = $connection->logging ? $config->get_logger() : null;
if (isset($info->charset))
$connection->set_encoding($info->charset);
} catch (PDOException $e) {
throw new DatabaseException($e);
}
return $connection;
}
/**
* Loads the specified class for an adapter.
*
* @param string $adapter Name of the adapter.
* @return string The full name of the class including namespace.
*/
private static function load_adapter_class($adapter)
{
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/ConnectionManager.php
/**
* Array of {@link Connection} objects.
* @var array
*/
static private $connections = array();
/**
* If $name is null then the default connection will be returned.
*
* @see Config
* @param string $name Optional name of a connection
* @return Connection
*/
public static function get_connection($name=null)
{
$config = Config::instance();
$name = $name ? $name : $config->get_default_connection();
if (!isset(self::$connections[$name]) || !self::$connections[$name]->connection)
self::$connections[$name] = Connection::instance($config->get_connection($name));
return self::$connections[$name];
}
/**
* Drops the connection from the connection manager. Does not actually close it since there
* is no close method in PDO.
*
* If $name is null then the default connection will be returned.
*
* @param string $name Name of the connection to forget about
*/
public static function drop_connection($name=null)
{
$config = Config::instance();
$name = $name ? $name : $config->get_default_connection();
if (isset(self::$connections[$name]))
unset(self::$connections[$name]);
}
Arguments
"mysql://thep_bhawani:demo!1@123@localhost/thep_bhawani"
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Table.php
$this->set_delegates();
$this->set_cache();
$this->set_setters_and_getters();
$this->callback = new CallBack($class_name);
$this->callback->register('before_save', function(Model $model) { $model->set_timestamps(); }, array('prepend' => true));
$this->callback->register('after_save', function(Model $model) { $model->reset_dirty(); }, array('prepend' => true));
}
public function reestablish_connection($close=true)
{
// if connection name property is null the connection manager will use the default connection
$connection = $this->class->getStaticPropertyValue('connection',null);
if ($close)
{
ConnectionManager::drop_connection($connection);
static::clear_cache();
}
return ($this->conn = ConnectionManager::get_connection($connection));
}
public function create_joins($joins)
{
if (!is_array($joins))
return $joins;
$ret = $space = '';
$existing_tables = array();
foreach ($joins as $value)
{
$ret .= $space;
if (stripos($value,'JOIN ') === false)
{
if (array_key_exists($value, $this->relationships))
{
$rel = $this->get_relationship($value);
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Table.php
self::$cache[$model_class_name] = new Table($model_class_name);
self::$cache[$model_class_name]->set_associations();
}
return self::$cache[$model_class_name];
}
public static function clear_cache($model_class_name=null)
{
if ($model_class_name && array_key_exists($model_class_name,self::$cache))
unset(self::$cache[$model_class_name]);
else
self::$cache = array();
}
public function __construct($class_name)
{
$this->class = Reflections::instance()->add($class_name)->get($class_name);
$this->reestablish_connection(false);
$this->set_table_name();
$this->get_meta_data();
$this->set_primary_key();
$this->set_sequence_name();
$this->set_delegates();
$this->set_cache();
$this->set_setters_and_getters();
$this->callback = new CallBack($class_name);
$this->callback->register('before_save', function(Model $model) { $model->set_timestamps(); }, array('prepend' => true));
$this->callback->register('after_save', function(Model $model) { $model->reset_dirty(); }, array('prepend' => true));
}
public function reestablish_connection($close=true)
{
// if connection name property is null the connection manager will use the default connection
$connection = $this->class->getStaticPropertyValue('connection',null);
if ($close)
{
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Table.php
/**
* A instance of CallBack for this model/table
* @static
* @var object ActiveRecord\CallBack
*/
public $callback;
/**
* List of relationships for this table.
*/
private $relationships = array();
public static function load($model_class_name)
{
if (!isset(self::$cache[$model_class_name]))
{
/* do not place set_assoc in constructor..it will lead to infinite loop due to
relationships requesting the model's table, but the cache hasn't been set yet */
self::$cache[$model_class_name] = new Table($model_class_name);
self::$cache[$model_class_name]->set_associations();
}
return self::$cache[$model_class_name];
}
public static function clear_cache($model_class_name=null)
{
if ($model_class_name && array_key_exists($model_class_name,self::$cache))
unset(self::$cache[$model_class_name]);
else
self::$cache = array();
}
public function __construct($class_name)
{
$this->class = Reflections::instance()->add($class_name)->get($class_name);
$this->reestablish_connection(false);
$this->set_table_name();
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Model.php
/**
* Re-establishes the database connection with a new connection.
*
* @return Connection
*/
public static function reestablish_connection()
{
return static::table()->reestablish_connection();
}
/**
* Returns the {@link Table} object for this model.
*
* Be sure to call in static scoping: static::table()
*
* @return Table
*/
public static function table()
{
return Table::load(get_called_class());
}
/**
* Creates a model and saves it to the database.
*
* @param array $attributes Array of the models attributes
* @param boolean $validate True if the validators should be run
* @param boolean $guard_attributes Set to true to guard protected/non-accessible attributes
* @return Model
*/
public static function create($attributes, $validate=true, $guard_attributes=true)
{
$class_name = get_called_class();
$model = new $class_name($attributes, $guard_attributes);
$model->save($validate);
return $model;
}
/**
* Save the model to the database.
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Model.php
return array_filter($models);
}
/**
* Finder method which will find by a single or array of primary keys for this model.
*
* @see find
* @param array $values An array containing values for the pk
* @param array $options An options array
* @return Model
* @throws {@link RecordNotFound} if a record could not be found
*/
public static function find_by_pk($values, $options)
{
if($values===null)
{
throw new RecordNotFound("Couldn't find ".get_called_class()." without an ID");
}
$table = static::table();
if($table->cache_individual_model)
{
$list = static::get_models_from_cache($values, $options);
}
else
{
$options['conditions'] = static::pk_conditions($values);
$list = $table->find($options);
}
$results = count($list);
//if ($results != ($expected = count($values)))
if ($results != ($expected = count((array)$values)))
{
$class = get_called_class();
if (is_array($values))
$values = join(',',$values);
if ($expected == 1)
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Model.php
$options['order'] = SQLBuilder::reverse_order($options['order']);
// fall thru
case 'first':
$options['limit'] = 1;
$options['offset'] = 0;
break;
}
$args = array_slice($args,1);
$num_args--;
}
//find by pk
elseif (1 === count($args) && 1 == $num_args)
$args = $args[0];
// anything left in $args is a find by pk
if ($num_args > 0 && !isset($options['conditions']))
return static::find_by_pk($args, $options);
$options['mapped_names'] = static::$alias_attribute;
$list = static::table()->find($options);
return $single ? (!empty($list) ? $list[0] : null) : $list;
}
/**
* Will look up a list of primary keys from cache
*
* @param mixed $pks primary keys
* @return array
*/
protected static function get_models_from_cache($pks, $options)
{
$models = array();
$table = static::table();
if(!is_array($pks))
{
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Model.php
{
// access association to ensure that the relationship has been loaded
// so that we do not double-up on records if we append a newly created
$this->$association_name;
return $association->$method($this, $args);
}
}
throw new ActiveRecordException("Call to undefined method: $method");
}
/**
* Alias for self::find('all').
*
* @see find
* @return array array of records found
*/
public static function all(/* ... */)
{
return call_user_func_array('static::find',array_merge(array('all'),func_get_args()));
}
/**
* Get a count of qualifying records.
*
* <code>
* YourModel::count(array('conditions' => 'amount > 3.14159265'));
* </code>
*
* @see find
* @return int Number of records that matched the query
*/
public static function count(/* ... */)
{
$args = func_get_args();
$options = static::extract_and_validate_options($args);
$options['select'] = 'COUNT(*)';
if (!empty($args) && !is_null($args[0]) && !empty($args[0]))
{
Arguments
/home
/thepos.xyz
/bhawani-medical
/vendor
/php-activerecord
/php-activerecord
/lib
/Model.php
{
// access association to ensure that the relationship has been loaded
// so that we do not double-up on records if we append a newly created
$this->$association_name;
return $association->$method($this, $args);
}
}
throw new ActiveRecordException("Call to undefined method: $method");
}
/**
* Alias for self::find('all').
*
* @see find
* @return array array of records found
*/
public static function all(/* ... */)
{
return call_user_func_array('static::find',array_merge(array('all'),func_get_args()));
}
/**
* Get a count of qualifying records.
*
* <code>
* YourModel::count(array('conditions' => 'amount > 3.14159265'));
* </code>
*
* @see find
* @return int Number of records that matched the query
*/
public static function count(/* ... */)
{
$args = func_get_args();
$options = static::extract_and_validate_options($args);
$options['select'] = 'COUNT(*)';
if (!empty($args) && !is_null($args[0]) && !empty($args[0]))
{
Arguments
"static::find"
array:2 [
0 => "all"
1 => 1
]
/home
/thepos.xyz
/bhawani-medical
/app
/routes
/admin
/index.php
<?php
/*
* Route Url : /admin/dashboard
* Request type : GET
* Loading dashboard view if user is loggedin
*
*/
$app->map("GET", "/", function(){
$setting = Setting::all(1);
View::load("admin/index",array('setting'=>$setting));
});
$app->map("POST", "/login", function(){
if(!Input::exists('token')){
Redirect::to(base_url());
exit;
}
if(!Input::exists('email') || !Input::exists('password') || !Input::exists('token')){
Session::put("type","error");
Session::put("msg","Input Fields are required.");
Redirect::to(base_url());
exit;
}else{
if(Token::check(Input::all())){
Arguments
/home
/thepos.xyz
/bhawani-medical
/core
/classes
/Router.php
. ($pre !== '' ? $pre : null)
. '('
. ($param !== '' ? "?P<$param>" : null)
. $type
. '))'
. ($optional !== '' ? '?' : null);
$route = str_replace($block, $pattern, $route);
}
}
return "`^$route$`u";
}
public function run(){
$match = $this->match();
//dd($match); exit;
if( $match && is_callable( $match['target'] ) ) {
call_user_func_array( $match['target'], $match['params'] );
} else {
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
echo Json::encode(['error' => 'invalid api call please contact provider']);
}
}
}
/home
/thepos.xyz
/bhawani-medical
/index.php
<?php
define("SYSTEM_PATH", __dir__."/");
require_once SYSTEM_PATH."core/init.php";
$app->run();