in model, selectReadConnection's param is fixed or custom?

class Robots extends Phalcon\Mvc\Model
{
    public function selectReadConnection($intermediate, $bindParams, $bindTypes)
    {
     ....

params ($intermediate, $bindParams, $bindTypes) is fixed or custom?

how to set the param value?



368

Follow tutorial http://docs.phalconphp.com/en/latest/reference/models.html

But constants are wrong in documentation, correct are BINDPARAMNULL BINDPARAMINT BINDPARAMSTR BINDPARAMBOOL BINDPARAMDECIMAL BIND_SKIP Related to : http://docs.phalconphp.com/en/latest/api/Phalcon%5Db%5Column.html



84.5k

That function is called to select the correct connection used to read, there you receive the parameters that were passed in the query:

$robots = Robots::find(['type = ?0', 'bind' => ['Virtual'], 'bindTypes' => [Column::BIND_PARAM_STR]);


12.4k

ok,thanks . i test it after a while

now, the selectReadConnection is fixed method within phalcon framework, i want to say , selectReadConnection method not full intro in document , and i find the api \Phalcon\Mvc\Model not have this method .

but have these method in api

public Phalcon\Mvc\Model setReadConnectionService (string $connectionService)

Sets the DependencyInjection connection service name used to read data

public Phalcon\Mvc\Model setWriteConnectionService (string $connectionService)

Sets the DependencyInjection connection service name used to write data

public string getReadConnectionService ()

Returns the DependencyInjection connection service name used to read data related the model

public string getWriteConnectionService ()


12.4k

selectReadConnection must be a connection?

i want to split a big table to many table , but in one database. how can i do ?



12.4k
Array
(
    [models] => Array
        (
            [0] => Test
        )

    [tables] => Array
        (
            [0] => test
        )

    [columns] => Array
        (
            [test] => Array
                (
                    [type] => object
                    [model] => Test
                    [column] => test
                    [balias] => test
                )

        )

    [where] => Array
        (
            [type] => binary-op
            [op] => =
            [left] => Array
                (
                    [type] => qualified
                    [domain] => test
                    [name] => id
                    [balias] => id
                )

            [right] => Array
                (
                    [type] => literal
                    [value] => 1
                )

        )

)

parame $intermediate 's print_r value.

this post not a question , Facilitate others to use



84.5k

selectReadConnection is not implemented by the extension, the extension checks if the method has been defined by the developer in a model and calls it, this is the same behavior for event callbacks (beforeSave, beforeDelete) etc.

Actually, this funcionality is not intended to implement vertical sharding, you can use this method to implement horizontal sharding, this means, return a connection name according to the current search parameters, rather than return a table name.



12.4k

ok ,thanks